0

I am using this command line to add a five second image on end of video:

ffmpeg -i "f:\output\input.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4

It works great, but sometimes I want to cut the video and then add the five seconds. So, make a 120 second video 110 seconds, then add the 5 second ending.

Possibly in one command line? I've tried to break it into two, by starting with cutting the video, but then I get an "Unable to parse option value "-1" pixel format" error if I try to re-encode the video I cut with ffmpeg using this:

ffmpeg -i f:\output\input.mov -vcodec copy -acodec copy -ss 00:00:00.000 -t 00:01:50.000 f:\output\output.mov

That output video will then give an error if I try to run the first command line against it.

All feedback appreciated on shortening a video, and then adding ending.

Cheers! Ryan

1 Answer 1

1

Use

ffmpeg -t 110 -i "f:\output\input.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[0:v][0:a][1:v][2:a]concat=n=2:v=1:a=1[v][a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4 

With scale2ref, it should be

ffmpeg -t 110 -i "f:\output\input.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[1][0]scale2ref[2nd][ref];[ref][0:a][2nd][2:a]concat=n=2:v=1:a=1[v][a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4 

If the image has a different aspect ratio, use

ffmpeg -t 110 -i "f:\output\input.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[0]split[base][full];[base]trim=0:5,drawbox=t=fill[base];[1][base]scale2ref='if(lt(mdar,dar),oh*mdar/sar,iw)':'if(lt(mdar,dar),ih,ow*sar/mdar)'[2nd][base];[base][2nd]overlay='(W-w)/2':'(H-h)/2'[padded];[full][0:a][padded][2:a]concat=n=2:v=1:a=1[v][a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4 

This last command requires ffmpeg version >= 3.4

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks! Going to test that shortly. Also, not to stack questions, but if the .mov is different size than jpg, possible to auto-crop the jpg to match video dimensions?
Yes, with the scale2ref filter.
Thank you. I must have older ffmpeg build, as it does not recognize that filter.
ffmpeg -i "f:\output\yt.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[1][0]scale2ref[2nd][ref] [0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\ytready.mp4 I updated and it recognizes, but getting errors running this string.
Gyan's second answer its working perfectly. ffmpeg -t 110 -i "f:\output\input.mov" -loop 1 -t 5 -i "f:\output\taff.jpg" -f lavfi -t 5 -i anullsrc -filter_complex "[1][0]scale2ref[2nd][ref];[ref][0:a][2nd][2:a]concat=n=2:v=1:a=1[v][a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" f:\output\output.mp4 But i am unable find a parameter for scale2ref for avoid stretching input image end of the video. I want to make auto fit image without losing aspect ratio.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.