]> git.sesse.net Git - nageru/blobdiff - ffmpeg_capture.cpp
Fix a bug when looping FFmpeg inputs that have no audio.
[nageru] / ffmpeg_capture.cpp
index 1ffa9d5418dc8d16cf215fb84892346c89084cb8..42bdb2f765d65b18e69a2543793a08ad38590cfc 100644 (file)
@@ -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) {