[libav-api] Turning an image set into an FLV with transparent background

Anton Khirnov anton at khirnov.net
Thu Oct 3 09:04:56 CEST 2013


On Wed, 2 Oct 2013 11:44:40 +0200, Adam <doadam at gmail.com> wrote:
> I have an image set (over 900 PNGs) that I want to merge into FLV
> (preserving the transparency). All these images contain a colored character
> and a transparent background behind it.
> I've been searching on Google and other places and the best result I got is
> a working movie, with a black background.
> 
> The command I've been trying:
> avconv -r 24 -i HippoBingo_B_Render_%04d.png -i music.wav -r 24 -ac 1
> -vcodec flv -strict experimental -s 256x384 -ab 128k z.flv
> 
> console output:
> 
> adam at ubuntu:~/render$ avconv -r 24 -i HippoBingo_B_Render_%04d.png -i
> music.wav -r 24 -ac 1 -vcodec flv -strict experimental -s 256x384 -ab 128k
> z.flv
> avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav
> developers
>   built on Mar 30 2013 22:20:06 with gcc 4.7.2
> Input #0, image2, from 'HippoBingo_B_Render_%04d.png':
>   Duration: 00:00:34.16, start: 0.000000, bitrate: N/A
>     Stream #0.0: Video: png, bgra, 400x600, 24 fps, 24 tbr, 24 tbn, 24 tbc
> [wav @ 0x1ba8840] max_analyze_duration reached
> Input #1, wav, from 'music.wav':
>   Duration: 00:00:32.66, bitrate: 1412 kb/s
>     Stream #1.0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
> File 'z.flv' already exists. Overwrite ? [y/N] y
> Incompatible pixel format 'bgra' for codec 'flv', auto-selecting format
> 'yuv420p'
> [buffer @ 0x21091a0] w:400 h:600 pixfmt:bgra
> [scale @ 0x211fda0] w:400 h:600 fmt:bgra -> w:256 h:384 fmt:yuv420p
> flags:0x4
> Output #0, flv, to 'z.flv':
>   Metadata:
>     encoder         : Lavf53.21.1
>     Stream #0.0: Video: flv, yuv420p, 256x384, q=2-31, 200 kb/s, 1k tbn, 24
> tbc
>     Stream #0.1: Audio: adpcm_swf, 44100 Hz, 1 channels, s16, 176 kb/s
> Stream mapping:
>   Stream #0:0 -> #0:0 (png -> flv)
>   Stream #1:0 -> #0:1 (pcm_s16le -> adpcm_swf)
> Press ctrl-c to stop encoding
> frame=  820 fps=198 q=2.0 Lsize=    1776kB time=32.69 bitrate= 445.1kbits/s
> 
> video:1046kB audio:706kB global headers:0kB muxing overhead 1.376779%
> adam at ubuntu:~/render$ avconv -r 24 -i HippoBingo_B_Render_%04d.png -i
> music.wav -r 24 -ac 1 -vcodec flv -strict experimental -s 256x384 -ab 128k
> z.flv
> avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav
> developers
>   built on Mar 30 2013 22:20:06 with gcc 4.7.2
> Input #0, image2, from 'HippoBingo_B_Render_%04d.png':
>   Duration: 00:00:34.16, start: 0.000000, bitrate: N/A
>     Stream #0.0: Video: png, bgra, 400x600, 24 fps, 24 tbr, 24 tbn, 24 tbc
> [wav @ 0x1ba8840] max_analyze_duration reached
> Input #1, wav, from 'music.wav':
>   Duration: 00:00:32.66, bitrate: 1412 kb/s
>     Stream #1.0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
> File 'z.flv' already exists. Overwrite ? [y/N] y
> Incompatible pixel format 'bgra' for codec 'flv', auto-selecting format
> 'yuv420p'
> [buffer @ 0x21091a0] w:400 h:600 pixfmt:bgra
> [scale @ 0x211fda0] w:400 h:600 fmt:bgra -> w:256 h:384 fmt:yuv420p
> flags:0x4
> Output #0, flv, to 'z.flv':
>   Metadata:
>     encoder         : Lavf53.21.1
>     Stream #0.0: Video: flv, yuv420p, 256x384, q=2-31, 200 kb/s, 1k tbn, 24
> tbc
>     Stream #0.1: Audio: adpcm_swf, 44100 Hz, 1 channels, s16, 176 kb/s
> Stream mapping:
>   Stream #0:0 -> #0:0 (png -> flv)
>   Stream #1:0 -> #0:1 (pcm_s16le -> adpcm_swf)
> Press ctrl-c to stop encoding
> frame=  820 fps=198 q=2.0 Lsize=    1776kB time=32.69 bitrate= 445.1kbits/s
> 
> video:1046kB audio:706kB global headers:0kB muxing overhead 1.376779%
> 
> 
> 
> 
> Why do I get a black background?
> 

Because the flv codec simply does not support transparency. You need to use some
different codec for that.

-- 
Anton Khirnov


More information about the libav-api mailing list