Any supported file format and protocol can serve as input to ffmpeg:
Examples:
You can use YUV files as input:
ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
It will use the files:
/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
/tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the -s option if ffmpeg cannot guess it.
You can input from a raw YUV420P file:
ffmpeg -i /tmp/test.yuv /tmp/out.avi
test.yuv is a file containing raw YUV planar data. Each frame is composed of the Y plane followed by the U and V planes at half vertical and horizontal resolution.
You can output to a raw YUV420P file:
ffmpeg -i mydivx.avi hugefile.yuv
You can set several input files and output files:
ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
Converts the audio file a.wav and the raw YUV video file a.yuv to MPEG file a.mpg.
You can also do audio and video conversions at the same time:
ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
Converts a.wav to MPEG audio at 22050 Hz sample rate.
You can encode to several formats at the same time and define a mapping from input stream to output streams:
ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. ’-map file:index’ specifies which input stream is used for each output stream, in the order of the definition of output streams.
You can transcode decrypted VOBs:
ffmpeg -i snatch_1.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k snatch.avi
This is a typical DVD ripping example; the input is a VOB file, the output an AVI file with MPEG-4 video and MP3 audio. Note that in this command we use B-frames so the MPEG-4 stream is DivX5 compatible, and GOP size is 300 which means one intra frame every 10 seconds for 29.97fps input video. Furthermore, the audio stream is MP3-encoded so you need to enable LAME support by passing --enable-libmp3lame to configure. The mapping is particularly useful for DVD transcoding to get the desired audio language.
NOTE: To see the supported input formats, use ffmpeg -demuxers.
You can extract images from a video, or create a video from many images:
For extracting images from a video:
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
This will extract one video frame per second from the video and will output them in files named foo-001.jpeg, foo-002.jpeg, etc. Images will be rescaled to fit the new WxH values.
If you want to extract just a limited number of frames, you can use the above command in combination with the -frames:v or -t option, or in combination with -ss to start extracting from a certain point in time.
For creating a video from many images:
ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
The syntax foo-%03d.jpeg specifies to use a decimal number composed of three digits padded with zeroes to express the sequence number. It is the same syntax supported by the C printf function, but only formats accepting a normal integer are suitable.
When importing an image sequence, -i also supports expanding shell-like wildcard patterns (globbing) internally, by selecting the image2-specific -pattern_type glob option.
For example, for creating a video from filenames matching the glob pattern foo-*.jpeg:
ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
You can put many streams of the same type in the output:
ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
The resulting output file test12.nut will contain the first four streams from the input files in reverse order.
To force CBR video output:
ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
The four options lmin, lmax, mblmin and mblmax use ’lambda’ units, but you may use the QP2LAMBDA constant to easily convert from ’q’ units:
ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext