64 static char *
value_string(
char *buf,
int buf_size,
double val,
const char *unit)
70 mins = (int)secs / 60;
71 secs = secs - mins * 60;
74 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
76 const char *prefix_string;
80 index = (int) (log(val)/log(2)) / 10;
82 val /= pow(2, index * 10);
85 index = (int) (log10(val)) / 3;
87 val /= pow(10, index * 3);
91 snprintf(buf, buf_size,
"%.3f %s%s", val, prefix_string,
104 snprintf(buf, buf_size,
"N/A");
115 snprintf(buf, buf_size,
"N/A");
117 snprintf(buf, buf_size,
"%"PRId64, ts);
125 switch (media_type) {
131 default:
return "unknown";
184 if ((dec_ctx = stream->
codec)) {
185 if ((dec = dec_ctx->
codec)) {
189 printf(
"codec_name=unknown\n");
193 printf(
"codec_time_base=%d/%d\n",
198 printf(
"codec_tag_string=%s\n", val_str);
207 printf(
"sample_aspect_ratio=%d:%d\n",
214 printf(
"display_aspect_ratio=%d:%d\n",
215 display_aspect_ratio.
num, display_aspect_ratio.
den);
228 printf(
"bits_per_sample=%d\n",
233 printf(
"codec_type=unknown\n");
238 printf(
"r_frame_rate=%d/%d\n",
240 printf(
"avg_frame_rate=%d/%d\n",
242 printf(
"time_base=%d/%d\n",
324 "Unsupported codec with id %d for input stream %d\n",
327 fprintf(stderr,
"Error while opening codec for input stream %d\n",
332 *fmt_ctx_ptr = fmt_ctx;
360 printf(
"Simple multimedia streams analyzer\n");
369 fprintf(stderr,
"Unknown input format: %s\n", arg);
379 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
383 if (!strcmp(arg,
"-"))
409 "show unit of the displayed values" },
411 "use SI prefixes for the displayed values" },
413 "use binary prefixes for byte units" },
415 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
417 "prettify the format of displayed values, make it more human readable" },
422 "generic catch all option",
"" },
426 int main(
int argc,
char **argv)
443 fprintf(stderr,
"You have to specify one input file.\n");
445 "Use -h to get full help or, even better, run 'man %s'.\n",
static const char * unit_second_str
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
static char * time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base)
int64_t avio_size(AVIOContext *s)
Get the filesize.
int64_t pos
byte position in stream, -1 if unknown
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
void show_banner(void)
Print the program banner to stderr.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int index
stream index in AVFormatContext
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
AVCodec * avcodec_find_decoder(enum CodecID id)
Find a registered decoder with a matching codec ID.
static const OptionDef options[]
static const char * input_filename
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
#define FF_ARRAY_ELEMS(a)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static const char * decimal_unit_prefixes[]
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static void show_help(void)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Opaque data information usually continuous.
static char * ts_value_string(char *buf, int buf_size, int64_t ts)
int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int id
format-specific stream ID
void show_help_options(const OptionDef *options, const char *msg, int mask, int value)
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
static double av_q2d(AVRational a)
Convert rational to double.
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
int avformat_network_init(void)
Do global initialization of network components.
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
int av_get_bits_per_sample(enum CodecID codec_id)
Return codec bits per sample.
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static void show_usage(void)
AVDictionary * format_opts
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Main libavdevice API header.
int has_b_frames
Size of the frame reordering buffer in the decoder.
static int do_show_format
static int opt_format(const char *opt, const char *arg)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
AVRational avg_frame_rate
Average framerate.
int flags
A combination of AV_PKT_FLAG values.
static const char * binary_unit_prefixes[]
AVCodecContext * codec
codec context
static void show_packets(AVFormatContext *fmt_ctx)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned int nb_streams
A list of all streams in the file.
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
static const char * unit_hertz_str
static int use_value_sexagesimal_format
char filename[1024]
input or output filename
int width
picture width / height.
const int program_birth_year
program birth year, defined by the program for show_banner()
Opaque data information usually sparse.
static void opt_input_file(void *optctx, const char *arg)
static char * value_string(char *buf, int buf_size, double val, const char *unit)
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
static void opt_pretty(void)
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
enum AVMediaType codec_type
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int sample_rate
samples per second
static const char * media_type_string(enum AVMediaType media_type)
main external API structure.
static void show_format(AVFormatContext *fmt_ctx)
void exit_program(int ret)
Do all the necessary cleanup and abort.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int use_byte_value_binary_prefix
static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
rational number numerator/denominator
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int main(int argc, char **argv)
static int probe_file(const char *filename)
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
int64_t duration
Decoding: duration of the stream, in stream time base.
const char program_name[]
program name, defined by the program for show_version().
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
static int do_show_streams
static AVInputFormat * iformat
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
int64_t nb_frames
number of frames in this stream if known or 0
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt)
#define AVERROR_OPTION_NOT_FOUND
Option not found.
static int show_value_unit
int channels
number of audio channels
static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
int opt_default(const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions...
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
static const char * unit_bit_per_second_str
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int bit_rate
Decoding: total stream bitrate in bit/s, 0 if not available.
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
static const char * unit_byte_str
#define AV_DICT_IGNORE_SUFFIX
static int do_show_packets
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
AVRational r_frame_rate
Real base framerate of the stream.
static int use_value_prefix
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.