Changes between Version 13 and Version 14 of Creating multiple outputs
- Timestamp:
- Apr 10, 2014, 10:11:36 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Creating multiple outputs
v13 v14 2 2 = Introduction = 3 3 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: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: 5 5 {{{ 6 6 ffmpeg -i input \ 7 -acodec ..\8 -vcodec ..\7 -acodec … \ 8 -vcodec … \ 9 9 output1 10 10 }}} 11 11 that means the actual command line, typed in the shell, would be: 12 12 {{{ 13 ffmpeg -i input -acodec .. -vcodec ..output113 ffmpeg -i input -acodec … -vcodec … output1 14 14 }}} 15 but either iteration will work in a sane shell. 15 16 16 17 = Different parallel outputs = … … 18 19 [[Image(creating_multiple_outputs2.png)]] 19 20 20 FFmpegsupports 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: 21 22 {{{ 22 ffmpeg -i input1 -i input2 \23 -acodec .. -vcodec .. output1\24 -acodec .. -vcodec .. output2\25 -acodec .. -vcodec ..output323 ffmpeg -i input1 -i input2 \ 24 -acodec … -vcodec … output1 \ 25 -acodec … -vcodec … output2 \ 26 -acodec … -vcodec … output3 26 27 }}} 27 This way FFmpegcan create several '''different outputs''' out of the same input(s).28 This way `ffmpeg` can create several '''different outputs''' out of the same input(s). 28 29 29 30 For example, to encode your video in HD, VGA and QVGA resolution, at the same time, you would use something like this: 30 31 {{{ 31 32 ffmpeg -i input\ 32 -s 1280x720 -acodec .. -vcodec .. output1\33 -s 640x480 -acodec .. -vcodec .. output2\34 -s 320x240 -acodec .. -vcodec ..output333 -s 1280x720 -acodec … -vcodec … output1 \ 34 -s 640x480 -acodec … -vcodec … output2 \ 35 -s 320x240 -acodec … -vcodec … output3 35 36 }}} 36 37 … … 43 44 == Tee pseudo-muxer == 44 45 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.46 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`. 46 47 47 48 {{{ … … 56 57 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. 57 58 {{{ 58 ffmpeg -i input1 -i input2 -acodec .. -vcodec ..-f mpegts - | \59 ffmpeg -i input1 -i input2 -acodec … -vcodec … -f mpegts - | \ 59 60 ffmpeg -f mpegts -i - \ 60 61 -c copy output1 \ … … 62 63 -c copy output3 \ 63 64 }}} 64 ''Note: If you are using older FFmpeg and "-c copy" is not recognized, then you can replace it with "-acodec copy -vcodec copy".''65 65 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 }}} 67 70 68 71 {{{ … … 73 76 }}} 74 77 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 79 78 = Multiple encodings for same input = 80 79 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 2outputs: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: 82 81 83 82 {{{ 84 ffmpeg -i input -an -filter_complex "[0] scale=1000:1000,split=285 [a] [b]" -y -map "[a]" output1.avi-map "[b]" output2.avi83 ffmpeg -i input -an -filter_complex "[0]scale=1000:1000,split=2[a][b]" \ 84 -map "[a]" output1.mp4 -map "[b]" output2.avi 86 85 }}} 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].