I want to show a logoon a video when the video starts. I already found this command :

ffmpeg -i input.mp4 -framerate 30000/1001 \
-loop 1 -i test.png -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov];\
 [0:v][ov] overlay=10:10 [v]" -map "[v]" -map 0:a -c:v libx264 \
-c:a copy -shortest Bigout.mp4

from How to add my logo for the first 30 seconds in a video with ffmpeg?

But the problem is my video's widths/heights are different and each time I add a logo, it does not cover the whole video. What should I do if I want to set the logo width/height to the width/height of the video ?

UPDATE After @Behroozfar Answer, I tried to use scale2ref, with the command below:

ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i biglogo.png -filter_complex "[1:v][0:v]scale2ref=iw/1:-1[ovrl][0v]; [0v][ovrl]overlay=0:0[v]" -map "[v] ; [1:v] fade=out:st=2:d=1:alpha=1 [ov]" -map 0:a -c:v libx264 -c:a copy -shortest Bigout.mp4

but the question is , I can't show the logo just for one second. It exists during the whole video play.


Use scale2ref filter

ffmpeg -i input.mp4 -framerate 30000/1001 \ -loop 1 -i test.png -filter_complex "[1:v]fade=out:st=30:d=1:alpha=1[ov]; \ [ov][0:v]scale2ref[logo][video]; \ [video][logo]overlay=10:10[v]" -map "[v]" -map 0:a -c:v libx264 \ -c:a copy -shortest Bigout.mp4

| improve this answer | |
  • To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different. – Gyan Oct 12 '16 at 14:21
  • @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before. – MHPalang Oct 12 '16 at 14:48

To show the full-sized logo for one second and then a small-sized logo afterwards, use

ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i test.png
         "[1]fade=out:st=1:d=0.9:alpha=1,trim=0:2[f]; \
          [1]fade=st=2:d=0.5:alpha=1,trim=0:3[s]; \
          [video][fo]overlay=eof_action=pass[v0]; \
          [v0][ss]overlay=W-w-5:H-h-5[v]" \
       -map "[v]" -map 0:a -c:v libx264 -c:a copy Bigout.mp4
| improve this answer | |
  • thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video – MHPalang Oct 12 '16 at 15:48
  • sorry, [fo] in your command should have been [f]. – MHPalang Oct 12 '16 at 15:50
  • Made corrections. – Gyan Oct 12 '16 at 15:55
  • Thank you. It works fine for the first part. But there is not small logo on the for the second part – MHPalang Oct 12 '16 at 16:02
  • unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish. – MHPalang Oct 12 '16 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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