I'm learning how to split and combine videos with ffmpeg. Presently I'm practicing on a 799 KB MP4, one_through_ten-timestamped.mp4, where each frame has a burnt-in "frame number" (up to frame 40, the burnt-in number advances only every other frame).

The command I use is:

ffmpeg -f concat -i one_through_ten_edit_list.txt -c copy one_through_ten_edited.mp4

Where one_through_ten_edit_list.txt is:

file one_through_ten-timestamped.mp4
inpoint 00:00:01.500
outpoint 00:00:05.000
file one_through_ten-timestamped.mp4
inpoint 00:00:09.500
outpoint 00:00:13.000

When I perform this command in ffmpeg the output video has several issues:

  1. The output starts from the beginning of the source video instead of 1.5 s in.
  2. The audio after the second input video is concatenated is delayed (when played on QuickTime Player. It's fine on ffplay).

When I perform these same edits in MPEG Streamclip, the resulting video plays as expected. Here's some tabular output from ffprobe on one_through_ten-timestamped.mp4 which shows where the ffmpeg video and MPEG Streamclip differ in their concatenation points:

start of first segment end of first segment mpeg streamclip start 1st start of second segments end of second segment

Notice that both ffmpeg and MPEG Streamclip handle the second segment roughly the same, however ffmpeg doesn't seem to respect the inpoint in the first input video. Note that in my MP4, there's one packet per frame.

ffmpeg has behaved this way from version 2.8 (perhaps before) up through 3.3.3. Am I missing a command-line or edit-list option? Surely others have been successfully using ffmpeg to split and combine videos (without recompressing).

  • From the concat demuxer documentation: "inpoint–This directive works best with intra frame codecs, because for non-intra frame ones you will usually get extra packets before the actual In point and the decoded content will most likely contain frames before In point too." – llogan Sep 14 '17 at 17:10

Your Answer

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

Browse other questions tagged or ask your own question.