Changes between Version 14 and Version 15 of Creating multiple outputs
- Timestamp:
- Jan 16, 2015, 12:46:04 AM (12 years ago)
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 == 3 5 4 6 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: … … 15 17 but either iteration will work in a sane shell. 16 18 17 = Different parallel outputs=19 == Different parallel outputs == 18 20 21 === No filtering === 19 22 [[Image(creating_multiple_outputs2.png)]] 20 23 … … 30 33 For example, to encode your video in HD, VGA and QVGA resolution, at the same time, you would use something like this: 31 34 {{{ 32 ffmpeg -i input \35 ffmpeg -i input \ 33 36 -s 1280x720 -acodec … -vcodec … output1 \ 34 -s 640x480 -acodec … -vcodec … output2 \35 -s 320x240 -acodec … -vcodec … output337 -s 640x480 -acodec … -vcodec … output2 \ 38 -s 320x240 -acodec … -vcodec … output3 36 39 }}} 37 40 38 = Duplicate outputs = 41 === Same filtering for all outputs === 42 43 If you would like to use filtering, but with the same filter applied to all outputs, simply use `-filter_complex` with the `split` filter. 44 45 For 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 49 ffmpeg -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 57 If 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 59 For 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 63 ffmpeg -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 == 39 70 40 71 [[Image(creating_multiple_outputs1.png)]] … … 42 73 But, 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. 43 74 44 == Tee pseudo-muxer==75 === Tee pseudo-muxer === 45 76 46 77 The [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`. … … 53 84 The 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 `\:`). 54 85 55 == Piped processes==86 === Piped processes === 56 87 57 88 Older 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. … … 75 106 -c copy -f mpegts local.ts 76 107 }}} 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.avi85 }}}
