ffmpeg scale and overlay then output yuv got corrupted video I wanted to scale a video input (1.webm) and keeping it's aspect ratio,
then overlay to make it centered, with following command:


  ffmpeg -y -hide_banner -i 1.webm -filter_complex "color=color=Black:size=640x480:d=7.420[bg];[0:0]scale=w='iwmin(640/iw,480/ih)':h='ihmin(640/iw,480/ih)'[scaled];[bg][scaled]overlay=x=(W-w)/2:y=(H-h)/2" -an -f rawvideo -c:v rawvideo -s:v 640x480 -pixel_format yuv420p 1.yuv


the output seem corrupted, dark area in original video turns purple or pink, and it's blinking.

I edited the command to remove the overlay filter, with following command:


  ffmpeg -y -hide_banner -i 1.webm -filter_complex "[0:0]scale=w='iwmin(640/iw,480/ih)':h='ihmin(640/iw,480/ih)'" -an -f rawvideo -c:v rawvideo -s:v 640x480 -pixel_format yuv420p 1.yuv


this time, the output seem fine.

I can't figure out what is going wrong, please help.
I suspect this has to do with lack 1-1 correspondence between the frame timings in the color and video, but in any case, you can just run

ffmpeg -y -hide_banner -i 1.webm
       -vf "scale=w=640:h=480:force_original_aspect_ratio=decrease,
            pad=640:480:(ow-iw)/2:(oh-ih)/2"
       -an -f rawvideo -pix_fmt yuv420p 1.yuv