<p>The native VP8/9 decoders don't support transparency, so a) you'll have to force a decoder, b) the way to change transparent pixels is to overlay the video onto the color.</p>

<pre><code>ffmpeg -c:v libvpx -i 123.webm -f lavfi -i color=c=0xD9DADB,format=rgb24
       -filter_complex "[1][0]scale2ref[bg][vid];[bg][vid]overlay=format=rgb:shortest=1,setsar=1"
       -pix_fmt yuv420p -c:a copy 123.mp4
</code></pre>

CC BY-SA 4.0
2022-03-14T15:26:51.323Z
If your WebM isn't using VP8 but instead VP9, you need to replace `-c:v libvpx` with `-c:v libvpx-vp9`.
luckydonald
CC BY-SA 4.0
2019-01-29T20:58:58.470Z
this is great - just 2 problems though. 1) the rendering doesn't stop - it can go well past the final frame. 2) the resolution is different than the original. I'm guessing its because of the pix_fmt argument? How can i set specific dimensions for the final image?
Parris
CC BY-SA 4.0
2019-01-29T21:03:24.547Z
1) corrected, 2) not because of that, also corrected
Gyan
CC BY-SA 4.0
2019-01-29T05:02:23.673Z
2019-01-29T21:02:50.127Z
2019-01-29T21:02:50.127Z
Gyan
<p>I'm trying to convert a webm file that has a transparent background to an mp4 file. Mp4 doesn't have transparency so I'm trying to using this color: #D9DADB. How can I make this conversion happen with a single command in ffmpeg?</p>

<p>I've tried the following command and I seem to get a black background instead of a gray one: </p>

<pre><code>ffmpeg -f lavfi -i color=c=0xD9DADB -i 123.webm 123.mp4
</code></pre>

<ffmpeg><mp4>
How can you convert a WebM with transparency to MP4 with a background color using ffmpeg?
Parris
# How can you convert a WebM with transparency to MP4 with a background color using ffmpeg?

(Asked by: username_0 on 2019-01-29)

I'm trying to convert a webm file that has a transparent background to an mp4 file. Mp4 doesn't have transparency so I'm trying to using this color: #D9DADB. How can I make this conversion happen with a single command in ffmpeg?
I've tried the following command and I seem to get a black background instead of a gray one: 
ffmpeg -f lavfi -i color=c=0xD9DADB -i 123.webm 123.mp4

**Tags:** ffmpeg, mp4


---

## 1 answers

### Answer by username_1 on 2019-01-29. Score: 4 | Accepted answer

The native VP8/9 decoders don't support transparency, so a) you'll have to force a decoder, b) the way to change transparent pixels is to overlay the video onto the color.
ffmpeg -c:v libvpx -i 123.webm -f lavfi -i color=c=0xD9DADB,format=rgb24
       -filter_complex "[1][0]scale2ref[bg][vid];[bg][vid]overlay=format=rgb:shortest=1,setsar=1"
       -pix_fmt yuv420p -c:a copy 123.mp4

> **Comments:**
> **username_0**: this is great - just 2 problems though. 1) the rendering doesn't stop - it can go well past the final frame. 2) the resolution is different than the original. I'm guessing its because of the pix_fmt argument? How can i set specific dimensions for the final image?  
> **username_1**: 1) corrected, 2) not because of that, also corrected  
> **username_2**: If your WebM isn't using VP8 but instead VP9, you need to replace `-c:v libvpx` with `-c:v libvpx-vp9`.  

---

