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

CC BY-SA 4.0
2021-09-14T12:14:47.397Z
How do you intend to play the video?
Gyan
CC BY-SA 4.0
2021-09-15T06:42:31.277Z
This is just for a PowerPoint presentation (where it will partly overlap something else; that's why I want the transparent background).
Aephir
CC BY-SA 4.0
2021-09-18T14:46:47.137Z
How about `apng` (Animated PNG). Size will be large but it is simply PNG with animation .
Abdullah Ibn Fulan
CC BY-SA 4.0
2021-09-23T11:59:02.663Z
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).
Aephir
CC BY-SA 4.0
2021-09-23T12:13:36.850Z
@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!
Aephir
<ffmpeg>
How do I make ffmpeg create video that retains transparent background from *.png images with transparent background?
Aephir
# 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, 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, @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).  
> **username_0**: @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!  

---

## 0 answers

