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

Function open_input_file

fftools/ffprobe.c:2425–2541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2423}
2424
2425static int open_input_file(InputFile *ifile, const char *filename,
2426 const char *print_filename)
2427{
2428 int err, i;
2429 AVFormatContext *fmt_ctx = NULL;
2430 const AVDictionaryEntry *t = NULL;
2431 int scan_all_pmts_set = 0;
2432
2433 fmt_ctx = avformat_alloc_context();
2434 if (!fmt_ctx)
2435 return AVERROR(ENOMEM);
2436
2437 err = set_decoders(fmt_ctx);
2438 if (err < 0)
2439 return err;
2440 if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
2441 av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
2442 scan_all_pmts_set = 1;
2443 }
2444 if ((err = avformat_open_input(&fmt_ctx, filename,
2445 iformat, &format_opts)) < 0) {
2446 print_error(filename, err);
2447 return err;
2448 }
2449 if (print_filename) {
2450 av_freep(&fmt_ctx->url);
2451 fmt_ctx->url = av_strdup(print_filename);
2452 }
2453 ifile->fmt_ctx = fmt_ctx;
2454 if (scan_all_pmts_set)
2455 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
2456 while ((t = av_dict_iterate(format_opts, t)))
2457 av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
2458
2459 if (find_stream_info) {
2460 AVDictionary **opts;
2461 int orig_nb_streams = fmt_ctx->nb_streams;
2462
2463 err = setup_find_stream_info_opts(fmt_ctx, codec_opts, &opts);
2464 if (err < 0)
2465 return err;
2466
2467 err = avformat_find_stream_info(fmt_ctx, opts);
2468
2469 for (i = 0; i < orig_nb_streams; i++)
2470 av_dict_free(&opts[i]);
2471 av_freep(&opts);
2472
2473 if (err < 0) {
2474 print_error(filename, err);
2475 return err;
2476 }
2477 }
2478
2479 av_dump_format(fmt_ctx, 0, filename, 0);
2480
2481 ifile->streams = av_calloc(fmt_ctx->nb_streams, sizeof(*ifile->streams));
2482 if (!ifile->streams)

Callers 1

probe_fileFunction · 0.70

Calls 15

avformat_alloc_contextFunction · 0.85
set_decodersFunction · 0.85
av_dict_getFunction · 0.85
av_dict_setFunction · 0.85
avformat_open_inputFunction · 0.85
print_errorFunction · 0.85
av_freepFunction · 0.85
av_strdupFunction · 0.85
av_dict_iterateFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected