Commit 9109833b32f4b367ba3d518dde8e0641effced9c

Authored by Hu Chunming
1 parent d3b383c9

优化实时视频流判断

src/decoder/dvpp/DvppDecoder.cpp
@@ -108,14 +108,6 @@ bool DvppDecoder::init(FFDecConfig cfg){ @@ -108,14 +108,6 @@ bool DvppDecoder::init(FFDecConfig cfg){
108 AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ 108 AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){
109 109
110 const char* input_file = config.uri.c_str(); 110 const char* input_file = config.uri.c_str();
111 - FILE* infile = fopen(input_file, "r");  
112 - if(nullptr != infile) {  
113 - m_bReal = false;  
114 - fclose(infile);  
115 - infile = nullptr;  
116 - } else {  
117 - m_bReal = true;  
118 - }  
119 111
120 // 打开输入视频文件 112 // 打开输入视频文件
121 AVDictionary *options = nullptr; 113 AVDictionary *options = nullptr;
@@ -131,6 +123,21 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ @@ -131,6 +123,21 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){
131 } 123 }
132 av_dump_format(fmt_ctx, 0, input_file, 0); 124 av_dump_format(fmt_ctx, 0, input_file, 0);
133 125
  126 + FILE* infile = fopen(input_file, "r");
  127 + if(nullptr != infile) {
  128 + // 可以作为本地文件打开,那必然是文件
  129 + m_bReal = false;
  130 + fclose(infile);
  131 + infile = nullptr;
  132 + } else {
  133 + // http://xxxx/xxx.mp4 也与文件同
  134 + if (fmt_ctx->iformat && fmt_ctx->iformat->extensions) {
  135 + m_bReal = false;
  136 + } else {
  137 + m_bReal = true;
  138 + }
  139 + }
  140 +
134 // 查找流信息 141 // 查找流信息
135 if (avformat_find_stream_info(fmt_ctx, nullptr) < 0) { 142 if (avformat_find_stream_info(fmt_ctx, nullptr) < 0) {
136 LOG_ERROR("[{}]- Cannot find input stream information!", m_dec_name); 143 LOG_ERROR("[{}]- Cannot find input stream information!", m_dec_name);