I need to split a webm
encoded video into png
frames, without losing transparency. I use the following ffmpeg command:
ffmpeg -i dancer1.webm -pix_fmt rgba frames/%04d.png
This produces a directory of pngs, but why is each output frame is missing transparency?
I have used this example video, which contains an alpha channel. See it playing over a background here. Here's an example output frame from ffmpeg:
ffmpeg produces the following output when it runs:
ffmpeg version N-60294-g549f052 Copyright (c) 2000-2014 the FFmpeg developers [1/2471]
built on Feb 2 2014 05:41:56 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 63.100 / 52. 63.100
libavcodec 55. 49.101 / 55. 49.101
libavformat 55. 28.101 / 55. 28.101
libavdevice 55. 7.100 / 55. 7.100
libavfilter 4. 1.101 / 4. 1.101
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, matroska,webm, from 'dancer1.webm':
Metadata:
encoder : libwebm-0.2.1.0
Duration: 00:01:02.83, start: 0.000000, bitrate: 520 kb/s
Stream #0:0(eng): Video: vp8, yuv420p, 640x360, SAR 1:1 DAR 16:9, 30 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
Output #0, image2, to 'frames/%04d.png':
Metadata:
encoder : Lavf55.28.101
Stream #0:0(eng): Video: png, rgba, 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 30 tbc (default)
Metadata:
alpha_mode : 1
Stream mapping:
Stream #0:0 -> #0:0 (vp8 -> png)
Running identify
on an output png produces this:
$ identify 0001.png
0001.png PNG 640x360 640x360+0+0 8-bit DirectClass 94.1KB 0.000u 0:00.000
file
has this to say about the png:
$ file 0001.png
0001.png: PNG image data, 640 x 360, 8-bit/color RGBA, non-interlaced
Everything looks about right to me, so why don't the output images contain an alpha channel?
Since 2016-07-20, it's possible to decode properly a webm with alpha channel (VP8a or VP9a) but you need -vcodec libvpx
option. You must download an FFmpeg compiled after that date (or compile yourself with up-to-date commits) and, after creating the frames
folder, use the following command:
ffmpeg -vcodec libvpx -i dancer1.webm frames/%04d.png
Note that -vcodec libvpx
is before the input, not after it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With