if (ic->format->flags & AVFMT_NEEDNUMBER) { if (filename_number_test(ic->filename) < 0) exit(1); }
void opt_input_file(const char *filename){    AVFormatContext *ic;    AVFormatParameters params, *ap = &params;    URLFormat url_format;    AVFormat *fmt;    int err, i, ret;    ic = av_mallocz(sizeof(AVFormatContext));    strcpy(ic->filename, filename);    /* first format guess to know if we must open file */    fmt = file_format;    if (!fmt)         fmt = guess_format(NULL, filename, NULL);        if (fmt == NULL || !(fmt->flags & AVFMT_NOFILE)) {        /* open file */        if (url_fopen(&ic->pb, filename, URL_RDONLY) < 0) {            fprintf(stderr, "Could not open '%s'\n", filename);            exit(1);        }            /* find format and set default parameters */        fmt = file_format;        err = url_getformat(url_fileno(&ic->pb), &url_format);        if (err >= 0) {            if (!fmt)                fmt = guess_format(url_format.format_name, NULL, NULL);            ap->sample_rate = url_format.sample_rate;            ap->frame_rate = url_format.frame_rate;            ap->channels = url_format.channels;            ap->width = url_format.width;            ap->height = url_format.height;            ap->pix_fmt = url_format.pix_fmt;        } else {            if (!fmt)                fmt = guess_format(NULL, filename, NULL);            memset(ap, 0, sizeof(*ap));        }    } else {        memset(ap, 0, sizeof(*ap));    }    if (!fmt || !fmt->read_header) {        fprintf(stderr, "%s: Unknown file format\n", filename);        exit(1);    }    ic->format = fmt;    /* get default parameters from command line */    if (!ap->sample_rate)        ap->sample_rate = audio_sample_rate;    if (!ap->channels)        ap->channels = audio_channels;    if (!ap->frame_rate)        ap->frame_rate = frame_rate;    if (!ap->width)        ap->width = frame_width;    if (!ap->height)        ap->height = frame_height;        err = ic->format->read_header(ic, ap);    if (err < 0) {        fprintf(stderr, "%s: Error while parsing header\n", filename);        exit(1);    }        /* If not enough info for the codecs, we decode the first frames       to get it. (used in mpeg case for example) */    ret = find_codec_parameters(ic);    if (ret < 0) {        fprintf(stderr, "%s: could not find codec parameters\n", filename);        exit(1);    }    /* update the current parameters so that they match the one of the input stream */    for(i=0;i<ic->nb_streams;i++) {        AVCodecContext *enc = &ic->streams[i]->codec;        switch(enc->codec_type) {        case CODEC_TYPE_AUDIO:            audio_channels = enc->channels;            audio_sample_rate = enc->sample_rate;            break;        case CODEC_TYPE_VIDEO:            frame_height = enc->height;            frame_width = enc->width;            frame_rate = enc->frame_rate;            break;        }    }        input_files[nb_input_files] = ic;    /* dump the file content */    dump_format(ic, nb_input_files, filename, 0);    nb_input_files++;    file_format = NULL;}