Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques How to convert an image sequence to a PNG encoded MOV with alpha channel

  • How to convert an image sequence to a PNG encoded MOV with alpha channel

    Posted by Uli Kilian on February 24, 2012 at 3:52 pm

    Hi Guys,

    I’ve searched the whole web and RTFM but couldn’t find an answer to the simple question:
    How can I convert an image sequence with an alpha channel (eg TGA) to a MOV file using the PNG codec while preserving alpha channel.

    I know this is possible because I can export such a MOV out of other software. But I need ffmpeg to do it.

    Again:
    —————–
    What I have:
    32bit TGA files including alpha channel

    What I want:
    A lossless but as small as possible Quicktime file which includes the alpha channel
    —————–

    What I was able to achieve:
    A MOV file holding raw uncompressed data including alpha channel. But that is sometimes 10 times bigger than the (lossless) compressed PNG codec in Quicktime. So I really need it to be smaller. I would be also happy with some other lossless (but compressed) alternative.
    What I used to achieve the uncompressed huge MOV file:

    ffmpeg.exe -r 30 -i C:\temp\test_%04d.tga -y -r 30 -vcodec rawvideo -pix_fmt rgba test.mov

    ffmpeg version N-37208-g01fcbdf Copyright (c) 2000-2012 the FFmpeg developers
    built on Jan 27 2012 18:34:52 with gcc 4.6.2
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enab
    le-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
    able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --en
    able-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
    libxvid --enable-zlib
    libavutil 51. 34.101 / 51. 34.101
    libavcodec 53. 60.100 / 53. 60.100
    libavformat 53. 31.100 / 53. 31.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 60.100 / 2. 60.100
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 6.100 / 0. 6.100
    libpostproc 52. 0.100 / 52. 0.100
    Input #0, image2, from 'C:\temp\test\nounderscore%04d.tga':
    Duration: 00:00:01.03, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: targa, bgra, 1920x1080, 30 tbr, 30 tbn, 30 tbc
    [buffer @ 01E39C80] w:1920 h:1080 pixfmt:bgra tb:1/1000000 sar:0/1 sws_param:
    [buffersink @ 03C302C0] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
    [scale @ 03C311E0] w:1920 h:1080 fmt:bgra -> w:1920 h:1080 fmt:rgba flags:0x4
    Output #0, mov, to 'nounderscore.mov':
    Metadata:
    encoder : Lavf53.31.100
    Stream #0:0: Video: rawvideo (RGBA / 0x41424752), rgba, 1920x1080, q=2-31, 200 kb/s, 30 tbn, 30 tbc
    Stream mapping:
    Stream #0:0 -> #0:0 (targa -> rawvideo)
    Press [q] to stop, [?] for help
    frame= 31 fps= 19 q=0.0 Lsize= 251101kB time=00:00:01.03 bitrate=1990663.1kbits/s
    video:251100kB audio:0kB global headers:0kB muxing overhead 0.000325%

    But when I change “-vcode rawvideo” to “-vcode png” it drops the alpha channel alltogether.
    I played around with
    -pix_fmt rgba
    -pix_fmt argb
    -pix_fmt bgra
    -pix_fmt abgr

    but nothing worked…

    On the web there are different solutions but nothing worked for me. It seems my ffmpeg version (which is a fairly new build) doesn’t support it because other people claimed they did it by using exactly the same command.

    Are there any other suggested builds?
    Or am I missing something here?

    Any help is very much appreciated indeed.

    Thanks
    Uli

    Samuel Were replied 13 years, 8 months ago 4 Members · 4 Replies
  • 4 Replies
  • Reuben Martin

    February 25, 2012 at 2:59 am

    It should work. You might try specifying the input pix_fmt option in front of the -i option to ensure that 32bit mode is enforced.

    You can also try the “qtrle” codec which is basically quicktime animation codec. It supports alpha.

  • Uli Kilian

    February 27, 2012 at 7:15 pm

    Reuben – Thanks a lot!
    The qtrle option works. Finally I can encode with alpha channel.
    Thanks for sharing!

    However – as the PNG compression is a bit more efficient it would be nice to get that encoded with ffmpeg.
    If anyone has any idea – please share.
    I tried to put the “-pix_fmt argb” option in front of the -i option – but didn’t make any difference. Nor did all the others (abgr, rgba, etc).

    Anyway.
    Thanks again, Reuben!

    Uli

  • Tatiana Solano

    April 23, 2012 at 5:35 pm

    Hello

    I have been working with ffmpeg an a gif animation, so I was trying to do a video from it with alpha channel, and finally with your coments I figure it out, I use a sequence of png images that get from the gif animation and use the next code:

    ffmpeg -i homer%05d.png -vcodec png -pix_fmt rgb32 -y z.mov

    And it works… Hope it helps you

  • Samuel Were

    November 1, 2012 at 3:26 pm

    It doesn’t work for me 🙁
    I have mov png with alpha on input and I would like scaled down with alpa on output.
    Everything works OK except output mov has no alpha.
    Please help!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy