Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

video - FFMPEG ignores "-shortest"

I'm using FFMPEG to overlay one video on another. It works, but the "-shortest" instruction is ignored.

This is the code:

ffmpeg -i "D:Underlay.avi" -i "D:Overlay.avi" -filter_complex [1:v]colorkey=0xFFFFFF:0.01:0.0[KeyedOverlay];[0:v][KeyedOverlay]overlay[Composite] -map [Composite] -c:v png -shortest "D:Composite.avi"

Am I doing anything wrong? Is there an alternative method?

question from:https://stackoverflow.com/questions/65908789/ffmpeg-ignores-shortest

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Both videos are being combined into a single video. Your output only has one video stream, so -shortest does nothing because it has no other streams to compare duration.

Use the overlay specific shortest option instead:

ffmpeg -i "D:Underlay.avi" -i "D:Overlay.avi" -filter_complex "[1:v]colorkey=0xFFFFFF:0.01:0.0[KeyedOverlay];[0:v][KeyedOverlay]overlay=shortest=1:format=auto[Composite]" -map "[Composite]" -c:v png "D:Composite.avi"

I also added format=auto so your overlay may look better.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...