0

My Platform: Ubuntu 10.10 + FFMPEG 0.5.3(I installed ffmpeg from source)

I try to add Watermark to a .MOV video with FFMPEG 0.5.3 imlib2.so (Please note FFMPEG 0.6+ dont support imlib2.so, so I use ffmpeg 0.5.3)

Here is my code:

ffmpeg -sameq -i example.mov -vhook '/usr/local/lib/vhook/imlib2.so -x 0 -y 0 -i /var/www/files/watermark.png' newexample.mov

Here is the output:

FFmpeg version 0.5.3, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-avfilter --enable-filter=movie --enable-avfilter-lavf
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  built on Jul  3 2011 12:05:08, gcc: 4.4.5

Seems stream 1 codec frame rate differs from container frame rate: 59.94 (5994/100) -> 29.97 (30000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mov':
  Duration: 00:03:14.06, start: 0.000000, bitrate: 3350 kb/s
    Stream #0.0(eng): Audio: aac, 48000 Hz, stereo, s16
    Stream #0.1(eng): Video: h264, yuv420p, 1150x647, 29.97 tbr, 29.97 tbn, 59.94 tbc
Output #0, mov, to 'newexample.mov':
    Stream #0.0(eng): Video: mpeg4, yuv420p, 1150x647, q=2-31, 200 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1(eng): Audio: 0x0000, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Unsupported codec for output stream #0.1

What could be the possible problem? Is that AAC or H264 that is not supported?

I installed libavcodec-extra-52, linfaac, libfaad and etc. but the error is the same.

Do I have to install following this instruction? HOWTO: Install and use the latest FFmpeg and x264 or there is a simpler solution?

3
  • If you fixed your own question, put the solution in an answer of its own.
    – Wuffers
    Jul 9, 2011 at 22:09
  • @Mark Szymanski Where did he give any impression that he "fixed"/solved his own question?
    – barlop
    Jul 10, 2011 at 11:32
  • @barlop: if you look at the revisions, you will see that he posted and update to his question which include an answer.
    – Wuffers
    Jul 10, 2011 at 13:09

1 Answer 1

4

The correct way to do this with recent ffmpeg is to use the overlay filter. The following command will place watermark.png on top of input.mp4, with the upper-left corner of the watermark fifteen pixels to the right and ten pixels down from the upper-left corner of the main video:

ffmpeg -i input.mp4 -i watermark.png -filter_complex \
'[0:v][1:v]overlay=15:10[outv]' -map [outv] -map [0:a] \
-c:a copy -c:v libx264 -crf 22 -preset veryfast output.mp4

Obviously, change 15 or 10 to whatever values you want.

There are also a few constants you may find useful, if you're putting watermarks on multiple videos with separate resolutions:

  • W and H are the width and height of the main video (input.mp4)
  • w and h are the width and height of the overlay video (watermark.png)

These can come in handy many times. For example, to place the watermark over the centre of the video, you could use:

'[0:v][1:v]overlay=(W-w)/2:(H-h)/2[outv]'

Similarly, to centre the watermark over the upper-left sixth of the video:

'[0:v][1:v]overlay=(W-w)/6:(H-h)/6[outv]'

For the lower-left sixth of the video:

'[0:v][1:v]overlay=(W-w)/6:(H-h)/(6/5)[outv]'

You can pretty much do whatever you need to.

See the overlay filter documentation for more information.

1
  • FYI: the "-map [0:a]" fragment results in "Output with label '0:a' does not exist in any defined filter graph, or was already used elsewhere." error using migw64 terminal with ffmpeg.exe on Win10. Instead "-map 0:a" did the trick.
    – honzakotrs
    May 24, 2021 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .