Skip to content
Snippets Groups Projects
ffmpeg.c 61.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Fabrice Bellard's avatar
    Fabrice Bellard committed
            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 */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
            if (nb_output_files <= 0) {
                fprintf(stderr, "Must supply at least one output file\n");
                exit(1);
            }
    
        } 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);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        }
    
        /* close files */
        for(i=0;i<nb_output_files;i++) {
            if (!(output_files[i]->format->flags & AVFMT_NOFILE)) 
                url_fclose(&output_files[i]->pb);
        }
        for(i=0;i<nb_input_files;i++) {
            if (!(input_files[i]->format->flags & AVFMT_NOFILE)) 
                url_fclose(&input_files[i]->pb);
        }
    
        return 0;
    }