eladg / ffmpeg-by-example

Creative Commons Attribution 4.0 International
8 stars 5 forks source link

Print a text file to STDOUT using ffmpeg - FFmpeg By Example #43

Open eladg opened 2 years ago

eladg commented 2 years ago

https://www.ffmpegbyexample.com/examples/ktpgpp8f/print_text_file_to_stdout_using_ffmpeg/

Source: Reddit

This is a great example in demonstrating the versatility of using 'inputs', 'outputs' and 'formats' with ffmpeg.

By setting -f data ahead of -i input.txt we instruct FFmpeg to treat the input file as 'raw data'. For a full list of supported input/output formats, run ffmpeg -formats.

The params following the input (i.e. everything after -i) will define the output we intend ffmpeg to generate.

First, we would like to 'map' the input stream 0:0 to the output stream. Next, we set the encoding to 'Raw text subtitle'. For a full list of supported encoders, run ffmpeg -encoders. Then, we set the format of the output stream to 'raw data'. Lastly, normally ffmpeg generates a file, however in this case we would like to dump our raw data stream into STDOUT using by adding the - at the end of the command.

eladg commented 2 years ago

This is one of my favorite little hacks!