Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert PNGs to webm video with transparency

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.

like image 378
sebastian Avatar asked Jan 24 '16 09:01

sebastian


2 Answers

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
like image 130
Gyan Avatar answered Oct 07 '22 08:10

Gyan


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.

like image 40
cdlvcdlv Avatar answered Oct 07 '22 08:10

cdlvcdlv