oc->loop_output = loop_output;
static void opt_output_file(const char *filename){    AVFormatContext *oc;    int use_video, use_audio, input_has_video, input_has_audio;    AVFormatParameters params, *ap = &params;    if (!strcmp(filename, "-"))        filename = "pipe:";    oc = av_alloc_format_context();    if (!file_oformat) {        file_oformat = guess_format(NULL, filename, NULL);        if (!file_oformat) {            fprintf(stderr, "Unable for find a suitable output format for '%s'\n",                    filename);            exit(1);        }    }        oc->oformat = file_oformat;    pstrcpy(oc->filename, sizeof(oc->filename), filename);    if (!strcmp(file_oformat->name, "ffm") &&         strstart(filename, "http:", NULL)) {        /* special case for files sent to ffserver: we get the stream           parameters from ffserver */        if (read_ffserver_streams(oc, filename) < 0) {            fprintf(stderr, "Could not read stream parameters from '%s'\n", filename);            exit(1);        }    } else {        use_video = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy;        use_audio = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy;        /* disable if no corresponding type found and at least one           input file */        if (nb_input_files > 0) {            check_audio_video_inputs(&input_has_video, &input_has_audio);            if (!input_has_video)                use_video = 0;            if (!input_has_audio)                use_audio = 0;        }        /* manual disable */        if (audio_disable) {            use_audio = 0;        }        if (video_disable) {            use_video = 0;        }                if (use_video) {            new_video_stream(oc);        }            if (use_audio) {            new_audio_stream(oc);        }        if (!oc->nb_streams) {            fprintf(stderr, "No audio or video streams available\n");            exit(1);        }        oc->timestamp = rec_timestamp;	    	if (str_title)            pstrcpy(oc->title, sizeof(oc->title), str_title);        if (str_author)            pstrcpy(oc->author, sizeof(oc->author), str_author);        if (str_copyright)            pstrcpy(oc->copyright, sizeof(oc->copyright), str_copyright);        if (str_comment)            pstrcpy(oc->comment, sizeof(oc->comment), str_comment);    }    output_files[nb_output_files++] = oc;    /* check filename in case of an image number is expected */    if (oc->oformat->flags & AVFMT_NEEDNUMBER) {        if (filename_number_test(oc->filename) < 0) {            print_error(oc->filename, AVERROR_NUMEXPECTED);            exit(1);        }    }    if (!(oc->oformat->flags & AVFMT_NOFILE)) {        /* test if it already exists to avoid loosing precious files */        if (!file_overwrite &&             (strchr(filename, ':') == NULL ||             strstart(filename, "file:", NULL))) {            if (url_exist(filename)) {                int c;                                if ( !using_stdin ) {                    fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);                    fflush(stderr);                    c = getchar();                    if (toupper(c) != 'Y') {                        fprintf(stderr, "Not overwriting - exiting\n");                        exit(1);                    }				}				else {                    fprintf(stderr,"File '%s' already exists. Exiting.\n", filename);                    exit(1);				}            }        }                /* open the file */        if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {            fprintf(stderr, "Could not open '%s'\n", filename);            exit(1);        }    }    memset(ap, 0, sizeof(*ap));    ap->image_format = image_format;    if (av_set_parameters(oc, ap) < 0) {        fprintf(stderr, "%s: Invalid encoding parameters\n",                oc->filename);        exit(1);    }    oc->packet_size= mux_packet_size;    oc->mux_rate= mux_rate;    oc->preload= (int)(mux_preload*AV_TIME_BASE);    oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);    /* reset some options */    file_oformat = NULL;    file_iformat = NULL;    image_format = NULL;}