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

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.