Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-03T23:03:21.780Z
Answers.Text: What's the complex filter equivalent to `-pix_fmt`? Would `format=yuva420p` be enough?
Answers.UserDisplayName: Hashim Aziz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-04T02:18:00.273Z
Answers.Text: Not sure, that might be a good candidate for a new question
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-02T18:11:52.823Z
Answers.Text: Is it possible to use this for a .mov video file?
Answers.UserDisplayName: aaragon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-15T10:37:49.687Z
Answers.Text: `-pix_fmt yuva420p` not work in `hevc` and `nvenc`.
Answers.UserDisplayName: rint
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-02T02:44:39.590Z
Answers.Text: alpha isn't supported by hevc and nvenc
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-05T01:01:54.083Z
Answers.LastActivityDate: 2021-01-05T01:15:49.910Z
Answers.LastEditDate: 2021-01-05T01:15:49.910Z
Answers.UserDisplayName: stib
Body: <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>
  
Tags: <ffmpeg><alpha>
Title: Creating transparent video from transparent png files using ffmpeg
UserDisplayName: aaragon
ThreadText: # 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](https://video.stackexchange.com/questions/23893/make-white-background-in-mp4-movie-transparent). 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](https://ffmpeg.org/ffmpeg.html#Advanced-Video-options). 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  
  
  ---
  
  