From e463f05db81538dedceb8d0eaac59bb622cb76e5 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 4 Apr 2021 13:41:29 +0200 Subject: [PATCH] Stop decoding video/audio in FFmpegCapture if we are not going to use the decoded information anyway. --- nageru/ffmpeg_capture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nageru/ffmpeg_capture.cpp b/nageru/ffmpeg_capture.cpp index 0a328e0..4b9d54f 100644 --- a/nageru/ffmpeg_capture.cpp +++ b/nageru/ffmpeg_capture.cpp @@ -848,13 +848,13 @@ AVFrameWithDeleter FFmpegCapture::decode_frame(AVFormatContext *format_ctx, AVCo if (pkt.stream_index == video_stream_index && video_callback != nullptr) { video_callback(&pkt, format_ctx->streams[video_stream_index]->time_base); } - if (pkt.stream_index == video_stream_index) { + if (pkt.stream_index == video_stream_index && global_flags.transcode_video) { if (avcodec_send_packet(video_codec_ctx, &pkt) < 0) { fprintf(stderr, "%s: Cannot send packet to video codec.\n", pathname.c_str()); *error = true; return AVFrameWithDeleter(nullptr); } - } else if (pkt.stream_index == audio_stream_index) { + } else if (pkt.stream_index == audio_stream_index && global_flags.transcode_audio) { has_audio = true; if (avcodec_send_packet(audio_codec_ctx, &pkt) < 0) { fprintf(stderr, "%s: Cannot send packet to audio codec.\n", pathname.c_str()); -- 2.39.2