[FFmpeg-user] R: Re: Use ffmpeg to watermark and scale an image on video

daad at libero.it daad at libero.it
Tue Nov 22 23:18:51 CET 2011


doesn't it scale the video instead?
i need the image to be scaled.
in the meantime i came up with the following script:

#!/bin/bash

VIDEO=$1
LOGO=$2
VIDEO_WATERMARKED=w_${VIDEO}

VIDEO_WIDTH=`ffprobe -show_streams $VIDEO 2>&1 | grep ^width | sed s/width=//`
echo The video width is $VIDEO_WIDTH

cp $LOGO logo.png
IMAGE_WIDTH=$((VIDEO_WIDTH/3))
echo The image width will be $IMAGE_WIDTH

mogrify -resize $IMAGE_WIDTH logo.png
echo logo.png resized

echo Starting watermarking
ffmpeg -i $VIDEO -sameq -acodec copy -vf 'movie=logo.png [watermark]; [in]
[watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]' 
$VIDEO_WATERMARKED
echo Video watermarked



The last thing i'm not sure about is, why the watermarked video is smaller in 
size compared to the original. I thought that using "-sameq" would just keep 
the original video quality.
If i specify "-vcodec copy" then the watermark bit is not applied, hence I 
thought to use "-sameq".

INPUT
 Duration: 00:01:25.53, start: 0.000000, bitrate: 307 kb/s
    Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), 
yuv420p, 640x480 [SAR 1:1 DAR 4:3], 261 kb/s, 10 fps, 10 tbr, 3k tbn, 25 tbc
OUTPUT
   encoder         : Lavf53.20.0
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:
1 DAR 4:3], q=-1--1, 10 tbn, 10 tbc

whereas the audio info information are identical.
any advice on how to use the same video quality as well?
thanks




>----Messaggio originale----
>Da: alex.zhen.ma at gmail.com
>Data: 22/11/2011 22.57
>A: "FFmpeg user questions and RTFMs"<ffmpeg-user at ffmpeg.org>
>Ogg: Re: [FFmpeg-user] Use ffmpeg to watermark and scale an image on	video
>
>It should work with this way.
>
>ffmpeg -i sample.mov -sameq -acodec copy -vf
>'movie=logo.png,*scale=60:30* [watermark];
>[in]
>[watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]'
>sample2.mov
>
>On Tue, Nov 22, 2011 at 4:13 PM, daad at libero.it <daad at libero.it> wrote:
>
>> I want to be able to watermark videos with a logo image, which contains a
>> website url. The videos can be of different formats and dimension. I'm
>> trying
>> to figure out a generic ffmpeg command to achieve it, so that i don't have
>> to
>> tweak the command depending on the video i have to process. So far i got:
>>
>> ffmpeg -i sample.mov -sameq -acodec copy -vf 'movie=logo.png [watermark];
>> [in]
>> [watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]'
>> sample2.mov
>>
>> In this way though the logo will look too big or too small with video of
>> different size. I've seen there is a scale option for avfilter but that
>> will
>> scale the video, not the watermarked image (i guess?), but I haven't
>> figure out
>> whether it's possible to resize the image logo based on the dimension of
>> the
>> input video, so that I can say to scale the logo width to 1/3 of the video
>> width for example, and keep the image ratio.
>>
>> Any idea? doesn't need to be done in a single command, could even be a
>> script.
>> thanks in advance.
>> _______________________________________________
>> ffmpeg-user mailing list
>> ffmpeg-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>
>
>
>-- 
>Your sincerely !
>-------------------------------------------------------
>Alex Zhen Ma
>▪ Email: alex.zhen.ma at gmail.com
>_______________________________________________
>ffmpeg-user mailing list
>ffmpeg-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>




More information about the ffmpeg-user mailing list