Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ffmpeg multiple watermark images

2,744 views
Skip to first unread message

bad sector

unread,
Jun 23, 2016, 10:10:12 PM6/23/16
to

I'm using ffmpeg to add a short title image
to the source video in such a way as to minimize
resolution/quatilty loss on the way.

ffmpeg -i in.mkv -i wm-bp.png -c:v libx264 -preset veryslow -crf 20
-filter_complex
"overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,95,105)'"
-codec:a copy out.mkv

but I'd like to use several images, each with
it's own 'between' argument.

How is this possible?

let's say i wanted to add a first image wm-et.png
with a requirement such as between(t,10,45)

.. and maybe others


Thanks in adv.



bad sector

unread,
Jun 28, 2016, 9:28:02 PM6/28/16
to
I found THIS:

--------------------------------------------
https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2194

ffmpeg
-i wmcap.mp4
-i w1.png
-i w2.png
-i w3.png
-i w4.png
-i w5.png
-i w6.png
-filter_complex
"
[0:v][1:v] overlay=10:10:enable='between(t,1,2)' [tmp];
[tmp][2:v] overlay=20:20:enable='between(t,2,3)' [tmp];
[tmp][3:v] overlay=30:30:enable='between(t,2,3)' [tmp];
[tmp][4:v] overlay=40:40:enable='between(t,2,3)' [tmp];
[tmp][5:v] overlay=50:50:enable='between(t,2,3)' [tmp];
[tmp][6:v] overlay=60:60:enable='between(t,3,4)'
"
-y output.mp4
---------------------------------------------
On the surface the above should be able to
gang images in one spot at different times,
all at once in different places, or a mix thereof.


Adapted for my stuff it looks like:


ffmpeg
-i 0-3c.mkv
-i img-bridges.png
-i img-ride.png
-i img-etele.png
-y -c:v libx264rgb -preset veryslow -crf 5
-filter_complex
"
[0:v][1:v]overlay=(main_w-overlay_w)/2:
(main_h-overlay_h)/2:enable='between(t,12,16)' [tmp];
[tmp][2:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,24,25)'
[tmp];
[tmp][3:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,130,134)'
[tmp];
"
output.mkv




..or, all in one gulp

ffmpeg -i 0-3c.mkv -i img-bridges.png -i img-ride.png -i img-etele.png
-y -c:v libx264rgb -preset veryslow -crf 5 -filter_complex
"[0:v][1:v]overlay=(main_w-overlay_w)/2:
(main_h-overlay_h)/2:enable='between(t,12,16)'
[tmp];[tmp][2:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,24,25)'
[tmp];[tmp][3:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,130,134)'
[tmp];" output.mkv


The problem is I get an error:

[AVFilterGraph @ 0x1b5fac0] No such filter: '' Error initializing
complex filters. Invalid argument


I installed a dozen or so libav* packages that were not on board, same
difference.

Simlar problems encountered by others suggest syntax but I can't figure
it out.




Here's the whole run:

