MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / open_input_file

Function open_input_file

ffprobe.c:232–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
233{
234 int err, i;
235 AVFormatContext *fmt_ctx;
236
237 fmt_ctx = avformat_alloc_context();
238
239 if ((err = av_open_input_file(&fmt_ctx, filename, iformat, 0, NULL)) < 0) {
240 print_error(filename, err);
241 return err;
242 }
243
244 /* fill the streams in the format context */
245 if ((err = av_find_stream_info(fmt_ctx)) < 0) {
246 print_error(filename, err);
247 return err;
248 }
249
250 dump_format(fmt_ctx, 0, filename, 0);
251
252 /* bind a decoder to each input stream */
253 for (i = 0; i < fmt_ctx->nb_streams; i++) {
254 AVStream *stream = fmt_ctx->streams[i];
255 AVCodec *codec;
256
257 if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
258 fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n",
259 stream->codec->codec_id, stream->index);
260 } else if (avcodec_open(stream->codec, codec) < 0) {
261 fprintf(stderr, "Error while opening codec for input stream %d\n",
262 stream->index);
263 }
264 }
265
266 *fmt_ctx_ptr = fmt_ctx;
267 return 0;
268}
269
270static int probe_file(const char *filename)
271{

Callers 1

probe_fileFunction · 0.85

Calls 7

avformat_alloc_contextFunction · 0.85
av_open_input_fileFunction · 0.85
print_errorFunction · 0.85
av_find_stream_infoFunction · 0.85
dump_formatFunction · 0.85
avcodec_find_decoderFunction · 0.85
avcodec_openFunction · 0.85

Tested by

no test coverage detected