[FFmpeg-user] creating a transparent Video from PNG or Gif files

Lorenz Martens lorenz.martens at sogidia.com
Thu Jan 5 13:20:02 CET 2012


ok so lets get a little bit more detailed.

1. I have created an image with :

	convert -size 640x480 -background transparent -fill blue label:Lorenz label1-0.gif

	that is creating an gif file with transparent background what is fine!
2. ffmpeg -loop 1 -s 4cif -f image2 -i label1-0.gif -r 25 -vframes 250 -vcodec rawvideo -an test.mov

	(I found some information that mov with rawvideo inside will support transparency )

	Output: 

	ffmpeg version N-36427-g15b219f, Copyright (c) 2000-2012 the FFmpeg developers
	  built on Jan  4 2012 09:11:15 with gcc 4.4.3	
	  configuration: --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib --shlibdir=/usr/lib --enable-pthreads --enable-shared --enable-avfilter --disable-static --enable-libmp3lame --enable-libxvid --enable-libx264 --enable-postproc 	--enable-shared --enable-libdc1394 --enable-libtheora --enable-libschroedinger --enable-gpl --enable-decoder=aac --enable-encoder=aac --extra-ldflags=-lpng
	  libavutil      51. 34.100 / 51. 34.100
	  libavcodec     53. 50.100 / 53. 50.100
	  libavformat    53. 29.100 / 53. 29.100
	  libavdevice    53.  4.100 / 53.  4.100
	  libavfilter     2. 57.101 /  2. 57.101
	  libswscale      2.  1.100 /  2.  1.100
	  libswresample   0.  5.100 /  0.  5.100
	  libpostproc    51.  2.100 / 51.  2.100
	[image2 @ 0x85f3c60] max_analyze_duration 5000000 reached at 5000000
	Input #0, image2, from 'label1-0.gif':
	  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
	    Stream #0:0: Video: gif, pal8, 640x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
	[buffer @ 0x85f4300] w:640 h:480 pixfmt:pal8 tb:1/1000000 sar:0/1 sws_param:
	Output #0, mov, to 'test.mov':
	  Metadata:
	    encoder         : Lavf53.29.100
	    Stream #0:0: Video: rawvideo (raw  / 0x20776172), pal8, 640x480, q=2-31, 200 kb/s, 25 tbn, 25 tbc
	Stream mapping:
	  Stream #0:0 -> #0:0 (gif -> rawvideo)
	Press [q] to stop, [?] for help
	frame=  250 fps=187 q=0.0 Lsize=   75251kB time=00:00:10.00 bitrate=61645.4kbits/s    
	video:75250kB audio:0kB global headers:0kB muxing overhead 0.000929%

	after that I try to overlay the mov file to main video with :

4. ffmpeg -i origin.stream_0.flv -sameq -ar 44100 -vf "movie=test.mov [logo];[in][logo] overlay=10:10 [out]" output.flv

	Output :

	ffmpeg version N-36427-g15b219f, Copyright (c) 2000-2012 the FFmpeg developers
	  built on Jan  4 2012 09:11:15 with gcc 4.4.3
	  configuration: --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib --shlibdir=/usr/lib --enable-pthreads --enable-shared --enable-avfilter --disable-static --enable-libmp3lame --enable-libxvid --enable-libx264 --enable-postproc 	--enable-shared --enable-libdc1394 --enable-libtheora --enable-libschroedinger --enable-gpl --enable-decoder=aac --enable-encoder=aac --extra-ldflags=-lpng
	  libavutil      51. 34.100 / 51. 34.100
	  libavcodec     53. 50.100 / 53. 50.100
	  libavformat    53. 29.100 / 53. 29.100
	  libavdevice    53.  4.100 / 53.  4.100
	  libavfilter     2. 57.101 /  2. 57.101
	  libswscale      2.  1.100 /  2.  1.100
	  libswresample   0.  5.100 /  0.  5.100
	  libpostproc    51.  2.100 / 51.  2.100
	Input #0, flv, from 'origin.stream_0.flv':
	  Metadata:
	    creationdate    : Fr Dez 9 10:34:32
	  Duration: 00:15:10.96, start: 0.005000, bitrate: 948 kb/s
	    Stream #0:0: Video: h264 (High), yuv420p, 720x576, 25 tbr, 1k tbn, 50 tbc
	    Stream #0:1: Audio: aac, 48000 Hz, stereo, s16
	File 'output.flv' already exists. Overwrite ? [y/N] y
	w:720 h:576 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
	[movie @ 0x8623400] seek_point:0 format_name:(null) file_name:test.mov stream_index:0
	[overlay @ 0x8741860] auto-inserting filter 'auto-inserted scale 0' between the filter 'Parsed_movie_0' and the filter 'Parsed_overlay_1'
	[scale @ 0x8619980] w:640 h:480 fmt:pal8 -> w:640 h:480 fmt:yuva420p flags:0x4
	[overlay @ 0x8741860] main w:720 h:576 fmt:yuv420p overlay x:10 y:10 w:640 h:480 fmt:yuva420p
	[overlay @ 0x8741860] main_tb:1/1000000 overlay_tb:1/25 -> tb:1/1000000 exact:1
	Output #0, flv, to 'output.flv':
	  Metadata:
	    creationdate    : Fr Dez 9 10:34:32
	    encoder         : Lavf53.29.100
	    Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 720x576, q=2-31, 200 kb/s, 1k tbn, 25 tbc
	    Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16, 128 kb/s
	Stream mapping:
	  Stream #0:0 -> #0:0 (h264 -> flv)
	  Stream #0:1 -> #0:1 (aac -> libmp3lame)
	Press [q] to stop, [?] for help
	frame=22774 fps= 84 q=0.0 Lsize=  141985kB time=00:15:11.02 bitrate=1276.7kbits/s    
	video:116070kB audio:25013kB global headers:0kB muxing overhead 0.638709%


All that seems to be fine, but in the output file I see a back overlay and not a transparent one as I had expected :(

greetz

lorenz



Am 05.01.2012 um 12:27 schrieb Carl Eugen Hoyos:

> Lorenz Martens <lorenz.martens <at> sogidia.com> writes:
> 
>> So is it possible to create an transparent Video with ffmpeg?
> 
> Yes.
> 
> Seriously: You have to provide information about what you tried (command line)
> and how it failed (complete, uncut console output) if you need help. Without it,
> it is very, very difficult to answer your question (for example "image" is not a
> very exact description and "PNG or Gif" does not make it much easier).
> 
> Please do not break threads, it is considered rude here, Carl Eugen
> 
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user



More information about the ffmpeg-user mailing list