Convert PNGs to webm video with transparency
Asked Answered
M

3

16

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.

Moniz answered 24/1, 2016 at 9:45 Comment(1)
avconv != ffmpegArmbrecht
A
24

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
Armbrecht answered 24/1, 2016 at 11:4 Comment(9)
Thanks 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 using avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014Moniz
Switch to a recent ffmpeg build and try.Armbrecht
Still no luck. I am using avconv version 11.3-6:11.3-1~trusty now and still get Specified pix_fmt is not supported.Moniz
In your answer (updated now) you wrote avconv instead of ffmpeg. So I used avconv, too. Working with ffmpeg, thanks!Moniz
I needed to use '-metadata:s:v:0 alpha_mode="1"' as mentioned here to get alpha to work for VP8.Grooms
Works here, without. Which version of ffmpeg and libvpx?Armbrecht
For anyone frustrated on Ubuntu LTS: VP9+alpha doesn't work on ffmpeg 2.8.x, you should get ffmpeg 3.x.Notability
Works for me, but produces an output with garbage quality. How do you set a decent quality or configure the bitrate?Hackamore
Set the bitrate e.g. -b:v 2M for 2 mbps.Armbrecht
A
15

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.

Apron answered 23/8, 2016 at 23:32 Comment(2)
I added -b:v 800k for an increased video bit rate to get a better image quality. The default wasn't good enough.Natural
Doesn't work for me. ffmpeg 4.3.2, video doesn't transparent.Shae
B
1

You can also convert a video wich allready contains an alpha channel to a webm video with transparency with this command:

ffmpeg -i myVideoWithAlphaChannel.mov -c:v libvpx -vf format=rgba myVideoWithAlphaChannel.mov.webm

The format of myVideoWithAlphaChannel.mov (generated with Blender3D) is:

  • "Quicktime" format
  • "PNG" Codec

With as Ouputs:

  • H.264
  • RGBA

Here Blender 3D rendering configuration

Babita answered 2/7, 2018 at 21:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.