Changes between Version 14 and Version 15 of Creating multiple outputs


Ignore:
Timestamp:
Jan 16, 2015, 2:46:04 AM (4 years ago)
Author:
Timothy_Gu
Comment:

Reorganize

Legend:

Unmodified
Added
Removed
Modified
  • Creating multiple outputs

    v14 v15  
    1 [[PageOutline(1-2, Contents)]]
    2 = Introduction =
     1= Creating Multiple Outputs =
     2[[PageOutline(2-3, Contents)]]
     3
     4== Introduction ==
    35
    46The 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:
     
    1517but either iteration will work in a sane shell.
    1618
    17 = Different parallel outputs =
     19== Different parallel outputs ==
    1820
     21=== No filtering ===
    1922[[Image(creating_multiple_outputs2.png)]]
    2023
     
    3033For example, to encode your video in HD, VGA and QVGA resolution, at the same time, you would use something like this:
    3134{{{
    32 ffmpeg -i input\
     35ffmpeg -i input \
    3336        -s 1280x720 -acodec … -vcodec … output1 \
    34         -s 640x480 -acodec … -vcodec … output2 \
    35         -s 320x240 -acodec … -vcodec … output3
     37        -s 640x480  -acodec … -vcodec … output2 \
     38        -s 320x240  -acodec … -vcodec … output3
    3639}}}
    3740
    38 = Duplicate outputs =
     41=== Same filtering for all outputs ===
     42
     43If you would like to use filtering, but with the same filter applied to all outputs, simply use `-filter_complex` with the `split` filter.
     44
     45For example, to encode your video in HD, VGA and QVGA resolution, at the same time, but with the yadif filter applied, you would use something like this:
     46{{{
     47#!sh
     48# the `split=3` means split to three streams
     49ffmpeg -i input -filter_complex '[0:v]yadif,split=3[out1][out2][out3]' \
     50        -map '[out1]' -s 1280x720 -acodec … -vcodec … output1 \
     51        -map '[out2]' -s 640x480  -acodec … -vcodec … output2 \
     52        -map '[out3]' -s 320x240  -acodec … -vcodec … output3
     53}}}
     54
     55=== One filtering instance per each output ===
     56
     57If you would like to use filtering, with the **different** filter(s) applied to each outputs, use `-filter_complex` and `split`, but using `split` directly to the input.
     58
     59For example, to encode your video to three different outputs, at the same time, but with the boxblur, negate, yadif filter applied to the different outputs respectively, you would use something like this:
     60{{{
     61#!sh
     62# the `split=3` means split to three streams
     63ffmpeg -i input -filter_complex '[0:v]split=3[in1][in2][in3];[in1]boxblur[out1];[in2]negate[out2];[in3]yadif[out3]' \
     64        -map '[out1]' -acodec … -vcodec … output1 \
     65        -map '[out2]' -acodec … -vcodec … output2 \
     66        -map '[out3]' -acodec … -vcodec … output3
     67}}}
     68
     69== Duplicate outputs ==
    3970
    4071[[Image(creating_multiple_outputs1.png)]]
     
    4273But, what if you want to have duplicate outputs of your encoding? For example, when you are streaming a live audio/video and want to save a duplicate of that stream into the file at the same time.  You don't want to encode twice, that wastes cpu.
    4374
    44 == Tee pseudo-muxer ==
     75=== Tee pseudo-muxer ===
    4576
    4677The [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`.
     
    5384The above outputs an MKV file, and a UDP stream. Streams are separated by the `|` symbol. Options can be applied to an individual output: `[f=mpegts]` is equivalent to `-f mpegts` in a normal ffmpeg command-line. Multiple options can be separated with a `:`, which means that any `:` have to be escaped (so use `\:`).
    5485
    55 == Piped processes ==
     86=== Piped processes ===
    5687
    5788Older 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.
     
    75106                -c copy -f mpegts local.ts
    76107}}}
    77 
    78 = Multiple encodings for same input =
    79 
    80 You 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:
    81 
    82 {{{
    83 ffmpeg -i input -an -filter_complex "[0]scale=1000:1000,split=2[a][b]" \
    84 -map "[a]" output1.mp4 -map "[b]" output2.avi
    85 }}}