Browse Source

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
Richard Stanway 3 năm trước cách đây
mục cha
commit
3332beece5

+ 6 - 1
plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c

@@ -780,7 +780,12 @@ static void *ffmpeg_mux_io_thread(void *data)
 			if (want_seek) {
 			if (want_seek) {
 				os_fseeki64(ffm->io.output_file,
 				os_fseeki64(ffm->io.output_file,
 					    next_seek_position, SEEK_SET);
 					    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;
 				want_seek = false;
 			}
 			}