105 void (*print_integer) (
const char *key, int64_t value);
106 void (*print_string) (
const char *key,
const char *value);
111 #define AVP_INDENT() avio_printf(probe_out, "%*c", octx.level * 2, ' ')
141 case '\r':
avio_printf(probe_out,
"%s",
"\\r");
break;
142 case '\n':
avio_printf(probe_out,
"%s",
"\\n");
break;
143 case '\f':
avio_printf(probe_out,
"%s",
"\\f");
break;
144 case '\b':
avio_printf(probe_out,
"%s",
"\\b");
break;
145 case '\t':
avio_printf(probe_out,
"%s",
"\\t");
break;
149 case ':' :
avio_w8(probe_out,
'\\');
151 if ((
unsigned char)c < 32)
176 for (i = 1; i < octx.
level; i++) {
255 avio_printf(probe_out,
"\"%s\" : %"PRId64
"", key, value);
265 case '\r':
avio_printf(probe_out,
"%s",
"\\r");
break;
266 case '\n':
avio_printf(probe_out,
"%s",
"\\n");
break;
267 case '\f':
avio_printf(probe_out,
"%s",
"\\f");
break;
268 case '\b':
avio_printf(probe_out,
"%s",
"\\b");
break;
269 case '\t':
avio_printf(probe_out,
"%s",
"\\t");
break;
271 case '"' :
avio_w8(probe_out,
'\\');
273 if ((
unsigned char)c < 32)
301 if (!strcmp(name,
"tags"))
318 if (!strcmp(name,
"tags"))
367 if (!octx.
prefix || !name) {
368 fprintf(stderr,
"Out of memory\n");
438 static void probe_str(
const char *key,
const char *value)
456 static char *
value_string(
char *buf,
int buf_size,
double val,
const char *unit)
462 mins = (int)secs / 60;
463 secs = secs - mins * 60;
466 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
468 const char *prefix_string;
472 index = (int)
log2(val) / 10;
474 val /= pow(2, index * 10);
477 index = (int) (log10(val)) / 3;
479 val /= pow(10, index * 3);
482 snprintf(buf, buf_size,
"%.*f%s%s",
497 snprintf(buf, buf_size,
"N/A");
508 snprintf(buf, buf_size,
"N/A");
510 snprintf(buf, buf_size,
"%"PRId64, ts);
519 snprintf(buf, buf_size,
"%d%s%d", rat->
num, sep, rat->
den);
525 snprintf(buf, buf_size,
"0x%04x", tag);
580 if ((dec_ctx = stream->
codec)) {
581 if ((dec = dec_ctx->
codec)) {
621 &display_aspect_ratio));
728 fprintf(stderr,
"Failed to probe codec for input stream %d\n",
732 "Unsupported codec with id %d for input stream %d\n",
735 fprintf(stderr,
"Error while opening codec for input stream %d\n",
740 *fmt_ctx_ptr = fmt_ctx;
785 printf(
"Simple multimedia streams analyzer\n");
786 printf(
"usage: %s [OPTIONS] [INPUT_FILE]\n",
program_name);
790 static int opt_format(
void *optctx,
const char *opt,
const char *arg)
794 fprintf(stderr,
"Unknown input format: %s\n", arg);
803 if (!strcmp(arg,
"json")) {
813 }
else if (!strcmp(arg,
"ini")) {
821 }
else if (!strcmp(arg,
"old")) {
855 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
859 if (!strcmp(arg,
"-"))
873 static int opt_pretty(
void *optctx,
const char *opt,
const char *arg)
887 "show unit of the displayed values" },
889 "use SI prefixes for the displayed values" },
891 "use binary prefixes for byte units" },
893 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
895 "prettify the format of displayed values, make it more human readable" },
898 "show a particular entry from the format/container info",
"entry" },
902 "generic catch all option",
"" },
908 printf(
"%.*s", buf_size, buf);
912 #define AVP_BUFFSIZE 4096
914 int main(
int argc,
char **argv)
948 fprintf(stderr,
"You have to specify one input file.\n");
950 "Use -h to get full help or, even better, run 'man %s'.\n",
void(* print_object_header)(const char *name)
static void ini_print_integer(const char *key, int64_t value)
codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it ...
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static char * time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base)
void(* print_object_footer)(const char *name)
int64_t avio_size(AVIOContext *s)
Get the filesize.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static void probe_header(void)
static void probe_footer(void)
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.
static void show_format_entry_string(const char *key, const char *value)
static void probe_group_enter(const char *name, int type)
static const char *const binary_unit_prefixes[]
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
static void probe_array_header(const char *name)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const char * input_filename
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
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.
#define FF_ARRAY_ELEMS(a)
static void json_print_integer(const char *key, int64_t value)
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void(* print_array_header)(const char *name)
static void json_print_array_footer(const char *name)
static void probe_int(const char *key, int64_t value)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
static void ini_escape_print(const char *s)
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions...
static char * ts_value_string(char *buf, int buf_size, int64_t ts)
static int opt_format(void *optctx, const char *opt, const char *arg)
static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
int id
Format-specific stream ID.
static const char *const decimal_unit_prefixes[]
static void json_escape_print(const char *s)
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
AVStream ** streams
A list of all streams in the file.
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.
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
static void old_print_object_header(const char *name)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static void show_usage(void)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVDictionary * format_opts
static void probe_dict(AVDictionary *dict, const char *name)
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Main libavdevice API header.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
static void probe_str(const char *key, const char *value)
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
static void json_print_object_footer(const char *name)
static void ini_print_object_header(const char *name)
static void json_print_array_header(const char *name)
static const OptionDef real_options[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int has_b_frames
Size of the frame reordering buffer in the decoder.
static int do_show_format
static AVDictionary * fmt_entries_to_show
static int probe_buf_write(void *opaque, uint8_t *buf, int buf_size)
static void show_format_entry_integer(const char *key, int64_t value)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
static char * tag_string(char *buf, int buf_size, int tag)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
AVRational avg_frame_rate
Average framerate.
int flags
A combination of AV_PKT_FLAG values.
static int nb_fmt_entries_to_show
AVCodecContext * codec
Codec context associated with this stream.
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
Number of elements in AVFormatContext.streams.
void(* print_header)(void)
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
int bit_rate
the average bitrate
int void avio_flush(AVIOContext *s)
static int use_value_sexagesimal_format
char filename[1024]
input or output filename
const char * media_type_string(enum AVMediaType media_type)
Get a string describing a media type.
static void avprobe_cleanup(int ret)
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
void show_help_default(const char *opt, const char *arg)
Per-avtool specific help handler.
int width
picture width / height.
void(* print_string)(const char *key, const char *value)
static void probe_object_header(const char *name)
static const char unit_byte_str[]
const int program_birth_year
program birth year, defined by the program for show_banner()
void(* print_footer)(void)
static void opt_input_file(void *optctx, const char *arg)
static int opt_pretty(void *optctx, const char *opt, const char *arg)
static char * value_string(char *buf, int buf_size, double val, const char *unit)
static const OptionDef * options
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
Libavcodec external API header.
enum AVMediaType codec_type
static const char unit_second_str[]
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
char * av_strdup(const char *s)
Duplicate the string s.
int sample_rate
samples per second
AVIOContext * pb
I/O context.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void avio_w8(AVIOContext *s, int b)
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
static void show_format(AVFormatContext *fmt_ctx)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int use_byte_value_binary_prefix
static void json_print_string(const char *key, const char *value)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Replacements for frequently missing libm functions.
static void old_print_string(const char *key, const char *value)
static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
static const char unit_bit_per_second_str[]
void(* print_integer)(const char *key, int64_t value)
rational number numerator/denominator
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
static void ini_print_string(const char *key, const char *value)
static void json_print_footer(void)
static void ini_print_header(void)
static void json_print_object_header(const char *name)
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)
static AVIOContext * probe_out
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
static void probe_array_footer(const char *name)
int64_t duration
Decoding: duration of the stream, in stream time base.
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
static int opt_output_format(void *optctx, const char *opt, const char *arg)
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 void old_print_object_footer(const char *name)
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
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.
static void probe_group_leave(void)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int64_t nb_frames
number of frames in this stream if known or 0
struct AVInputFormat * iformat
The input container format.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
void(* print_array_footer)(const char *name)
static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt)
static void ini_print_footer(void)
#define AVERROR_OPTION_NOT_FOUND
Option not found.
static void json_print_header(void)
static const char unit_hertz_str[]
static int show_value_unit
int channels
number of audio channels
static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
static void ini_print_array_header(const char *name)
#define AV_DICT_IGNORE_SUFFIX
static void close_input_file(AVFormatContext **ctx_ptr)
static char * rational_string(char *buf, int buf_size, const char *sep, const AVRational *rat)
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...
static int use_value_prefix
static void probe_object_footer(const char *name)
This structure stores compressed data.
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.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2