FFmpeg has a number of video generating filters, listed in the documentation as "video sources":
- cellauto
- color
- mptestsrc
- fei0r_src
- life
- nullsrc, rgbtestsrc, testsrc
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
.
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
Examples
In these examples I've added
-t 30
to specify that I only want 30 seconds of output.Color (Red)
The key can be shortened to its abbreviated form:
-i color=c=red
SMPTE Color Bars Pattern
Test Source Pattern
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.
RGB Test Source
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:
Though hinted at in the documentation, this isn't explicitly spelled out. I was pleased to figure it out, so I thought I'd share.
The key is to use the special format
lavfi
:Essentially,
lavfi
format causes the input to be treated as a video filter instead of a filename.Thus, to make a movie consisting of nothing but red, the command is:
(Specifying the number of frames or otherwise limiting the input is crucial as filters generally have no fixed "end" point, and will happily go on generating video forever.)