Commit 9109833b32f4b367ba3d518dde8e0641effced9c
1 parent
d3b383c9
优化实时视频流判断
Showing
1 changed file
with
15 additions
and
8 deletions
src/decoder/dvpp/DvppDecoder.cpp
... | ... | @@ -108,14 +108,6 @@ bool DvppDecoder::init(FFDecConfig cfg){ |
108 | 108 | AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ |
109 | 109 | |
110 | 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 | 113 | AVDictionary *options = nullptr; |
... | ... | @@ -131,6 +123,21 @@ AVCodecContext* DvppDecoder::init_FFmpeg(FFDecConfig config){ |
131 | 123 | } |
132 | 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 | 142 | if (avformat_find_stream_info(fmt_ctx, nullptr) < 0) { |
136 | 143 | LOG_ERROR("[{}]- Cannot find input stream information!", m_dec_name); | ... | ... |