Convert PNGs to webm video with transparency
Solution 1
With VP8:
ffmpeg -framerate 25 -f image2 -i frames/%03d.png -c:v libvpx -pix_fmt yuva420p output.webm
Edit: Now, with VP9
ffmpeg -framerate 25 -f image2 -i frames/%03d.png -c:v libvpx-vp9 -pix_fmt yuva420p output.webm
Solution 2
Since 2016-07-13, it's possible to encode VP9/webm videos with alpha channel (VP9a).
You only need a copy of ffmpeg compiled after that date. By the way, all you need to write is:
ffmpeg -i frames/%03d.png output.webm
FFmpeg understands png format and will set a default framerate of 25 fps and a yuva420p
pixel format to the output.
sebastian
Updated on July 09, 2022Comments
-
sebastian almost 2 years
I would like to use
avconv
to convert a series of PNG images to a WebM video, preserving transparency.I understand that the pixel format used in the output video must support transparency. So I tried:
$ avconv -framerate 25 -f image2 -i frames/%03d.png -pix_fmt yuva420p output.webm
Unfortunately,
avconv
complains:Incompatible pixel format 'yuva420p' for codec 'libvpx-vp9', auto-selecting format 'yuv420p'
I am using
ffmpeg version 2.8.4-1+b1 Copyright (c) 2000-2015 the FFmpeg developers
. -
sebastian over 8 yearsThanks for the insight. Can't get it to work though, if I run your command, avconv complains that
Specified pix_fmt is not supported
. I am usingavconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014
-
Gyan over 8 yearsSwitch to a recent ffmpeg build and try.
-
sebastian over 8 yearsStill no luck. I am using
avconv version 11.3-6:11.3-1~trusty
now and still getSpecified pix_fmt is not supported
. -
sebastian over 8 yearsIn your answer (updated now) you wrote
avconv
instead offfmpeg
. So I usedavconv
, too. Working with ffmpeg, thanks! -
Jason Pratt about 7 yearsI needed to use '-metadata:s:v:0 alpha_mode="1"' as mentioned here to get alpha to work for VP8.
-
Gyan about 7 yearsWorks here, without. Which version of ffmpeg and libvpx?
-
Kagami Sascha Rosylight over 6 yearsFor anyone frustrated on Ubuntu LTS: VP9+alpha doesn't work on ffmpeg 2.8.x, you should get ffmpeg 3.x.
-
Alex over 6 yearsI added
-b:v 800k
for an increased video bit rate to get a better image quality. The default wasn't good enough. -
matteo almost 6 yearsWorks for me, but produces an output with garbage quality. How do you set a decent quality or configure the bitrate?
-
Gyan almost 6 yearsSet the bitrate e.g.
-b:v 2M
for 2 mbps. -
JavaRunner about 3 yearsDoesn't work for me. ffmpeg 4.3.2, video doesn't transparent.