Skip to content
Snippets Groups Projects
ffmpeg.c 143 KiB
Newer Older
  • Learn to ignore specific revisions
  • Fabrice Bellard's avatar
    Fabrice Bellard committed
        { NULL, },
    };
    
    
    static void show_banner(void)
    {
    
        fprintf(stderr, "FFmpeg version " FFMPEG_VERSION ", Copyright (c) 2000-2004 Fabrice Bellard\n");
        fprintf(stderr, "  configuration: " FFMPEG_CONFIGURATION "\n");
    
        fprintf(stderr, "  libavutil version: " AV_STRINGIFY(LIBAVUTIL_VERSION) "\n");
    
        fprintf(stderr, "  libavcodec version: " AV_STRINGIFY(LIBAVCODEC_VERSION) "\n");
        fprintf(stderr, "  libavformat version: " AV_STRINGIFY(LIBAVFORMAT_VERSION) "\n");
    
        fprintf(stderr, "  built on " __DATE__ " " __TIME__);
    
        fprintf(stderr, ", gcc: " __VERSION__ "\n");
    
        fprintf(stderr, ", using a non-gcc compiler\n");
    
    }
    
    static void show_license(void)
    {
        show_banner();
    
        "This program is free software; you can redistribute it and/or modify\n"
    
        "it under the terms of the GNU General Public License as published by\n"
        "the Free Software Foundation; either version 2 of the License, or\n"
        "(at your option) any later version.\n"
        "\n"
        "This program is distributed in the hope that it will be useful,\n"
        "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
        "GNU General Public License for more details.\n"
        "\n"
        "You should have received a copy of the GNU General Public License\n"
        "along with this program; if not, write to the Free Software\n"
    
        "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n"
    
        "This library is free software; you can redistribute it and/or\n"
        "modify it under the terms of the GNU Lesser General Public\n"
        "License as published by the Free Software Foundation; either\n"
        "version 2 of the License, or (at your option) any later version.\n"
        "\n"
        "This library is distributed in the hope that it will be useful,\n"
        "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n"
        "Lesser General Public License for more details.\n"
        "\n"
        "You should have received a copy of the GNU Lesser General Public\n"
        "License along with this library; if not, write to the Free Software\n"
    
        "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
    
        exit(1);
    }
    
    static void show_help(void)
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        printf("usage: ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...\n"
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
               "Hyper fast Audio and Video encoder\n");
        printf("\n");
    
        show_help_options(options, "Main options:\n",
                          OPT_EXPERT | OPT_AUDIO | OPT_VIDEO, 0);
        show_help_options(options, "\nVideo options:\n",
    
                          OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
    
                          OPT_VIDEO);
        show_help_options(options, "\nAdvanced Video options:\n",
    
                          OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
    
                          OPT_VIDEO | OPT_EXPERT);
        show_help_options(options, "\nAudio options:\n",
    
                          OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
    
                          OPT_AUDIO);
        show_help_options(options, "\nAdvanced Audio options:\n",
    
                          OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
    
                          OPT_AUDIO | OPT_EXPERT);
    
        show_help_options(options, "\nSubtitle options:\n",
    
                          OPT_SUBTITLE | OPT_GRAB,
    
        show_help_options(options, "\nAudio/Video grab options:\n",
    
                          OPT_GRAB);
        show_help_options(options, "\nAdvanced options:\n",
    
                          OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_GRAB,
    
    Michael Niedermayer's avatar
    Michael Niedermayer committed
        av_opt_show(avctx_opts, NULL);
    
        av_opt_show(avformat_opts, NULL);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        exit(1);
    }
    
    void parse_arg_file(const char *filename)
    {
        opt_output_file(filename);
    }
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    int main(int argc, char **argv)
    {
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        int i;
    
        int64_t ti;
    
        avctx_opts= avcodec_alloc_context();
    
        avformat_opts = av_alloc_format_context();
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
        if (argc <= 1)
            show_help();
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        parse_options(argc, argv, options);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        /* file converter / grab */
        if (nb_output_files <= 0) {
            fprintf(stderr, "Must supply at least one output file\n");
            exit(1);
        }
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        if (nb_input_files == 0) {
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
            prepare_grab();
    
        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++) {
    
            /* maybe av_close_output_file ??? */
            AVFormatContext *s = output_files[i];
    
            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);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        }
    
        for(i=0;i<nb_input_files;i++)
            av_close_input_file(input_files[i]);
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
    
    
        if(intra_matrix)
            av_free(intra_matrix);
        if(inter_matrix)
            av_free(inter_matrix);
    
        extern void powerpc_display_perf_report(void);
        powerpc_display_perf_report();
    
    #endif /* POWERPC_PERFORMANCE_REPORT */
    
        if (received_sigterm) {
            fprintf(stderr,
                "Received signal %d: terminating.\n",
                (int) received_sigterm);
            exit (255);
        }
    #endif
        exit(0); /* not all OS-es handle main() return value */
    
    Fabrice Bellard's avatar
    Fabrice Bellard committed
        return 0;
    }