From 9109833b32f4b367ba3d518dde8e0641effced9c Mon Sep 17 00:00:00 2001 From: Hu Chunming <2657262686@qq.com> Date: Mon, 27 May 2024 14:44:06 +0800 Subject: [PATCH] 优化实时视频流判断 --- src/decoder/dvpp/DvppDecoder.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/decoder/dvpp/DvppDecoder.cpp b/src/decoder/dvpp/DvppDecoder.cpp index b21b7c8..940f378 100644 --- a/src/decoder/dvpp/DvppDecoder.cpp +++ b/src/decoder/dvpp/DvppDecoder.cpp @@ -108,14 +108,6 @@ bool DvppDecoder::init(FFDecConfig cfg){ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ const char* input_file = config.uri.c_str(); - FILE* infile = fopen(input_file, "r"); - if(nullptr != infile) { - m_bReal = false; - fclose(infile); - infile = nullptr; - } else { - m_bReal = true; - } // 打开输入视频文件 AVDictionary *options = nullptr; @@ -131,6 +123,21 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ } av_dump_format(fmt_ctx, 0, input_file, 0); + FILE* infile = fopen(input_file, "r"); + if(nullptr != infile) { + // 可以作为本地文件打开,那必然是文件 + m_bReal = false; + fclose(infile); + infile = nullptr; + } else { + // http://xxxx/xxx.mp4 也与文件同 + if (fmt_ctx->iformat && fmt_ctx->iformat->extensions) { + m_bReal = false; + } else { + m_bReal = true; + } + } + // 查找流信息 if (avformat_find_stream_info(fmt_ctx, nullptr) < 0) { LOG_ERROR("[{}]- Cannot find input stream information!", m_dec_name); -- libgit2 0.21.4