<p>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</p>

<pre><code>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
</code></pre>

CC BY-SA 3.0
2017-08-07T12:14:37.897Z
Mulvya, your command works like a charm, thanks.
And, nice formatting, will format my command line next time.
Slacker
CC BY-SA 3.0
2017-08-07T10:39:37.877Z
2017-08-07T10:39:37.877Z
Gyan
<p>I wanted to scale a video input (1.webm) and keeping it's aspect ratio,
then overlay to make it centered, with following command:</p>

<blockquote>
  <p>ffmpeg -y -hide_banner -i 1.webm -filter_complex "color=color=Black:size=640x480:d=7.420[bg];[0:0]scale=w='iw<em>min(640/iw,480/ih)':h='ih</em>min(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</p>
</blockquote>

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

<p>I edited the command to remove the overlay filter, with following command:</p>

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

<p>this time, the output seem fine.</p>

<p>I can't figure out what is going wrong, please help. </p>

CC BY-SA 3.0
2017-08-07T10:38:03.117Z
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
<ffmpeg>
ffmpeg scale and overlay then output yuv got corrupted video
Slacker
# ffmpeg scale and overlay then output yuv got corrupted video

(Asked by: username_0 on 2017-08-07)

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='iw*min(640/iw,480/ih)':h='ih*min(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='iw*min(640/iw,480/ih)':h='ih*min(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.

**Tags:** ffmpeg

> **Comments:**
> **username_0**: 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  

---

## 1 answers

### Answer by username_1 on 2017-08-07. Score: 0 | Accepted answer

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

> **Comments:**
> **username_0**: Mulvya, your command works like a charm, thanks. And, nice formatting, will format my command line next time.  

---

