aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-25 03:33:01 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-25 03:33:01 +0100
commit8117c92ee57b732e6d503dba02544cc614487265 (patch)
treef9ee7545ac1e51f5d4146ff0de2db3c1929574ac
parenta99f010603be2d7efa7e936b0895dda33931b135 (diff)
Fix replay crash when not recording audio
-rw-r--r--src/main.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 40966f5..a1103c2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -720,7 +720,7 @@ static void save_replay_async(AVCodecContext *video_codec_context, AVCodecContex
}
save_replay_output_filepath = output_dir + "/Replay_" + get_date_str() + "." + container_format;
- save_replay_thread = std::async(std::launch::async, [video_stream_index, audio_stream_index, container_format, start_index, pts_offset, video_codec_context, audio_codec_context]() mutable {
+ save_replay_thread = std::async(std::launch::async, [video_stream_index, container_format, start_index, pts_offset, video_codec_context, audio_codec_context]() mutable {
AVFormatContext *av_format_context;
// The output format is automatically guessed from the file extension
avformat_alloc_output_context2(&av_format_context, nullptr, container_format.c_str(), nullptr);
@@ -730,7 +730,7 @@ static void save_replay_async(AVCodecContext *video_codec_context, AVCodecContex
av_format_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
AVStream *video_stream = create_stream(av_format_context, video_codec_context);
- AVStream *audio_stream = audio_stream_index == -1 ? nullptr : create_stream(av_format_context, audio_codec_context);
+ AVStream *audio_stream = audio_codec_context ? create_stream(av_format_context, audio_codec_context) : nullptr;
avcodec_parameters_from_context(video_stream->codecpar, video_codec_context);
if(audio_stream)