Skip to content
Snippets Groups Projects
ffprobe.c 111 KiB
Newer Older
  • Learn to ignore specific revisions
  •     show_banner(argc, argv, options);
    
        parse_options(NULL, argc, argv, options, opt_input_file);
    
        /* mark things to show, based on -show_entries */
    
        SET_DO_SHOW(CHAPTERS, chapters);
    
        SET_DO_SHOW(ERROR, error);
        SET_DO_SHOW(FORMAT, format);
        SET_DO_SHOW(FRAMES, frames);
        SET_DO_SHOW(LIBRARY_VERSIONS, library_versions);
        SET_DO_SHOW(PACKETS, packets);
    
        SET_DO_SHOW(PIXEL_FORMATS, pixel_formats);
    
        SET_DO_SHOW(PROGRAM_VERSION, program_version);
    
        SET_DO_SHOW(PROGRAMS, programs);
    
        SET_DO_SHOW(STREAMS, streams);
        SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
    
        SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
    
        SET_DO_SHOW(CHAPTER_TAGS, chapter_tags);
        SET_DO_SHOW(FORMAT_TAGS, format_tags);
        SET_DO_SHOW(FRAME_TAGS, frame_tags);
        SET_DO_SHOW(PROGRAM_TAGS, program_tags);
        SET_DO_SHOW(STREAM_TAGS, stream_tags);
    
    
        if (do_bitexact && (do_show_program_version || do_show_library_versions)) {
            av_log(NULL, AV_LOG_ERROR,
                   "-bitexact and -show_program_version or -show_library_versions "
                   "options are incompatible\n");
            ret = AVERROR(EINVAL);
            goto end;
        }
    
    
        writer_register_all();
    
        if (!print_format)
            print_format = av_strdup("default");
    
        if (!print_format) {
            ret = AVERROR(ENOMEM);
            goto end;
        }
    
        w_name = av_strtok(print_format, "=", &buf);
        w_args = buf;
    
    
        if (show_data_hash) {
            if ((ret = av_hash_alloc(&hash, show_data_hash)) < 0) {
                if (ret == AVERROR(EINVAL)) {
                    const char *n;
                    av_log(NULL, AV_LOG_ERROR,
                           "Unknown hash algorithm '%s'\nKnown algorithms:",
                           show_data_hash);
                    for (i = 0; (n = av_hash_names(i)); i++)
                        av_log(NULL, AV_LOG_ERROR, " %s", n);
                    av_log(NULL, AV_LOG_ERROR, "\n");
                }
                goto end;
            }
        }
    
    
        w = writer_get_by_name(w_name);
        if (!w) {
            av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name);
            ret = AVERROR(EINVAL);
            goto end;
    
        if ((ret = writer_open(&wctx, w, w_args,
                               sections, FF_ARRAY_ELEMS(sections))) >= 0) {
    
            if (w == &xml_writer)
                wctx->string_validation_utf8_flags |= AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES;
    
    
            writer_print_section_header(wctx, SECTION_ID_ROOT);
    
            if (do_show_program_version)
                ffprobe_show_program_version(wctx);
            if (do_show_library_versions)
                ffprobe_show_library_versions(wctx);
    
            if (do_show_pixel_formats)
                ffprobe_show_pixel_formats(wctx);
    
                ((do_show_format || do_show_programs || do_show_streams || do_show_chapters || do_show_packets || do_show_error) ||
    
                 (!do_show_program_version && !do_show_library_versions && !do_show_pixel_formats))) {
    
                show_usage();
                av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
                av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
                ret = AVERROR(EINVAL);
    
                ret = probe_file(wctx, input_filename);
    
                if (ret < 0 && do_show_error)
                    show_error(wctx, ret);
            }
    
            writer_print_section_footer(wctx);
    
        av_freep(&read_intervals);
    
        av_hash_freep(&hash);
    
        for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
            av_dict_free(&(sections[i].entries_to_show));
    
        avformat_network_deinit();
    
    
    Stefano Sabatini's avatar
    Stefano Sabatini committed
    }