Reputation: 188
I have been generating static black videos as backgrounds using FFMPEG's color source. This works fine for smaller and shorter videos, but I need to be able to generate long 1080p black videos quickly.
For example, I can generate a two hour long 1080p@30fps video using:
ffmpeg -f lavfi -i color=black:s=1920x1080:r=30 -t 7200 test.mp4
But this will take over 45 minutes to run.
There are options that speed up runtime, like using the ultrafast
preset:
ffmpeg -f lavfi -i color=black:s=1920x1080:r=30 -preset ultrafast -t 7200 test.mp4
Which will take around 20 minutes to run. Better, but not good enough for doing this en masse.
Are there any other options to drastically speed up runtime?
Intuitively, I am generating a static video where only video duration varies, so it seems like there should be an approach that is restricted only by disk write speed. All of these options are very CPU intensive and seem to be doing more processing than is necessary for my use case.
Upvotes: 1
Views: 915
Reputation: 92928
Use the concat demuxer
Step 1 Generate a short black video
ffmpeg -f lavfi -i color=black:s=1920x1080:r=30 -t 5 -x264opts stitchable black.mp4
Step 2 Create a text file - full.txt
file black.mp4
file black.mp4
file black.mp4
file black.mp4
file black.mp4
file black.mp4
...
Number of entries should be equal to final duration / 5
Step 3 Create the full file
ffmpeg -f concat -i full.txt -c copy full.mp4
Upvotes: 4