The concat demuxer's seek to an in point goes 8 ms past it. The MP4 demuxer takes a seek's time as a presentation time and subtracts the first frame's delay to search the decode times (mov_seek_stream()). In an MP4 copied from an MKV the times were rounded to milliseconds, so a key frame's delay can be 1 ms shorter than the first frame's, and a seek to the key frame's own time found the key frame before it: Big Buck Bunny at 720p, cut at its key frame at 184.933 s, came out with the 83 frames from 182.167 s in front. The in point itself, and so the file's place in the list, is as before; 8 ms is less than a frame at 120 fps. Measured on 8.1.3 (D927, tools/fm-test.sh studio-render). --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -35,6 +35,9 @@ #include "internal.h" #include "url.h" +/* how far past an in point its seek goes, in AV_TIME_BASE units: 8 ms */ +#define INPOINT_SEEK_SLACK 8000 + typedef enum ConcatMatchMode { MATCH_ONE_TO_ONE, MATCH_EXACT_ID, @@ -394,7 +397,11 @@ if ((ret = match_streams(avf)) < 0) return ret; if (file->inpoint != AV_NOPTS_VALUE) { - if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, file->inpoint, file->inpoint, 0)) < 0) + /* a few milliseconds past the in point: an MP4 whose times were rounded to + * milliseconds has key frames up to 1 ms off the constant delay its seek + * assumes, and a seek to the key frame's own time found the one before it */ + int64_t seek = av_sat_add64(file->inpoint, INPOINT_SEEK_SLACK); + if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, seek, seek, 0)) < 0) return ret; } return 0;