dump_format(ic, nb_input_files, "", 0);
if (verbose >= 0) dump_format(ic, nb_input_files, "", 0);
static void prepare_grab(void){    int has_video, has_audio, i, j;    AVFormatContext *oc;    AVFormatContext *ic;    AVFormatParameters vp1, *vp = &vp1;    AVFormatParameters ap1, *ap = &ap1;        /* see if audio/video inputs are needed */    has_video = 0;    has_audio = 0;    memset(ap, 0, sizeof(*ap));    memset(vp, 0, sizeof(*vp));    for(j=0;j<nb_output_files;j++) {        oc = output_files[j];        for(i=0;i<oc->nb_streams;i++) {            AVCodecContext *enc = &oc->streams[i]->codec;            switch(enc->codec_type) {            case CODEC_TYPE_AUDIO:                if (enc->sample_rate > ap->sample_rate)                    ap->sample_rate = enc->sample_rate;                if (enc->channels > ap->channels)                    ap->channels = enc->channels;                has_audio = 1;                break;            case CODEC_TYPE_VIDEO:                if (enc->width > vp->width)                    vp->width = enc->width;                if (enc->height > vp->height)                    vp->height = enc->height;                                assert(enc->frame_rate_base == DEFAULT_FRAME_RATE_BASE);                if (enc->frame_rate > vp->frame_rate){                    vp->frame_rate      = enc->frame_rate;                    vp->frame_rate_base = enc->frame_rate_base;                }                has_video = 1;                break;            default:                av_abort();            }        }    }        if (has_video == 0 && has_audio == 0) {        fprintf(stderr, "Output file must have at least one audio or video stream\n");        exit(1);    }        if (has_video) {        AVInputFormat *fmt1;        fmt1 = av_find_input_format(video_grab_format);        vp->device  = video_device;        vp->channel = video_channel;	vp->standard = video_standard;        if (av_open_input_file(&ic, "", fmt1, 0, vp) < 0) {            fprintf(stderr, "Could not find video grab device\n");            exit(1);        }        /* If not enough info to get the stream parameters, we decode the           first frames to get it. */	if ((ic->ctx_flags & AVFMTCTX_NOHEADER) && av_find_stream_info(ic) < 0) {            fprintf(stderr, "Could not find video grab parameters\n");            exit(1);        }        /* by now video grab has one stream */        ic->streams[0]->r_frame_rate      = vp->frame_rate;        ic->streams[0]->r_frame_rate_base = vp->frame_rate_base;        input_files[nb_input_files] = ic;        dump_format(ic, nb_input_files, "", 0);        nb_input_files++;    }    if (has_audio && audio_grab_format) {        AVInputFormat *fmt1;        fmt1 = av_find_input_format(audio_grab_format);        ap->device = audio_device;        if (av_open_input_file(&ic, "", fmt1, 0, ap) < 0) {            fprintf(stderr, "Could not find audio grab device\n");            exit(1);        }        input_files[nb_input_files] = ic;        dump_format(ic, nb_input_files, "", 0);        nb_input_files++;    }}