Changes between Initial Version and Version 1 of Creating multiple outputs


Ignore:
Timestamp:
Jul 24, 2012, 2:57:23 PM (7 years ago)
Author:
burek
Comment:

Page created

Legend:

Unmodified
Added
Removed
Modified
  • Creating multiple outputs

    v1 v1  
     1= Introduction =
     2
     3The 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{{{
     5ffmpeg -i input \
     6        -acodec .. \
     7        -vcodec .. \
     8        output1
     9}}}
     10that means the actual command line, typed in the shell, would be:
     11{{{
     12ffmpeg -i input -acodec .. -vcodec .. output1
     13}}}
     14
     15= Different parallel outputs =
     16
     17FFmpeg supports multiple outputs created out of the same input(s). The usual way to accomplish this is:
     18{{{
     19ffmpeg -i input1 -i input2\
     20        -acodec .. -vcodec .. output1\
     21        -acodec .. -vcodec .. output2\
     22        -acodec .. -vcodec .. output3
     23}}}
     24This way FFmpeg can create several '''different outputs''' out of the same input(s).
     25
     26For example, to encode your video in HD, VGA and QVGA resolution, at the same time, you would use something like this:
     27{{{
     28ffmpeg -i input\
     29        -s 1280x720 -acodec .. -vcodec .. output1\
     30        -s 640x480 -acodec .. -vcodec .. output2\
     31        -s 320x240 -acodec .. -vcodec .. output3
     32}}}
     33
     34= Duplicate outputs =
     35
     36But, 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.
     37FFmpeg 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.
     38{{{
     39ffmpeg -i input1 -i input2 -acodec .. -vcodec .. -f mpegts - \
     40        | \
     41        ffmpeg -f mpegts - \
     42                -c copy output1 \
     43                -c copy output2 \
     44                -c copy output3 \
     45}}}
     46''Note: If you are using older FFmpeg and "-c copy" is not recognized, then you can replace it with "-acodec copy -vcodec copy".''
     47
     48For 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:
     49
     50{{{
     51ffmpeg -f v4l2 -i /dev/video0 -vcodec libx264 -f mpegts - \
     52        | \
     53        ffmpeg -f mpegts - \
     54                -c copy -f mpegts udp://1.2.3.4:5678 \
     55                -c copy -f mpegts local.ts
     56}}}