Changes between Version 13 and Version 14 of Creating multiple outputs


Ignore:
Timestamp:
Apr 10, 2014, 10:11:36 PM (5 years ago)
Author:
llogan
Comment:

nits; remove unsubstantiated rambling; remove old link

Legend:

Unmodified
Added
Removed
Modified
  • Creating multiple outputs

    v13 v14  
    22= Introduction =
    33
    4 The following example command lines, that are usually written in one line, have been split into multiple lines, using the new-line delimiter character "\" for more clarity. So, if the example shows something like this:
     4The following example command lines, that are usually written in one line, have been split into multiple lines, using the new-line delimiter character `\` for more clarity. So, if the example shows something like this:
    55{{{
    66ffmpeg -i input \
    7         -acodec .. \
    8         -vcodec .. \
     7        -acodec \
     8        -vcodec \
    99        output1
    1010}}}
    1111that means the actual command line, typed in the shell, would be:
    1212{{{
    13 ffmpeg -i input -acodec .. -vcodec .. output1
     13ffmpeg -i input -acodec … -vcodec … output1
    1414}}}
     15but either iteration will work in a sane shell.
    1516
    1617= Different parallel outputs =
     
    1819[[Image(creating_multiple_outputs2.png)]]
    1920
    20 FFmpeg supports multiple outputs created out of the same input(s). The usual way to accomplish this is:
     21`ffmpeg` supports multiple outputs created out of the same input(s). The usual way to accomplish this is:
    2122{{{
    22 ffmpeg -i input1 -i input2\
    23         -acodec .. -vcodec .. output1\
    24         -acodec .. -vcodec .. output2\
    25         -acodec .. -vcodec .. output3
     23ffmpeg -i input1 -i input2 \
     24        -acodec … -vcodec … output1 \
     25        -acodec … -vcodec … output2 \
     26        -acodec … -vcodec … output3
    2627}}}
    27 This way FFmpeg can create several '''different outputs''' out of the same input(s).
     28This way `ffmpeg` can create several '''different outputs''' out of the same input(s).
    2829
    2930For example, to encode your video in HD, VGA and QVGA resolution, at the same time, you would use something like this:
    3031{{{
    3132ffmpeg -i input\
    32         -s 1280x720 -acodec .. -vcodec .. output1\
    33         -s 640x480 -acodec .. -vcodec .. output2\
    34         -s 320x240 -acodec .. -vcodec .. output3
     33        -s 1280x720 -acodec … -vcodec … output1 \
     34        -s 640x480 -acodec … -vcodec … output2 \
     35        -s 320x240 -acodec … -vcodec … output3
    3536}}}
    3637
     
    4344== Tee pseudo-muxer ==
    4445
    45 The tee pseudo-muxer was added to ffmpeg on 2013-02-03, and allows you to duplicate the output to multiple files, on a single instance of ffmpeg.
     46The [https://ffmpeg.org/ffmpeg-formats.html#tee tee pseudo-muxer] was added to `ffmpeg` on 2013-02-03, and allows you to duplicate the output to multiple files with a single instance of `ffmpeg`.
    4647
    4748{{{
     
    5657Older versions of ffmpeg can also do this, using 2 piped processes, where the first process is used to encode the stream(s) and second process is used to duplicate that to several outputs.
    5758{{{
    58 ffmpeg -i input1 -i input2 -acodec .. -vcodec .. -f mpegts - | \
     59ffmpeg -i input1 -i input2 -acodec … -vcodec … -f mpegts - | \
    5960        ffmpeg -f mpegts -i - \
    6061                -c copy output1 \
     
    6263                -c copy output3 \
    6364}}}
    64 ''Note: If you are using older FFmpeg and "-c copy" is not recognized, then you can replace it with "-acodec copy -vcodec copy".''
    6565
    66 For example, if you want to stream your webcam and save the copy of the stream into the local file, you can do it like this:
     66{{{
     67#!div style="border: 1pt dotted; margin: 1em; background-color: #fffff9;"
     68'''Note:''' If you are using older `ffmpeg` and `-c copy` is not recognized, then you can replace it with `-acodec copy -vcodec copy`.
     69}}}
    6770
    6871{{{
     
    7376}}}
    7477
    75 = Parallel Encoding =
    76 
    77 Another option is to output from FFmpeg to "-" then to pipe that to a "tee" command, which can send it to multiple other processes, for instance 2 different other ffmpeg processes for encoding (this may save time, as if you do different encodings, and do the encoding in 2 different simultaneous processes, it might do encoding more in parallel than elsewise).  Un benchmarked, however, see also [http://ffmpeg-users.933282.n4.nabble.com/Multiple-output-files-td2076623.html here].
    78 
    7978= Multiple encodings for same input =
    8079
    81 If you had one input, then run it through some filters, then encode it to (for instance) several different bitrates to multiple files, then you may be able to save processing power by performing the filtering only once. This can be accomplished via the "map" feature, for instance, in this example the rescaling is performed only once, then encoded to 2 outputs:
     80You can use one filtering instance for multiple outputs. This can be accomplished via the `-map` option. In this example the scaling is performed only once then encoded to two outputs:
    8281
    8382{{{
    84 ffmpeg -i input -an -filter_complex "[0] scale=1000:1000,split=2
    85 [a] [b]" -y -map "[a]" output1.avi -map "[b]" output2.avi
     83ffmpeg -i input -an -filter_complex "[0]scale=1000:1000,split=2[a][b]" \
     84-map "[a]" output1.mp4 -map "[b]" output2.avi
    8685}}}
    87 
    88 Again, you could use the "tee" command, see Parallel Encoding, to possibly do this more quickly, but this example at least avoids scaling twice.
    89 
    90 = See also =
    91 
    92 See also [http://stackoverflow.com/questions/12041077/ffmpeg-output-to-multiple-files-simultaneously this SO post].