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

Function handle_file

tools/ismindex.c:495–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495static int handle_file(struct Tracks *tracks, const char *file, int split,
496 int ismf, const char *basename,
497 const char* output_prefix)
498{
499 AVFormatContext *ctx = NULL;
500 int err = 0, i, orig_tracks = tracks->nb_tracks;
501 char *ptr;
502 struct Track *track;
503
504 err = avformat_open_input(&ctx, file, NULL, NULL);
505 if (err < 0) {
506 fprintf(stderr, "Unable to open %s: %s\n", file, av_err2str(err));
507 return 1;
508 }
509
510 err = avformat_find_stream_info(ctx, NULL);
511 if (err < 0) {
512 fprintf(stderr, "Unable to identify %s: %s\n", file, av_err2str(err));
513 goto fail;
514 }
515
516 if (ctx->nb_streams < 1) {
517 fprintf(stderr, "No streams found in %s\n", file);
518 goto fail;
519 }
520
521 for (i = 0; i < ctx->nb_streams; i++) {
522 struct Track **temp;
523 AVStream *st = ctx->streams[i];
524
525 if (st->codecpar->bit_rate == 0) {
526 fprintf(stderr, "Skipping track %d in %s as it has zero bitrate\n",
527 st->id, file);
528 continue;
529 }
530
531 track = av_mallocz(sizeof(*track));
532 if (!track) {
533 err = AVERROR(ENOMEM);
534 goto fail;
535 }
536 temp = av_realloc_array(tracks->tracks,
537 tracks->nb_tracks + 1,
538 sizeof(*tracks->tracks));
539 if (!temp) {
540 av_free(track);
541 err = AVERROR(ENOMEM);
542 goto fail;
543 }
544 tracks->tracks = temp;
545 tracks->tracks[tracks->nb_tracks] = track;
546
547 track->name = file;
548 if ((ptr = strrchr(file, '/')))
549 track->name = ptr + 1;
550
551 track->bitrate = st->codecpar->bit_rate;
552 track->track_id = st->id;

Callers 1

mainFunction · 0.70

Calls 11

avformat_open_inputFunction · 0.85
av_realloc_arrayFunction · 0.85
av_freepFunction · 0.85
get_video_private_dataFunction · 0.85
avformat_close_inputFunction · 0.85
read_mfraFunction · 0.85
av_malloczFunction · 0.70
av_freeFunction · 0.70
av_rescale_rndFunction · 0.70
get_private_dataFunction · 0.70

Tested by

no test coverage detected