>> Why do you think that this is possible in the general case? > Why not? I suggested that missing keyframes could be the cause of this behavior, so I tried to use raw input formats (rawvideo+pcm_s16le instead of h264+aac), but the new video is still 0.2s longer (it's not 2 seconds but still too long). I have no more ideas.