2

I have a watermark.png that was made to overlay videos with 1280 width. When i use a different size video, the watermark is totally out of proportion.

So i'm looking for a single command that can scale the watermark to fit the original video size. I do not want to resize the original video.

This is the current working format i use which works fine with 1280 width videos. (watermark placed left-bottom)

-i video.mp4 -vf "movie=watermark.png [watermark]; [in][watermark] overlay=1:main_h-overlay_h-1:enable=not(between'(t,30,210)') [out]"

On a side note, since the watermark is simply a 15 letter word i could also use text in the command if this would make the solution less complicated.

2
  • What's the resolution of your watermark? And are all videos 16:9?
    – Gyan
    Commented Aug 26, 2016 at 12:18
  • Hi, thanks for the help! The watermark = 400x48. 90% of the videos are 16:9 so that could be used as standard.
    – razz
    Commented Aug 26, 2016 at 12:33

1 Answer 1

2

You can use the scale2ref filter, which can resize one input to match a reference input.

Template is

-i video.mp4 -filter_complex "movie=watermark.png[watermark];[watermark][0]scale2ref=400*iw/1280:48*iw/1280[wm][v];[wm]setsar=1[logo];[v][logo] overlay=1:main_h-overlay_h-1:enable=not(between'(t,30,210)') [out]"
9
  • I'm getting a "Filter overlay has an unconnected output" error with this code?
    – razz
    Commented Aug 26, 2016 at 20:49
  • You haven't shown your full command, but you should have a -map [out] in there.
    – Gyan
    Commented Aug 26, 2016 at 20:52
  • Worked! -i in.mp4 -filter_complex "movie=logo.png[watermark];[watermark][0]scale2ref=400*iw/1280:48*iw/1280[wm][v];[wm]setsar=1[logo];[v][logo] overlay=1:main_h-overlay_h-1:enable=not(between'(t,30,210)')" out.mp4 Now trying to get it working with an automated script with the following command (used in a cms) $q = "$ffmpeg_path -i \"".$content_path."/".$row['orig_filename']."\" $ffmpeg_command \"$video_path/$subdir".$row['filename']."\""; The $ffmpeg_command part is added in the cms and executed however here it fails. Can't locate what i'm doing wrong with the script
    – razz
    Commented Aug 26, 2016 at 21:40
  • What's the $ffmpeg_command string?
    – Gyan
    Commented Aug 27, 2016 at 5:51
  • that is the part where i add the command. In this case -filter_complex "movie=/logo.png[watermark];[watermark][0]scale2ref=400*iw/1280:48*iw/1280[wm][v];[wm]setsar=1[logo];[v][logo] overlay=1:main_h-overlay_h-1:enable=not(between'(t,30,210)')[out]" Something goes wrong with scale2ref because when i use the command below (without scale2ref) all works perfectly. -vf "movie=logo.png [watermark]; [in][watermark] overlay=1:main_h-overlay_h-1:enable=not(between'(t,30,210)') [out]"
    – razz
    Commented Aug 27, 2016 at 7:54

You must log in to answer this question.

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