X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffprobe.c;h=28c954daaef42080f32ad0ce63f21b905359c0e0;hb=b00e56bec5f8aea788f3565cec09bcfea0aa4a53;hp=98c4a4987c1df00a986980740bbf01fed7a79e9f;hpb=5d199c3ad985eab4500cbfd2d1146ac70197ceac;p=ffmpeg diff --git a/ffprobe.c b/ffprobe.c index 98c4a4987c1..28c954daaef 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1904,52 +1904,55 @@ static int probe_file(WriterContext *wctx, const char *filename) do_read_packets = do_show_packets || do_count_packets; ret = open_input_file(&fmt_ctx, filename); - if (ret >= 0) { - nb_streams_frames = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames)); - nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets)); - selected_streams = av_calloc(fmt_ctx->nb_streams, sizeof(*selected_streams)); - - for (i = 0; i < fmt_ctx->nb_streams; i++) { - if (stream_specifier) { - ret = avformat_match_stream_specifier(fmt_ctx, - fmt_ctx->streams[i], - stream_specifier); - if (ret < 0) - goto end; - else - selected_streams[i] = ret; - } else { - selected_streams[i] = 1; - } - } + if (ret < 0) + return ret; + + nb_streams_frames = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames)); + nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets)); + selected_streams = av_calloc(fmt_ctx->nb_streams, sizeof(*selected_streams)); - if (do_read_frames || do_read_packets) { - if (do_show_frames && do_show_packets && - wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER) - section_id = SECTION_ID_PACKETS_AND_FRAMES; - else if (do_show_packets && !do_show_frames) - section_id = SECTION_ID_PACKETS; - else // (!do_show_packets && do_show_frames) - section_id = SECTION_ID_FRAMES; - if (do_show_frames || do_show_packets) - writer_print_section_header(wctx, section_id); - read_packets(wctx, fmt_ctx); - if (do_show_frames || do_show_packets) - writer_print_section_footer(wctx); + for (i = 0; i < fmt_ctx->nb_streams; i++) { + if (stream_specifier) { + ret = avformat_match_stream_specifier(fmt_ctx, + fmt_ctx->streams[i], + stream_specifier); + if (ret < 0) + goto end; + else + selected_streams[i] = ret; + ret = 0; + } else { + selected_streams[i] = 1; } - if (do_show_streams) - show_streams(wctx, fmt_ctx); - if (do_show_chapters) - show_chapters(wctx, fmt_ctx); - if (do_show_format) - show_format(wctx, fmt_ctx); - - end: - close_input_file(&fmt_ctx); - av_freep(&nb_streams_frames); - av_freep(&nb_streams_packets); - av_freep(&selected_streams); } + + if (do_read_frames || do_read_packets) { + if (do_show_frames && do_show_packets && + wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER) + section_id = SECTION_ID_PACKETS_AND_FRAMES; + else if (do_show_packets && !do_show_frames) + section_id = SECTION_ID_PACKETS; + else // (!do_show_packets && do_show_frames) + section_id = SECTION_ID_FRAMES; + if (do_show_frames || do_show_packets) + writer_print_section_header(wctx, section_id); + read_packets(wctx, fmt_ctx); + if (do_show_frames || do_show_packets) + writer_print_section_footer(wctx); + } + if (do_show_streams) + show_streams(wctx, fmt_ctx); + if (do_show_chapters) + show_chapters(wctx, fmt_ctx); + if (do_show_format) + show_format(wctx, fmt_ctx); + +end: + close_input_file(&fmt_ctx); + av_freep(&nb_streams_frames); + av_freep(&nb_streams_packets); + av_freep(&selected_streams); + return ret; } @@ -2356,5 +2359,5 @@ end: avformat_network_deinit(); - return ret; + return ret < 0; }