At the same time, I came up with this script that does the job:
#!/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 only thing I'm not sure about is how to maintain the same video quality. I thought that "-sameq" would maintain the same video quality, but as a result, the video size is smaller. I noticed this:
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 information is identical. Any tips on how to maintain the original video quality? thanks
source share