8
ffmpeg -i v.3gp -acodec copy -vf "movie=w.png [logo]; [in][logo] overlay=10:main_h-overlay_h-10 [out]" nv.3gp

It work's fine, but i want watermark only first 30 seconds. Any ideas?

ncs
  • 454
  • 1
  • 3
  • 12

4 Answers4

8

You can convert the logo into a 30 second video with png codec and alpha channel, and apply the video as overlay.

The duration of the logo video should be specified through the number of frames at the frame rate of the main video (in your case, v.3pg). For example, for 30 fps main video run:

ffmpeg.exe -loop 1 -i w.png -vframes 901 -vf "fade=out:899:1:alpha=1" 
    -vcodec png -pix_fmt rgba w.mov

The logo needs to be faded out; otherwise it will not disappear. Then use the logo video as overlay on another video:

ffmpeg -i v.3gp -acodec copy -vf "movie=w.mov [logo]; [in][logo]
    overlay=10:main_h-overlay_h-10 [out]" nv.3gp

Alternatively, rather then ending abruptly, the logo can be faded out gradually, e.g. within 30 frames using -vf "fade=out:870:30:alpha=1".

Dmitry Shkuropatsky
  • 3,902
  • 2
  • 21
  • 13
  • Invalid value '1' for option 'loop' – ncs Feb 09 '12 at 11:55
  • And it doesn't disappear ffmpeg -i w.png -vframes 901 -vf "fade=out:870:30:alpha=1" -vcodec png -pix_fmt rgba logo.mov ffmpeg -i v.3gp -acodec copy -vf "movie=logo.mov [logo]; [in][logo] overlay=10:main_h-overlay_h-10 [out]" nv.3gp – ncs Feb 09 '12 at 12:08
  • Strange. Are you using an older ffmpeg? Try `-loop-input` then, or get the latest – Dmitry Shkuropatsky Feb 09 '12 at 12:54
  • ffmpeg -loop_input -f image2 -i w.png -vframes 901 -vf "fade=out:870:30:alpha=1" -vcodec png logo.mov // ffmpeg -i v.3gp -acodec copy -vf "movie=logo.mov [logo]; [in][logo] overlay=10:main_h-overlay_h-10 [out]" nv.3gp // it's work, but thereis no alpha, i saw black square after fadeout. If i make logo.mov without -vf everything is ok, but watermark appears whole duration. – ncs Feb 12 '12 at 09:50
  • You did not pass `-pix_fmt rgba` option. Also, try the latest ffmpeg. – Dmitry Shkuropatsky Feb 12 '12 at 13:49
  • ffmpeg version 0.7.11, it's latest in freebsd ports, -pix_fmt rgba does not take any affect :( – ncs Feb 12 '12 at 20:15
  • @Dmitry-Shkuropatsky could you please help me with [this](http://stackoverflow.com/q/10948714/765854)??? Basically when I try to merge a transparent video I get a black overlay instead of background effect. – Rakesh Sankar Jun 12 '12 at 07:55
7

overlay filter supports timeline editing; you can simply read from a png file and then overlay=enable='lte(t,30)':...

sendmoreinfo
  • 582
  • 6
  • 22
5

Realize it's late, but as I was looking at a similar problem I managed to solve this one. It fades in with 0.5 sec from start, then fades out at 30 sec

ffmpeg \
-i v.3gp \
-loop 1 -i w.png \
-acodec copy \
-filter_complex \
"[1:v] fade=in:st=0:d=0.5,fade=out:st=30:d=0.5 [logo]; [0:v][logo] overlay=10:main_h-overlay_h-10" \
nv.3gp
ismail
  • 46,010
  • 9
  • 86
  • 95
cueloop
  • 141
  • 1
  • 5
  • how do you avoid endless encoding loop ( caused by -loop 1 )? When on the other side I use eof_action=pass[out1] in the complex filter and map it to the output, the output has no working audio. Any ideas? – XtraBytesLab Dec 22 '15 at 00:34
  • @fiveDust Try the `-shortest` argument (see [advanced options documentation](https://ffmpeg.org/ffmpeg.html#Advanced-options)). – Tag Aug 23 '16 at 23:26
0

You may cut the first 30 seconds, apply watermark to it, then join it with the remaining part.

Felix Yan
  • 14,841
  • 7
  • 48
  • 61