if (unit == unit_byte_str && use_byte_value_binary_prefix) {
index = (int) (log(val)/log(2)) / 10;
- index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) -1);
- val /= pow(2, index*10);
+ index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) - 1);
+ val /= pow(2, index * 10);
prefix_string = binary_unit_prefixes[index];
} else {
index = (int) (log10(val)) / 3;
- index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) -1);
- val /= pow(10, index*3);
+ index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) - 1);
+ val /= pow(10, index * 3);
prefix_string = decimal_unit_prefixes[index];
}
- snprintf(buf, buf_size, "%.3f %s%s", val, prefix_string, show_value_unit ? unit : "");
+ snprintf(buf, buf_size, "%.3f %s%s", val, prefix_string,
+ show_value_unit ? unit : "");
} else {
snprintf(buf, buf_size, "%f %s", val, show_value_unit ? unit : "");
}
return buf;
}
-static char *time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base)
+static char *time_value_string(char *buf, int buf_size, int64_t val,
+ const AVRational *time_base)
{
if (val == AV_NOPTS_VALUE) {
snprintf(buf, buf_size, "N/A");
AVStream *st = fmt_ctx->streams[pkt->stream_index];
printf("[PACKET]\n");
- printf("codec_type=%s\n" , media_type_string(st->codec->codec_type));
- printf("stream_index=%d\n" , pkt->stream_index);
- printf("pts=%s\n" , ts_value_string (val_str, sizeof(val_str), pkt->pts));
- printf("pts_time=%s\n" , time_value_string(val_str, sizeof(val_str), pkt->pts, &st->time_base));
- printf("dts=%s\n" , ts_value_string (val_str, sizeof(val_str), pkt->dts));
- printf("dts_time=%s\n" , time_value_string(val_str, sizeof(val_str), pkt->dts, &st->time_base));
- printf("duration=%s\n" , ts_value_string (val_str, sizeof(val_str), pkt->duration));
- printf("duration_time=%s\n", time_value_string(val_str, sizeof(val_str), pkt->duration, &st->time_base));
- printf("size=%s\n" , value_string (val_str, sizeof(val_str), pkt->size, unit_byte_str));
- printf("pos=%"PRId64"\n" , pkt->pos);
- printf("flags=%c\n" , pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
+ printf("codec_type=%s\n", media_type_string(st->codec->codec_type));
+ printf("stream_index=%d\n", pkt->stream_index);
+ printf("pts=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->pts));
+ printf("pts_time=%s\n", time_value_string(val_str, sizeof(val_str),
+ pkt->pts, &st->time_base));
+ printf("dts=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->dts));
+ printf("dts_time=%s\n", time_value_string(val_str, sizeof(val_str),
+ pkt->dts, &st->time_base));
+ printf("duration=%s\n", ts_value_string(val_str, sizeof(val_str),
+ pkt->duration));
+ printf("duration_time=%s\n", time_value_string(val_str, sizeof(val_str),
+ pkt->duration,
+ &st->time_base));
+ printf("size=%s\n", value_string(val_str, sizeof(val_str),
+ pkt->size, unit_byte_str));
+ printf("pos=%"PRId64"\n", pkt->pos);
+ printf("flags=%c\n", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
printf("[/PACKET]\n");
}
printf("[STREAM]\n");
- printf("index=%d\n", stream->index);
+ printf("index=%d\n", stream->index);
if ((dec_ctx = stream->codec)) {
if ((dec = dec_ctx->codec)) {
- printf("codec_name=%s\n", dec->name);
- printf("codec_long_name=%s\n", dec->long_name);
+ printf("codec_name=%s\n", dec->name);
+ printf("codec_long_name=%s\n", dec->long_name);
} else {
printf("codec_name=unknown\n");
}
- printf("codec_type=%s\n", media_type_string(dec_ctx->codec_type));
- printf("codec_time_base=%d/%d\n", dec_ctx->time_base.num, dec_ctx->time_base.den);
+ printf("codec_type=%s\n", media_type_string(dec_ctx->codec_type));
+ printf("codec_time_base=%d/%d\n",
+ dec_ctx->time_base.num, dec_ctx->time_base.den);
/* print AVI/FourCC tag */
av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
switch (dec_ctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- printf("width=%d\n", dec_ctx->width);
- printf("height=%d\n", dec_ctx->height);
- printf("has_b_frames=%d\n", dec_ctx->has_b_frames);
+ printf("width=%d\n", dec_ctx->width);
+ printf("height=%d\n", dec_ctx->height);
+ printf("has_b_frames=%d\n", dec_ctx->has_b_frames);
if (dec_ctx->sample_aspect_ratio.num) {
- printf("sample_aspect_ratio=%d:%d\n", dec_ctx->sample_aspect_ratio.num,
- dec_ctx->sample_aspect_ratio.den);
+ printf("sample_aspect_ratio=%d:%d\n",
+ dec_ctx->sample_aspect_ratio.num,
+ dec_ctx->sample_aspect_ratio.den);
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
dec_ctx->width * dec_ctx->sample_aspect_ratio.num,
dec_ctx->height * dec_ctx->sample_aspect_ratio.den,
1024*1024);
- printf("display_aspect_ratio=%d:%d\n", display_aspect_ratio.num,
- display_aspect_ratio.den);
+ printf("display_aspect_ratio=%d:%d\n",
+ display_aspect_ratio.num, display_aspect_ratio.den);
}
- 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);
+ 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:
- printf("sample_rate=%s\n", value_string(val_str, sizeof(val_str),
- dec_ctx->sample_rate,
- unit_hertz_str));
- printf("channels=%d\n", dec_ctx->channels);
- printf("bits_per_sample=%d\n", av_get_bits_per_sample(dec_ctx->codec_id));
+ printf("sample_rate=%s\n", value_string(val_str, sizeof(val_str),
+ dec_ctx->sample_rate,
+ unit_hertz_str));
+ printf("channels=%d\n", dec_ctx->channels);
+ printf("bits_per_sample=%d\n",
+ av_get_bits_per_sample(dec_ctx->codec_id));
break;
}
} else {
if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS)
printf("id=0x%x\n", stream->id);
- 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);
- 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,
- &stream->time_base));
+ 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);
+ 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, &stream->time_base));
if (stream->nb_frames)
- printf("nb_frames=%"PRId64"\n", stream->nb_frames);
+ printf("nb_frames=%"PRId64"\n", stream->nb_frames);
- while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_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");
{
AVDictionaryEntry *tag = NULL;
char val_str[128];
+ int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
printf("[FORMAT]\n");
- printf("filename=%s\n", fmt_ctx->filename);
- printf("nb_streams=%d\n", fmt_ctx->nb_streams);
- printf("format_name=%s\n", fmt_ctx->iformat->name);
+ printf("filename=%s\n", fmt_ctx->filename);
+ printf("nb_streams=%d\n", fmt_ctx->nb_streams);
+ printf("format_name=%s\n", fmt_ctx->iformat->name);
printf("format_long_name=%s\n", fmt_ctx->iformat->long_name);
- printf("start_time=%s\n", time_value_string(val_str, sizeof(val_str), fmt_ctx->start_time,
- &AV_TIME_BASE_Q));
- printf("duration=%s\n", time_value_string(val_str, sizeof(val_str), fmt_ctx->duration,
- &AV_TIME_BASE_Q));
- printf("size=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->file_size,
- unit_byte_str));
- printf("bit_rate=%s\n", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate,
- unit_bit_per_second_str));
-
- while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
+ printf("start_time=%s\n",
+ time_value_string(val_str, sizeof(val_str),
+ fmt_ctx->start_time, &AV_TIME_BASE_Q));
+ printf("duration=%s\n",
+ time_value_string(val_str, sizeof(val_str),
+ fmt_ctx->duration, &AV_TIME_BASE_Q));
+ printf("size=%s\n", size >= 0 ? value_string(val_str, sizeof(val_str),
+ size, unit_byte_str)
+ : "unknown");
+ printf("bit_rate=%s\n",
+ value_string(val_str, sizeof(val_str),
+ fmt_ctx->bit_rate, unit_bit_per_second_str));
+
+ 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");
AVFormatContext *fmt_ctx = NULL;
AVDictionaryEntry *t;
- if ((err = avformat_open_input(&fmt_ctx, filename, iformat, &format_opts)) < 0) {
+ if ((err = avformat_open_input(&fmt_ctx, filename,
+ iformat, &format_opts)) < 0) {
print_error(filename, err);
return err;
}
AVCodec *codec;
if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
- fprintf(stderr, "Unsupported codec with 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_open2(stream->codec, codec, NULL) < 0) {
fprintf(stderr, "Error while opening codec for input stream %d\n",
if (do_show_format)
show_format(fmt_ctx);
- av_close_input_file(fmt_ctx);
+ avformat_close_input(&fmt_ctx);
return 0;
}
static void opt_input_file(void *optctx, const char *arg)
{
if (input_filename) {
- fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
+ fprintf(stderr,
+ "Argument '%s' provided as input filename, but '%s' was already specified.\n",
arg, input_filename);
exit(1);
}
static const OptionDef options[] = {
#include "cmdutils_common_opts.h"
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "format" },
- { "unit", OPT_BOOL, {(void*)&show_value_unit}, "show unit of the displayed values" },
- { "prefix", OPT_BOOL, {(void*)&use_value_prefix}, "use SI prefixes for the displayed values" },
+ { "unit", OPT_BOOL, {(void*)&show_value_unit},
+ "show unit of the displayed values" },
+ { "prefix", OPT_BOOL, {(void*)&use_value_prefix},
+ "use SI prefixes for the displayed values" },
{ "byte_binary_prefix", OPT_BOOL, {(void*)&use_byte_value_binary_prefix},
"use binary prefixes for byte units" },
{ "sexagesimal", OPT_BOOL, {(void*)&use_value_sexagesimal_format},
{ "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", 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, },
};
if (!input_filename) {
show_usage();
fprintf(stderr, "You have to specify one input file.\n");
- fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
+ fprintf(stderr,
+ "Use -h to get full help or, even better, run 'man %s'.\n",
+ program_name);
exit(1);
}