if(genpts) ic->flags|= AVFMT_FLAG_GENPTS;
static void opt_input_file(const char *filename){    AVFormatContext *ic;    AVFormatParameters params, *ap = &params;    int err, i, ret, rfps, rfps_base;    int64_t timestamp;    if (!strcmp(filename, "-"))        filename = "pipe:";    using_stdin |= !strncmp(filename, "pipe:", 5) ||                    !strcmp( filename, "/dev/stdin" );    /* get default parameters from command line */    memset(ap, 0, sizeof(*ap));    ap->sample_rate = audio_sample_rate;    ap->channels = audio_channels;    ap->time_base.den = frame_rate;    ap->time_base.num = frame_rate_base;    ap->width = frame_width + frame_padleft + frame_padright;    ap->height = frame_height + frame_padtop + frame_padbottom;    ap->image_format = image_format;    ap->pix_fmt = frame_pix_fmt;    ap->device  = grab_device;    ap->channel = video_channel;    ap->standard = video_standard;    ap->video_codec_id = video_codec_id;    ap->audio_codec_id = audio_codec_id;    if(pgmyuv_compatibility_hack)        ap->video_codec_id= CODEC_ID_PGMYUV;    /* open the input file with generic libav function */    err = av_open_input_file(&ic, filename, file_iformat, 0, ap);    if (err < 0) {        print_error(filename, err);        exit(1);    }        /* If not enough info to get the stream parameters, we decode the       first frames to get it. (used in mpeg case for example) */    ret = av_find_stream_info(ic);    if (ret < 0 && verbose >= 0) {        fprintf(stderr, "%s: could not find codec parameters\n", filename);        exit(1);    }    timestamp = start_time;    /* add the stream start time */    if (ic->start_time != AV_NOPTS_VALUE)        timestamp += ic->start_time;    /* if seeking requested, we execute it */    if (start_time != 0) {        ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);        if (ret < 0) {            fprintf(stderr, "%s: could not seek to position %0.3f\n",                     filename, (double)timestamp / AV_TIME_BASE);        }        /* reset seek info */        start_time = 0;    }    /* 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;#if defined(HAVE_THREADS)        if(thread_count>1)            avcodec_thread_init(enc, thread_count);#endif        enc->thread_count= thread_count;        switch(enc->codec_type) {        case CODEC_TYPE_AUDIO:            //fprintf(stderr, "\nInput Audio channels: %d", enc->channels);            audio_channels = enc->channels;            audio_sample_rate = enc->sample_rate;            if(audio_disable)                ic->streams[i]->discard= AVDISCARD_ALL;            break;        case CODEC_TYPE_VIDEO:            frame_height = enc->height;            frame_width = enc->width;	    frame_aspect_ratio = av_q2d(enc->sample_aspect_ratio) * enc->width / enc->height;	    frame_pix_fmt = enc->pix_fmt;            rfps      = ic->streams[i]->r_frame_rate.num;            rfps_base = ic->streams[i]->r_frame_rate.den;            enc->workaround_bugs = workaround_bugs;            enc->error_resilience = error_resilience;             enc->error_concealment = error_concealment;             enc->idct_algo = idct_algo;            enc->debug = debug;            enc->debug_mv = debug_mv;                        enc->lowres= lowres;            if(lowres) enc->flags |= CODEC_FLAG_EMU_EDGE;            if(bitexact)                enc->flags|= CODEC_FLAG_BITEXACT;            if(me_threshold)                enc->debug |= FF_DEBUG_MV;            if(gray_only)                enc->flags |= CODEC_FLAG_GRAY;            if (enc->time_base.den != rfps || enc->time_base.num != rfps_base) {                 if (verbose >= 0)                    fprintf(stderr,"\nSeems that stream %d comes from film source: %2.2f (%d/%d) -> %2.2f (%d/%d)\n",                            i, (float)enc->time_base.den / enc->time_base.num, enc->time_base.den, enc->time_base.num,                    (float)rfps / rfps_base, rfps, rfps_base);            }            /* update the current frame rate to match the stream frame rate */            frame_rate      = rfps;            frame_rate_base = rfps_base;            enc->rate_emu = rate_emu;            if(video_disable)                ic->streams[i]->discard= AVDISCARD_ALL;            else if(video_discard)                ic->streams[i]->discard= video_discard;            break;        case CODEC_TYPE_DATA:            break;        case CODEC_TYPE_SUBTITLE:            break;        case CODEC_TYPE_UNKNOWN:            break;        default:            av_abort();        }    }        input_files[nb_input_files] = ic;    input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp);    /* dump the file content */    if (verbose >= 0)        dump_format(ic, nb_input_files, filename, 0);    nb_input_files++;    file_iformat = NULL;    file_oformat = NULL;    image_format = NULL;    grab_device = NULL;    video_channel = 0;        rate_emu = 0;}