Skip to content

Commit

Permalink
obs-ffmpeg: Fix seek offset being calculated incorrectly
Browse files Browse the repository at this point in the history
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 #7269
Fixes #7144
  • Loading branch information
notr1ch authored and derrod committed Sep 2, 2022
1 parent 7396c21 commit 3332bee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 3332bee

Please sign in to comment.