0

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.

  • updates: I found that, after adding format filter right after color, the output seems fine, with following command: ffmpeg -y -hide_banner -i 1.webm -filter_complex "color=color=Black:size=640x480:d=7.420,format=pix_fmts=yuv420p[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 – Slacker Aug 7 '17 at 10:38
0

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
  • Mulvya, your command works like a charm, thanks. And, nice formatting, will format my command line next time. – Slacker Aug 7 '17 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.