I've got a load of screenshots of a homepage that are named homescreen000001.png
, homescreen000002.png
, etc and I'm trying to create a time-lapse video of these images using ffmpeg.
I've got it working in general when I run the following:
ffmpeg -f image2 \
-i ~/Desktop/homescreen%06d.png \
-r 0.5 \
-s 1440x900 \
-b:v 1M \
-vcodec libx264 \
-pix_fmt yuv420p \
~/Desktop/timelapse.mp4
However, it turns out that some of the images have transparent backgrounds so the background is showing up as black on those images.
I'd like a white background so I've been trying to set that up using ffmpeg as follows:
ffmpeg -f image2 \
-loop 1 \
-i ~/Desktop/whitebg.png \
-i ~/Desktop/homescreen%06d.png \
-filter_complex overlay \
-r 0.5 \
-s 1440x900 \
-b:v 1M \
-vcodec libx264 \
-pix_fmt yuv420p \
~/Desktop/timelapse.mp4
Here whitebg.png
is 2px x 2px png with a white background, and that's it.
This ffmpeg command produces a really tiny (in file size) video that's just a white background.
Can anyone explain how I can overlay the images as a time-lapse video over a white background using ffmpeg?
You can use the color filter as a background:
ffmpeg -f lavfi -i color=c=white:s=1920x1080:r=24 -framerate 24 -i input_%04d.png -filter_complex "[0:v][1:v]overlay=shortest=1,format=yuv420p[out]" -map "[out]" output.mp4
Also see:
You can replace the transparent pixels with white ones using ImageMagick like this:
convert in.png -alpha off out.png
or for a whole directory (with output files in a subdirectory called output
) like this:
mkdir output
for i in *.png; do
convert "$i" -alpha off output/"$i"
done
Please make a backup first!
ImageMagick is here though it is already installed on many Linux distros.
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