X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=ffprobe.c;h=2457b063a5a2723b9c055ca2d01ff120fafddca7;hb=ab3d241be17ac376f0dfdbbce0e4ce2c319c6eea;hp=9625a52d9d090788d64e7cba9facdfdc363be6f3;hpb=a7e5a832c4839f83ea270886f7400efb56307f6e;p=coroid%2Flibav_saccubus.git diff --git a/ffprobe.c b/ffprobe.c index 9625a52d9..2457b063a 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1,21 +1,21 @@ /* - * FFprobe : Simple Media Prober based on the FFmpeg libraries + * ffprobe : Simple Media Prober based on the Libav libraries * Copyright (c) 2007-2010 Stefano Sabatini * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -23,12 +23,13 @@ #include "libavformat/avformat.h" #include "libavcodec/avcodec.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/dict.h" #include "libavdevice/avdevice.h" #include "cmdutils.h" -const char program_name[] = "FFprobe"; +const char program_name[] = "ffprobe"; const int program_birth_year = 2007; static int do_show_format = 0; @@ -160,7 +161,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) AVCodecContext *dec_ctx; AVCodec *dec; char val_str[128]; - AVMetadataTag *tag = NULL; + AVDictionaryEntry *tag = NULL; AVRational display_aspect_ratio; printf("[STREAM]\n"); @@ -200,6 +201,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) } printf("pix_fmt=%s\n", dec_ctx->pix_fmt != PIX_FMT_NONE ? av_pix_fmt_descriptors[dec_ctx->pix_fmt].name : "unknown"); + printf("level=%d\n", dec_ctx->level); break; case AVMEDIA_TYPE_AUDIO: @@ -219,8 +221,6 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) printf("r_frame_rate=%d/%d\n", stream->r_frame_rate.num, stream->r_frame_rate.den); printf("avg_frame_rate=%d/%d\n", stream->avg_frame_rate.num, stream->avg_frame_rate.den); printf("time_base=%d/%d\n", stream->time_base.num, stream->time_base.den); - if (stream->language[0]) - printf("language=%s\n", stream->language); printf("start_time=%s\n", time_value_string(val_str, sizeof(val_str), stream->start_time, &stream->time_base)); printf("duration=%s\n", time_value_string(val_str, sizeof(val_str), stream->duration, @@ -228,7 +228,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) if (stream->nb_frames) printf("nb_frames=%"PRId64"\n", stream->nb_frames); - while ((tag = av_metadata_get(stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) + while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) printf("TAG:%s=%s\n", tag->key, tag->value); printf("[/STREAM]\n"); @@ -236,7 +236,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) static void show_format(AVFormatContext *fmt_ctx) { - AVMetadataTag *tag = NULL; + AVDictionaryEntry *tag = NULL; char val_str[128]; printf("[FORMAT]\n"); @@ -254,7 +254,7 @@ static void show_format(AVFormatContext *fmt_ctx) printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str)); - while ((tag = av_metadata_get(fmt_ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) + while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) printf("TAG:%s=%s\n", tag->key, tag->value); printf("[/FORMAT]\n"); @@ -263,15 +263,18 @@ static void show_format(AVFormatContext *fmt_ctx) static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) { int err, i; - AVFormatContext *fmt_ctx; - - fmt_ctx = avformat_alloc_context(); - set_context_opts(fmt_ctx, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL); + AVFormatContext *fmt_ctx = NULL; + AVDictionaryEntry *t; - if ((err = av_open_input_file(&fmt_ctx, filename, iformat, 0, NULL)) < 0) { + if ((err = avformat_open_input(&fmt_ctx, filename, iformat, &format_opts)) < 0) { print_error(filename, err); return err; } + if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + return AVERROR_OPTION_NOT_FOUND; + } + /* fill the streams in the format context */ if ((err = av_find_stream_info(fmt_ctx)) < 0) { @@ -279,7 +282,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) return err; } - dump_format(fmt_ctx, 0, filename, 0); + av_dump_format(fmt_ctx, 0, filename, 0); /* bind a decoder to each input stream */ for (i = 0; i < fmt_ctx->nb_streams; i++) { @@ -287,9 +290,9 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) AVCodec *codec; if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { - fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n", + fprintf(stderr, "Unsupported codec with id %d for input stream %d\n", stream->codec->codec_id, stream->index); - } else if (avcodec_open(stream->codec, codec) < 0) { + } else if (avcodec_open2(stream->codec, codec, NULL) < 0) { fprintf(stderr, "Error while opening codec for input stream %d\n", stream->index); } @@ -328,13 +331,14 @@ static void show_usage(void) printf("\n"); } -static void opt_format(const char *arg) +static int opt_format(const char *opt, const char *arg) { iformat = av_find_input_format(arg); if (!iformat) { fprintf(stderr, "Unknown input format: %s\n", arg); - exit(1); + return AVERROR(EINVAL); } + return 0; } static void opt_input_file(const char *arg) @@ -381,7 +385,7 @@ static const OptionDef options[] = { { "show_format", OPT_BOOL, {(void*)&do_show_format} , "show format/container info" }, { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" }, { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" }, - { "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" }, + { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" }, { NULL, }, }; @@ -390,6 +394,7 @@ int main(int argc, char **argv) int ret; av_register_all(); + init_opts(); #if CONFIG_AVDEVICE avdevice_register_all(); #endif