FFmpeg has a number of video generating filters, listed in the documentation as "video sources":
Those are great for using with other filters like overlay, but is there any way that I can generate a movie consisting of just one of those video sources without any input video?
Something like:
ffmpeg -vf color=red" red_movie.mp4
Except that that errors out with At least one input file must be specified
.
From the FFmpeg documentation: -lavfi filtergraph (global) Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs. Equivalent to -filter_complex.
Ffmpeg stands for Fast Forward MPEG. It's an opensource software project for working with audio and video. It is command-line based and lets you handle video, audio, multimedia files, and streams. You'll find it used for transcoding, simple editing, video scaling, video post-production effects and standards compliance.
It looks like the options have changed slightly in recent versions.
To use the filter input sources, you have to:
-f lavfi
-i
flag (not -vf
)color=color=red
This works for ffplay
, too, to test your filtergraph: ffplay -f lavfi -i color
In these examples I've added -t 30
to specify that I only want 30 seconds of output.
ffmpeg -f lavfi -i color=color=red -t 30 red.mp4 ^ ^ ^ | | | filter key value
The key can be shortened to its abbreviated form: -i color=c=red
ffmpeg -f lavfi -i smptebars -t 30 smpte.mp4
ffmpeg -f lavfi -i testsrc -t 30 -pix_fmt yuv420p testsrc.mp4
In order for this to playback reliably, you might need to set the pixel format with: -pix_fmt yuv420p
By default, ffmpeg will use yuv444p (x264, High 4:4:4 Predictive), which some players aren't yet able to decode.
For instance, the video it creates is crashing VLC 2.0.7 and is just 30 seconds of black in QuickTime Player 10.2 (Mac OS X 10.8.4).
More info on test source here.
ffmpeg -f lavfi -i rgbtestsrc -pix_fmt yuv420p -t 30 rgbtestsrc.mp4
As with the last example, this might not work for you unless you set the pixel format to yuv420p as shown.
For posterity, here's the version I'm using:
ffmpeg version 1.2.1 libavutil 52. 18.100 / 52. 18.100 libavcodec 54. 92.100 / 54. 92.100 libavformat 54. 63.104 / 54. 63.104 libavdevice 54. 3.103 / 54. 3.103 libavfilter 3. 42.103 / 3. 42.103 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With