Skip to main content

FFmpeg watermark


ffmpeg –i test.mkv -vf "movie=watermark.png [watermark]; [in][watermark] overlay=10:10 [out]" outputvideo.mkv

I'm trying to simply add a watermark to a video to start testing with ffmpeg. But it simply does not work although I can't see any error.


I also tried


ffmpeg -i test.mkv -i watermark.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.mkv

But no success there either.


Output:


ffmpeg version 1.1.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 20 2013 23:05:28 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 13.100 / 52. 13.100
libavcodec 54. 86.100 / 54. 86.100
libavformat 54. 59.106 / 54. 59.106
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 32.100 / 3. 32.100
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, matroska,webm, from 'test.mkv':
Metadata:
creation_time : 2012-11-01 02:35:10
Duration: 00:00:59.74, start: 0.000000, bitrate: 5821 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x720, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
Input #1, image2, from 'watermark.png':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #1:0: Video: png, rgba, 1600x200, 25 tbr, 25 tbn, 25 tbc
[Parsed_overlay_0 @ 00328000] Overlay area (10,510)<->(1610,710) not within the main area (0,0)<->(1280,720) or zero-sized
[auto-inserted scaler 0 @ 03da0f60] Failed to configure input pad on Parsed_overlay_0

Answer



It seems that your watermark is larger than the main video. Since you're using filters already, the cleanest way to fix that is with the scale filter. scale=25:20 will scale it to a 25x20 pixel square. If you were to use scale=25:-1 it would scale the video (watermark in this case) to a width of 25, and scale the height down such that the aspect ratio stays the same (you can also use scale=-1:20).


Here is an example use:


ffmpeg -i test.mkv -i watermark.png -filter_complex \
"[1:v]scale=25:20[wat];[0:v][wat]overlay=10:main_h-overlay_h-10[outv]" \
-map "[outv]" -map 0:a output.mkv

With a complex filtergraph, I personally always label my inputs and outputs in order to increase readability. If you don't have any audio, or don't want to take any audio from test.mkv, then cut out the -map 0:a.


Within the filtergraph, [1:v] refers to 'the video of input 1' (watermark.png in this case, since ffmpeg starts counting from 0). You could equally use [1:0] for 'the zeroth stream of input 1', or just [1], since in this case there is only one stream in the input. See the stream specifiers documentation for a bit more information.


The [wat] at the end of the scale filter simply allows for the rest of the filtergraph to refer to the output of the scale filter -- akin to setting a variable in a script. The [outv] at the very end of the filtergraph serves a similar function, but here I'm using it outside of the filtergraph too (all labels set within a filtergraph are similarly accessible outside of the filtergraph, with the -map option).


To achieve decent-quality video, you'll need to set several other options; check out this general encoding primer, or one of the more in-depth guides at the FFmpeg wiki.


Comments

Popular Posts

Use Google instead of Bing with Windows 10 search

I want to use Google Chrome and Google search instead of Bing when I search in Windows 10. Google Chrome is launched when I click on web, but it's Bing search. (My default search engine on Google and Edge is http://www.google.com ) I haven't found how to configure that. Someone can help me ? Answer There is no way to change the default in Cortana itself but you can redirect it in Chrome. You said that it opens the results in the Chrome browser but it used Bing search right? There's a Chrome extension now that will redirect Bing to Google, DuckDuckGo, or Yahoo , whichever you prefer. More information on that in the second link.

linux - Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I understand an index probably won't help for complicated regexps, but I use mostly very simple patters. Does an indexer exist for this case? EDIT: I know about ctags and the like, but I would like to do full-text search. Answer what about cscope , does this match your shoes? Allows searching code for: all references to a symbol global definitions functions called by a function functions calling a function text string regular expression pattern a file files including a file

How do I transmit a single hexadecimal value serial data in PuTTY using an Alt code?

I am trying to sent a specific hexadecimal value across a serial COM port using PuTTY. Specifically, I want to send the hex codes 9C, B6, FC, and 8B. I have looked up the Alt codes for these and they are 156, 182, 252, and 139 respectively. However, whenever I input the Alt codes, a preceding hex value of C2 is sent before 9C, B6, and 8B so the values that are sent are C2 9C, C2 B6, and C2 8B. The value for FC is changed to C3 FC. Why are these values being placed before the hex value and why is FC being changed altogether? To me, it seems like there is a problem internally converting the Alt code to hex. Is there a way to directly input hex values without using Alt codes in PuTTY? Answer What you're seeing is just ordinary text character set conversion. As far as PuTTY is concerned, you are typing (and reading) text , not raw binary data, therefore it has to convert the text to bytes in whatever configured character set before sending it over the wire. In other words, when y

networking - Windows 10, can ping other PC but cannot access shared folders! What gives?

I have a computer running Windows 7 that shares a Git repo on drive D. Let's call this PC " win7 ". This repo is the origin of a project that we push to and pull from. The network is a wireless network. One PC on this network is running on Windows 10. Let's call this PC " win10 ". Win10 can ping every other PC on the network including win7 . Win7 can ping win10 . Win7 can access all shared files on win10 . Neither of the PCs have passwords. Problem : Win10 cannot access any shared files on win7 , not from Explorer, nor from Git Bash or any other Git management system (E-Git on Eclipse or Visual Studio). So, win10 cannot pull/push. Every other PC on the network can access win7 shared files and push/pull to/from the shared Git origin. What's wrong with Windows 10? I have tried these: Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings\ File sharing is on, Discovery is on, Password protected sharing is off Adapte