4

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?

1 Answer 1

2

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
5
  • What's the complex filter equivalent to -pix_fmt? Would format=yuva420p be enough? Feb 3, 2022 at 23:03
  • Not sure, that might be a good candidate for a new question
    – stib
    Feb 4, 2022 at 2:18
  • Is it possible to use this for a .mov video file?
    – aaragon
    Nov 2, 2022 at 18:11
  • -pix_fmt yuva420p not work in hevc and nvenc.
    – rint
    Sep 15 at 10:37
  • alpha isn't supported by hevc and nvenc
    – stib
    Oct 2 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.