Overlay a temporary video with a solid background color using ffmpeg

I will be loading screenshots of the homepage with names homescreen000001.png, homescreen000002.pngetc., and I'm trying to create a video image with these images using ffmpeg.

It works for me at all 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 a transparent background, so the background appears on black in these images.

I need a white background, so I'm trying to configure it with 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.pngis 2px x 2px png with a white background and what is it.

This ffmpeg command creates a really tiny (in size) video that is only on a white background.

Can someone explain how I can overlay images in the form of video images on a white background using ffmpeg?

+4
2

, , ffmpeg, , , , .

:

ffmpeg -f lavfi -i color=c=white:s=1440x900 -i homescreen%06d.png -filter_complex \
"[0:v][1:v]overlay=shortest=1,format=yuv420p[out]" \
-map "[out]" output.mp4
+9

, ImageMagick :

convert in.png -alpha off out.png

( output), :

mkdir output
for i in *.png; do
   convert "$i" -alpha off output/"$i"
done

!

ImageMagick , Linux.

0

All Articles