From 54171389c54dea3caf19ffb3abec1e72ae0531e2 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 17 Mar 2018 16:14:41 +0100 Subject: [PATCH] Fix a bug when looping FFmpeg inputs that have no audio. --- bmusb | 2 +- ffmpeg_capture.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bmusb b/bmusb index 6a012a4..e85d7ee 160000 --- a/bmusb +++ b/bmusb @@ -1 +1 @@ -Subproject commit 6a012a41c5422092cdac1f18a9019f37c0b85368 +Subproject commit e85d7ee1c0541900c57dd505454289dfaab9e782 diff --git a/ffmpeg_capture.cpp b/ffmpeg_capture.cpp index 1ffa9d5..42bdb2f 100644 --- a/ffmpeg_capture.cpp +++ b/ffmpeg_capture.cpp @@ -381,8 +381,9 @@ bool FFmpegCapture::play_video(const string &pathname) video_codec_ctx.get(), avcodec_close); // Open audio decoder, if we have audio. - AVCodecContextWithDeleter audio_codec_ctx = avcodec_alloc_context3_unique(nullptr); + AVCodecContextWithDeleter audio_codec_ctx; if (audio_stream_index != -1) { + audio_codec_ctx = avcodec_alloc_context3_unique(nullptr); const AVCodecParameters *audio_codecpar = format_ctx->streams[audio_stream_index]->codecpar; audio_timebase = format_ctx->streams[audio_stream_index]->time_base; if (avcodec_parameters_to_context(audio_codec_ctx.get(), audio_codecpar) < 0) { -- 2.39.2