From efa621163bfac52c71754583955434c8573ae83a Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 16 Jun 2023 12:20:00 +0200 Subject: [PATCH] vidcap file: flush decoder context on seek Also check if ring_buffer is available before flushing it, it crashes without audio. --- src/video_capture/file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/video_capture/file.c b/src/video_capture/file.c index 5e6563661..1ec7ef386 100644 --- a/src/video_capture/file.c +++ b/src/video_capture/file.c @@ -158,7 +158,15 @@ static void flush_captured_data(struct vidcap_state_lavf_decoder *s) { while ((f = simple_linked_list_pop(s->video_frame_queue)) != NULL) { VIDEO_FRAME_DISPOSE(f); } - ring_buffer_flush(s->audio_data); + if (s->audio_data) { + ring_buffer_flush(s->audio_data); + } + if (s->vid_ctx) { + avcodec_flush_buffers(s->vid_ctx); + } + if (s->aud_ctx) { + avcodec_flush_buffers(s->aud_ctx); + } } static void vidcap_file_common_cleanup(struct vidcap_state_lavf_decoder *s) {