if (!(output_files[i]->oformat->flags & AVFMT_NOFILE)) url_fclose(&output_files[i]->pb);
AVFormatContext *s = output_files[i]; int j; if (!(s->oformat->flags & AVFMT_NOFILE)) url_fclose(&s->pb); for(j=0;j<s->nb_streams;j++) av_free(s->streams[j]); av_free(s);
int main(int argc, char **argv){    int optindex, i;    const char *opt, *arg;    const OptionDef *po;    INT64 ti;        av_register_all();    /* detect if invoked as player */    i = strlen(argv[0]);    if (i >= 6 && !strcmp(argv[0] + i - 6, "ffplay"))        do_play = 1;    if (argc <= 1)        show_help();        /* parse options */    optindex = 1;    while (optindex < argc) {        opt = argv[optindex++];                if (opt[0] == '-' && opt[1] != '\0') {            po = options;            while (po->name != NULL) {                if (!strcmp(opt + 1, po->name))                    break;                po++;            }            if (!po->name) {                fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], opt);                exit(1);            }            arg = NULL;            if (po->flags & HAS_ARG)                arg = argv[optindex++];            if (po->flags & OPT_STRING) {                char *str;                str = strdup(arg);                *po->u.str_arg = str;            } else if (po->flags & OPT_BOOL) {                *po->u.int_arg = 1;            } else {                po->u.func_arg(arg);            }        } else {            if (!do_play) {                opt_output_file(opt);            } else {                opt_input_file(opt);            }        }    }    if (!do_play) {        /* file converter / grab */        if (nb_output_files <= 0) {            fprintf(stderr, "Must supply at least one output file\n");            exit(1);        }                if (nb_input_files == 0) {            prepare_grab();        }    } else {        /* player */        if (nb_input_files <= 0) {            fprintf(stderr, "Must supply at least one input file\n");            exit(1);        }        prepare_play();    }    ti = getutime();    av_encode(output_files, nb_output_files, input_files, nb_input_files,               stream_maps, nb_stream_maps);    ti = getutime() - ti;    if (do_benchmark) {        printf("bench: utime=%0.3fs\n", ti / 1000000.0);    }    /* close files */    for(i=0;i<nb_output_files;i++) {        if (!(output_files[i]->oformat->flags & AVFMT_NOFILE))             url_fclose(&output_files[i]->pb);    }    for(i=0;i<nb_input_files;i++)        av_close_input_file(input_files[i]);    return 0;}