<p>You have to specify the pixel format, to force it to include the alpha channel, using the <a href="https://ffmpeg.org/ffmpeg.html#Advanced-Video-options" rel="nofollow noreferrer"><code>-pix_fmt</code> option</a>. You don't need to use png as your video codec either.</p>
<pre><code>ffmpeg -i anim.%04d.png -r 30  -pix_fmt yuva420p video.webm
</code></pre>

CC BY-SA 4.0
2022-02-03T23:03:21.780Z
What's the complex filter equivalent to `-pix_fmt`? Would `format=yuva420p` be enough?
Hashim Aziz
CC BY-SA 4.0
2022-02-04T02:18:00.273Z
Not sure, that might be a good candidate for a new question
stib
CC BY-SA 4.0
2022-11-02T18:11:52.823Z
Is it possible to use this for a .mov video file?
aaragon
CC BY-SA 4.0
2023-09-15T10:37:49.687Z
`-pix_fmt yuva420p` not work in `hevc` and `nvenc`.
rint
CC BY-SA 4.0
2023-10-02T02:44:39.590Z
alpha isn't supported by hevc and nvenc
stib
CC BY-SA 4.0
2021-01-05T01:01:54.083Z
2021-01-05T01:15:49.910Z
2021-01-05T01:15:49.910Z
stib
<p>I have a set of 300 transparent png files and I would like to create a transparent video file from them. I'm using the ffmpeg command as follows:</p>
<pre><code>ffmpeg -f image2 -i anim.%04d.png -r 30 -vcodec png video.webm
</code></pre>
<p>I know webm has an alpha channel according to <a href="https://video.stackexchange.com/questions/23893/make-white-background-in-mp4-movie-transparent">this answer</a>. The command creates the video but the transparency is completely lost. What am I doing wrong? Is it possible to create a transparent .mp4 with ffmpeg?</p>

<ffmpeg><alpha>
Creating transparent video from transparent png files using ffmpeg
aaragon
# Creating transparent video from transparent png files using ffmpeg

(Asked by: username_0 on 2021-01-03)

I have a set of 300 transparent png files and I would like to create a transparent video file from them. I'm using the ffmpeg command as follows:
ffmpeg -f image2 -i anim.%04d.png -r 30 -vcodec png video.webm

I know webm has an alpha channel according to this answer. The command creates the video but the transparency is completely lost. What am I doing wrong? Is it possible to create a transparent .mp4 with ffmpeg?

**Tags:** ffmpeg, alpha


---

## 1 answers

### Answer by username_1 on 2021-01-05. Score: 3 | Accepted answer

You have to specify the pixel format, to force it to include the alpha channel, using the -pix_fmt option. You don't need to use png as your video codec either.
ffmpeg -i anim.%04d.png -r 30  -pix_fmt yuva420p video.webm

> **Comments:**
> **username_2**: What's the complex filter equivalent to `-pix_fmt`? Would `format=yuva420p` be enough?  
> **username_1**: Not sure, that might be a good candidate for a new question  
> **username_0**: Is it possible to use this for a .mov video file?  
> **username_3**: `-pix_fmt yuva420p` not work in `hevc` and `nvenc`.  
> **username_1**: alpha isn't supported by hevc and nvenc  

---

