0

I want to add a watermark logo to a video (uploaded by users) and concat it with an Intro and resulting video must have same format as input video.

The problem starts when uploaded video have more than one audio stream and include subtitle.

I solved audio problem by something like this command.

ffmpeg -i intro.mp4 -i input.mkv -i logo.png -filter_complex "[0:v] scale=480:270,setdar=16/9 [a]; [1:v] scale=480:270,setdar=16/9 [b]; [2:0] scale=480:270 [wm]; [b][wm] overlay[ov]; [a][0:a:0][0:a:0] [ov][1:a:0][1:a:1] concat=n=2:v=1:a=2 [vd] [a0] [a1]" -map "[vd]" -map "[a0]" -map "[a1]" -y output.mkv

but output dose not contain subtitle.

any one can help?

0

Use

ffmpeg -i intro.mp4 -i input.mkv -itsoffset 4.5 -i input.mkv -i logo.png
  -filter_complex
     "[0:v] scale=480:270,setdar=16/9 [a];
      [1:v] scale=480:270,setdar=16/9 [b];
      [3:0] scale=480:270 [wm];
      [b][wm] overlay[ov];
      [a][0:a:0][0:a:0] [ov][1:a:0][1:a:1] concat=n=2:v=1:a=2 [vd] [a0] [a1]"
  -map "[vd]" -map "[a0]" -map "[a1]" -map 2:s? -c:s copy -y output.mkv

Once you specify any map statements, only those mapped streams are included. So, you have to explicitly map any subtitle streams. Since there may not be one, I've added a trailing ? to indicate conditional assignment.

I've fed the input video twice, because the subtitle timestamps will be wrong in the output as the intro now precedes the video. A timestamp offset is added to the 2nd input and the subtitle is mapped from that feed. The itsoffset value should be equal to the duration of the intro (in seconds). There shouldn't be any need to transcode the subtitles.

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.