I have two videos of the same format encoded with the same codecs. I want trailer.mkv to be played after n minutes in the middle of main.mkv. After playing trailer.mkv, the rest of the main.mkv will continue playing. How can I concatenate them?

1 Answer 1


I know how to do it in three steps. Separate your main video.

Step 1. Trim the end.

ffmpeg -i main.mkv -c copy -t 00:02:00 main-intro.mkv

Step 2. Trim the start.

ffmpeg -i main.mkv -c copy -ss 00:02:00 main-outro.mkv

Step 3. Concatenate them with your trailer file.

ffmpeg -safe 0 -i "concat:main-intro.mkv|trailer.mkv|main-outro.mkv" -c copy output.mkv

You can write script and you will have opportunity to do it in one click.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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