Body: <p>I am a researcher, trying to string together a bunch of png files of a protein to a short video. I have all the png images with transparent backgrounds, but I can't seem to get this in the video.</p>
  <p>I use this (on macOS terminal) to convert:</p>
  <pre><code>ffmpeg -framerate 20 -pattern_type glob -i '*.png' -c:v libx264 -preset slow  -profile:v high -level:v 4.0 -pix_fmt yuv420p -vf pad=&quot;width=ceil(iw/2)*2:height=ceil(ih/2)*2&quot; -crf 22 -codec:a aac -pix_fmt yuva420p SST4.mp4
  </code></pre>
  <p>I added the <code>-pix_fmt yuva420p</code> that I found as an <a href="https://video.stackexchange.com/a/33011">accepted answer here</a>, but it doesn't work for me. I also tried other options (<code>rgb24</code>, <code>bgra</code>, etc.), but none I have tried works. I get a nice video, just with black background instead of transparent.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-14T12:14:47.397Z
Comments.Text: How do you intend to play the video?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-15T06:42:31.277Z
Comments.Text: This is just for a PowerPoint presentation (where it will partly overlap something else; that's why I want the transparent background).
Comments.UserDisplayName: Aephir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-18T14:46:47.137Z
Comments.Text: How about `apng` (Animated PNG). Size will be large but it is simply PNG with animation .
Comments.UserDisplayName: Abdullah Ibn Fulan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-23T11:59:02.663Z
Comments.Text: Thanks for the suggestion, @AbdullahIbnFulan, but if I try that, I see "ghosting". That is, each part of the previous image that is now where there is nothing (clear background) sticks around for the next. So I can see parts of each of the 240 images once it's done (done with online tool, https://ezgif.com/apng-maker).
Comments.UserDisplayName: Aephir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-23T12:13:36.850Z
Comments.Text: @AbdullahIbnFulan scratch that, apparently there was a checkbox to avoid that behavior. Still interested in alternatives for as you say, size is large. But for now it'll work, thanks!
Comments.UserDisplayName: Aephir
Tags: <ffmpeg>
Title: How do I make ffmpeg create video that retains transparent background from *.png images with transparent background?
UserDisplayName: Aephir
ThreadText: # How do I make ffmpeg create video that retains transparent background from *.png images with transparent background?
  
  (Asked by: username_0 on 2021-09-14)
  
  I am a researcher, trying to string together a bunch of png files of a protein to a short video. I have all the png images with transparent backgrounds, but I can't seem to get this in the video.
  
  I use this (on macOS terminal) to convert:
  
  ```
  ffmpeg -framerate 20 -pattern_type glob -i '*.png' -c:v libx264 -preset slow  -profile:v high -level:v 4.0 -pix_fmt yuv420p -vf pad="width=ceil(iw/2)*2:height=ceil(ih/2)*2" -crf 22 -codec:a aac -pix_fmt yuva420p SST4.mp4
  
  ```
  
  I added the `-pix_fmt yuva420p` that I found as an [accepted answer here](https://video.stackexchange.com/a/33011), but it doesn't work for me. I also tried other options (`rgb24`, `bgra`, etc.), but none I have tried works. I get a nice video, just with black background instead of transparent.
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: How do you intend to play the video?  
  > **username_0**: This is just for a PowerPoint presentation (where it will partly overlap something else; that's why I want the transparent background).  
  > **username_2**: How about `apng` (Animated PNG). Size will be large but it is simply PNG with animation .  
  > **username_0**: Thanks for the suggestion, @username_2, but if I try that, I see "ghosting". That is, each part of the previous image that is now where there is nothing (clear background) sticks around for the next. So I can see parts of each of the 240 images once it's done (done with online tool, https://ezgif.com/apng-maker).  
  > **username_0**: @username_2 scratch that, apparently there was a checkbox to avoid that behavior. Still interested in alternatives for as you say, size is large. But for now it'll work, thanks!  
  
  ---
  
  ## 0 answers
  
  