obs-ffmpeg: Fix seek offset being calculated incorrectly

If FFmpeg wrote data and then seeked back to immediately overwrite it,
the second seek would be skipped as our virtual offset was incorrectly
thinking it hadn't changed. This caused MP4 corruption when seeking
back in the file to write the moov atom.

Fixes https://github.com/obsproject/obs-studio/issues/7269
Fixes https://github.com/obsproject/obs-studio/issues/7144
This commit is contained in:
Richard Stanway 2022-09-02 21:58:05 +02:00 committed by Rodney
parent 7396c211be
commit 3332beece5

View File

@ -780,7 +780,12 @@ static void *ffmpeg_mux_io_thread(void *data)
if (want_seek) {
os_fseeki64(ffm->io.output_file,
next_seek_position, SEEK_SET);
current_seek_position = next_seek_position;
// Update the next virtual position, making sure to take
// into account the size of the chunk we're about to write.
current_seek_position =
next_seek_position + chunk_used;
want_seek = false;
}