ffmpeg -i 0-3c.mkv -i img-bridges.png -i img-ride.png -i img-etele.png
-y -c:v libx264rgb -preset veryslow -crf 5 -filter_complex
"[0:v][1:v]overlay=(main_w-overlay_w)/2:
(main_h-overlay_h)/2:enable='between(t,12,16)'
[tmp];[tmp][2:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,24,25)'
[tmp];[tmp][3:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(t,130,134)'
[tmp];" output.mkv


ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (SUSE Linux)
configuration: --prefix=/usr --libdir=/usr/lib64
--shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg
--extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -g' --optflags='-fmessage-length=0
-grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector
-funwind-tables -fasynchronous-unwind-tables -g' --disable-htmlpages
--enable-pic --disable-stripping --enable-shared --disable-static
--enable-runtime-cpudetect --enable-gpl --disable-openssl
--enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libcelt --enable-libcdio
--enable-libdc1394 --enable-libfreetype --enable-libgsm
--enable-libopenjpeg --enable-libopus --enable-libpulse
--enable-libschroedinger --enable-libspeex --enable-libtheora
--enable-libvorbis --enable-libvpx --enable-libwebp --enable-pic
--enable-pthreads --enable-vaapi --enable-vdpau --enable-libmp3lame
--enable-libtwolame --enable-libx264 --enable-libx265 --enable-libxvid
--enable-x11grab
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '0-3c.mkv':
Metadata:
ENCODER : Lavf57.25.100
Duration: 00:04:13.03, start: 0.000000, bitrate: 155205 kb/s
Stream #0:0: Video: h264 (High 4:4:4 Predictive), gbrp(tv,
gbr/unknown/unknown), 1509x1080, SAR 1:1 DAR 503:360, 30 fps, 30 tbr, 1k
tbn, 60 tbc (default)
Metadata:
ENCODER : Lavc57.24.102 libx264rgb
DURATION : 00:04:13.033000000
Input #1, png_pipe, from 'img-bridges.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 1350x743 [SAR 3780:3780 DAR
1350:743], 25 tbr, 25 tbn, 25 tbc
Input #2, png_pipe, from 'img-ride.png':
Duration: N/A, bitrate: N/A
Stream #2:0: Video: png, rgba(pc), 949x467 [SAR 3780:3780 DAR
949:467], 25 tbr, 25 tbn, 25 tbc
Input #3, png_pipe, from 'img-etele.png':
Duration: N/A, bitrate: N/A
Stream #3:0: Video: png, rgba(pc), 713x237 [SAR 3780:3780 DAR
713:237], 25 tbr, 25 tbn, 25 tbc
[AVFilterGraph @ 0x2a646e0] No such filter: ''
Error initializing complex filters.
Invalid argument

bad sector

unread,
Jul 3, 2016, 9:40:12 AM7/3/16
to

In the case of 2 images as an example, sofar the only way seems to be to
overlay the first image, then overlay the second image on the result.
Using libx264rgb arguments ultrafast and qp0 works, I don't know why
slower options cause display corruption. I haven't gone past 6
iterations and don't even know if this involves just streaming or
recoding each time. It seems too fast to be recoding but...


ffmpeg -i 0-capture.mkv -i img1.png -c:v libx264rgb -preset ultrafast
-qp 0 -filter_complex "overlay=0:0:enable='between(t,23,29)'" a2329vs.mkv

ffmpeg -i a2329vs.mkv -i img2.png -c:v libx264rgb -preset ultrafast -qp
0 -filter_complex "overlay=0:0:enable='between(t,28,33)'" b2833vs.mkv


I think this could be a good candidate for a list.txt reference where
one could specifty a hundred images with the insertion details for each.


Jasen Betts

unread,
Jul 5, 2016, 6:31:35 AM7/5/16
to
Ffmpeg seems to be internally pipelined, so it shold be possible to
overlay several watermarks, but it also seems you need to be a genius
to write the command-line.

Can you make a single png with all the watermarks and overlay that once?

--
This email has not been checked by half-arsed antivirus software

AnnS

unread,
Mar 1, 2017, 9:12:31 AM3/1/17
to
I succeed to add two differents PNG images to a video.
Here is the command line :

ffmpeg -i video.mpg -i logo1.png -i logo2.png -c:v mpeg2video -b:v 15000k -minrate 15000k -maxrate 15000k -bufsize 15000k -filter_complex "[0:v][1:v]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:enable='between(t,16,20)'[tmp];[tmp][2:v]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:enable='between(t,22,24)'" out.mpg

Hoping it will help you!

hlavace...@volny.cz

unread,
Dec 2, 2017, 8:44:15 AM12/2/17
to
Here is an example adding more watermarks to video with ffmpeg. Just add the between stuff in it and It should work. https://radek350.wordpress.com/2017/12/01/ffmpeg-watermarks/
0 new messages