]> git.sesse.net Git - nageru/commitdiff
Stop decoding video/audio in FFmpegCapture if we are not going to use the decoded...
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sun, 4 Apr 2021 11:41:29 +0000 (13:41 +0200)
committerSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sun, 4 Apr 2021 23:54:24 +0000 (01:54 +0200)
nageru/ffmpeg_capture.cpp

index 0a328e0182570a8953407541954a2ee5ac7763aa..4b9d54ff47082c0928e462201e623bef54069011 100644 (file)
@@ -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());