Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am wanting to overlay one video onto another but with a delayed appearance. I have:

  • source1.mp4 which is of duration 20 sec.
  • source2.mp4 which is of duration 5 sec.

I want to create a final output in which source2.mp4 overlaps source1.mp4 from 00:00:07 to 00:00:12. How can I achieve this?

I have tried following commands, but none of these serve what I want:

ffmpeg -i source1.mp4 -itsoffset 7 -i source2.mp4 -map 0:0 -map 1:1 -c copy -y output.mp4

ffmpeg -itsoffset 7 -i source2.mp4 -i source1.mp4 -filter_complex 'overlay=0:0' output.mp4 

ffmpeg -i source1.mp4 -i source2.mp4 -filter_complex "overlay" -strict -2 output.mp4
share|improve this question
    
Please do not ask the same question on multiple Stack Exchange sites. –  LordNeckbeard Mar 27 at 17:56
    
I asked this on both sites because it was confusing whether or not it is a programming related question. However I have still not received any answer on either site for this question. –  alter Mar 29 at 12:46
    
Please show the complete ffmpeg console output from at least one of your commands. –  LordNeckbeard Mar 29 at 17:49

1 Answer 1

up vote 0 down vote accepted

To do this you need latest ffmpeg version (2.2). So you should run command like

ffmpeg -i sample1.mp4 -i sample2.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS[v0];[1:v]setpts=PTS-STARTPTS+7/TB[v1];[v0][v1]overlay=eof_action=pass[out1]" -map [out1]  /tmp/final.mp4

The trick is to set PTS for second video to +7 sec (PTS-STARTPTS+7/TB) and then just overlay 2 streams.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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