I have a problem adding watermark to my video. I'm converting a video into 5 different resolutions using the -s option.

what I've tried:

waterMark="\"movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]\""

resolutions=$(echo -e "${resolutions} -s ${newX}x${myY} ${map} -vcodec libx264 ${options} 
-vf ${waterMark} ${NEW_FILENAME}_${myY}p.mp4")

ffmpeg -i $FILENAME "${resolutions}"

here's the echo of the command: echo "ffmpeg -i $FILENAME $resolutions"

ffmpeg -i test.mp4  
 -s 1728x720 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_720p.mp4 
 -s 1152x480 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_480p.mp4 
 -s 864x360 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_360p.mp4 
 -s 576x240 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_240p.mp4 
 -s 344x144 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_144p.mp4

I don't know what the error is, all i'm getting is part of the code in red:

Metadata:
  handler_name    : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 126 kb/s
Metadata:
  handler_name    : SoundHandler  

this part in red*

-s 1728x720 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_720p.mp4 -s 1152x480 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_480p.mp4 -s 864x360 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_360p.mp4 -s 576x240 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" test_240p.mp4 -s 344x144 -map 0:0 -map 0:1 -vcodec libx264 -acodec aac -strict experimental -movflags faststart -vf "movie=/watermark.png [watermark]; [in

the strange part is, if I run the code I get from echo "ffmpeg -i $FILENAME $resolutions" from the terminal, it does work! but it's not working from bash

I also tried adding the watermark right after -i $FILENAME

ffmpeg -i $FILENAME -vf "movie=/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" $resolutions"

but in that case only the first video comes out with a watermark.

  • Is specifying multiple output resolutions in one command faster than doing it in separate calls? If not you could just use a for loop that executes ffmpeg five times. – Tim Sep 30 '13 at 8:52
  • If the output from echo works, but directly calling ffnpeg doesn't: Maybe the quotes are the problem. Have you considered writing the output of echo into a variable (tocall=$(echo "ffmpeg -i $FILENAME $resolutions")) and then calling this variable ($($tocall))? – Tim Sep 30 '13 at 12:26
  • @Tim I get [NULL @ 0x2452760] Unable to find a suitable output format for '[watermark];' [watermark];: Invalid argument – user2783132 Sep 30 '13 at 13:02
  • but your suggestion lead me to solution. eval $tocall worked! thanks – user2783132 Sep 30 '13 at 13:03
up vote 0 down vote accepted

I solve it by running the ffmpeg command with eval. eval takes a string as its argument, and evaluates it as if you'd typed that string on a command line.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.