115 void (*print_array_header) (
const char *
name,
int plain_values);
116 void (*print_array_footer) (
const char *
name,
int plain_values);
120 void (*print_integer) (
const char *key, int64_t value);
121 void (*print_string) (
const char *key,
const char *value);
126 #define AVP_INDENT() avio_printf(probe_out, "%*c", octx.level * 2, ' ') 156 case '\r':
avio_printf(probe_out,
"%s",
"\\r");
break;
157 case '\n':
avio_printf(probe_out,
"%s",
"\\n");
break;
158 case '\f':
avio_printf(probe_out,
"%s",
"\\f");
break;
159 case '\b':
avio_printf(probe_out,
"%s",
"\\b");
break;
160 case '\t':
avio_printf(probe_out,
"%s",
"\\t");
break;
164 case ':' :
avio_w8(probe_out,
'\\');
166 if ((
unsigned char)c < 32)
203 for (i = 1; i < octx.
level; i++) {
306 case '\r':
avio_printf(probe_out,
"%s",
"\\r");
break;
307 case '\n':
avio_printf(probe_out,
"%s",
"\\n");
break;
308 case '\f':
avio_printf(probe_out,
"%s",
"\\f");
break;
309 case '\b':
avio_printf(probe_out,
"%s",
"\\b");
break;
310 case '\t':
avio_printf(probe_out,
"%s",
"\\t");
break;
312 case '"' :
avio_w8(probe_out,
'\\');
314 if ((
unsigned char)c < 32)
342 if (!strcmp(name,
"tags"))
361 if (!strcmp(name,
"tags"))
412 if (!octx.
prefix || !name) {
413 fprintf(stderr,
"Out of memory\n");
483 static void probe_str(
const char *key,
const char *value)
501 static char *
value_string(
char *buf,
int buf_size,
double val,
const char *unit)
507 mins = (int)secs / 60;
508 secs = secs - mins * 60;
511 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
513 const char *prefix_string;
517 index = (int)
log2(val) / 10;
519 val /= pow(2, index * 10);
522 index = (int) (log10(val)) / 3;
524 val /= pow(10, index * 3);
527 snprintf(buf, buf_size,
"%.*f%s%s",
542 snprintf(buf, buf_size,
"N/A");
553 snprintf(buf, buf_size,
"N/A");
555 snprintf(buf, buf_size,
"%"PRId64, ts);
564 snprintf(buf, buf_size,
"%d%s%d", rat->
num, sep, rat->
den);
570 snprintf(buf, buf_size,
"0x%04x", tag);
576 snprintf(buf, buf_size,
"Unknown (%d)", val);
684 &display_aspect_ratio));
763 for (j = 0; j < 9; j++)
856 fprintf(stderr,
"Failed to probe codec for input stream %d\n",
864 "Unsupported codec with id %d for input stream %d\n",
879 fprintf(stderr,
"Error while opening codec for input stream %d\n",
935 printf(
"Simple multimedia streams analyzer\n");
936 printf(
"usage: %s [OPTIONS] [INPUT_FILE]\n",
program_name);
940 static int opt_format(
void *optctx,
const char *opt,
const char *arg)
944 fprintf(stderr,
"Unknown input format: %s\n", arg);
953 if (!strcmp(arg,
"json")) {
963 }
else if (!strcmp(arg,
"ini")) {
972 }
else if (!strcmp(arg,
"old")) {
1006 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
1010 if (!strcmp(arg,
"-"))
1024 static int opt_pretty(
void *optctx,
const char *opt,
const char *arg)
1038 "show unit of the displayed values" },
1040 "use SI prefixes for the displayed values" },
1042 "use binary prefixes for byte units" },
1044 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
1046 "prettify the format of displayed values, make it more human readable" },
1049 "show a particular entry from the format/container info",
"entry" },
1053 "generic catch all option",
"" },
1059 printf(
"%.*s", buf_size, buf);
1063 #define AVP_BUFFSIZE 4096 1100 fprintf(stderr,
"You have to specify one input file.\n");
1102 "Use -h to get full help or, even better, run 'man %s'.\n",
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 ...
enum AVChromaLocation chroma_location
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
enum AVColorTransferCharacteristic color_trc
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static void probe_header(void)
static void probe_footer(void)
static void close_input_file(InputFile *ifile)
int coded_width
Bitstream width / height, may be different from width/height e.g.
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.
AVRational sample_aspect_ratio
Video only.
static void show_format_entry_string(const char *key, const char *value)
static void probe_group_enter(const char *name, int type)
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
static const char *const binary_unit_prefixes[]
static void probe_array_header(const char *name, int plain_values)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
void(* print_string)(const char *key, const char *value)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
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)
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
static void json_print_integer(const char *key, int64_t value)
static void ini_print_array_footer(const char *name, int plain_values)
This struct describes the properties of an encoded stream.
static void probe_int(const char *key, int64_t value)
enum AVColorSpace color_space
const char * av_color_space_name(enum AVColorSpace space)
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)
const char * av_stereo3d_type_name(unsigned int type)
Provide a human-readable name of a given stereo3d type.
static int opt_format(void *optctx, const char *opt, const char *arg)
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
const char * av_color_range_name(enum AVColorRange range)
static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int id
Format-specific stream ID.
static const char *const decimal_unit_prefixes[]
static void json_escape_print(const char *s)
int nb_side_data
The number of elements in the AVStream.side_data array.
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.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
static double av_q2d(AVRational a)
Convert rational to double.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
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)
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)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Main libavdevice API header.
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)
const char * av_chroma_location_name(enum AVChromaLocation location)
static void show_stream(InputFile *ifile, InputStream *ist)
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.
int flags
Additional information about the frame packing.
static int do_show_format
static void json_print_array_footer(const char *name, int plain_values)
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)
enum AVColorPrimaries color_primaries
static char * unknown_string(char *buf, int buf_size, int val)
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. ...
enum AVMediaType codec_type
General type of the encoded data.
enum AVPacketSideDataType type
const char * long_name
A more descriptive name for this codec.
AVRational avg_frame_rate
Average framerate.
int flags
A combination of AV_PKT_FLAG values.
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
static int nb_fmt_entries_to_show
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int bit_rate
The average bitrate of the encoded data (in bits per second).
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
void(* print_integer)(const char *key, int64_t value)
int void avio_flush(AVIOContext *s)
static int use_value_sexagesimal_format
char filename[1024]
input or output filename
static void ini_print_array_header(const char *name, int plain_values)
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.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
void(* print_array_footer)(const char *name, int plain_values)
void show_help_default(const char *opt, const char *arg)
Per-avtool specific help handler.
void(* print_footer)(void)
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
void(* print_object_footer)(const char *name)
static void probe_array_footer(const char *name, int plain_values)
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()
enum AVColorRange color_range
Video only.
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.
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
enum AVStereo3DType type
How views are packed within the video.
Libavcodec external API header.
static const char unit_second_str[]
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
char * av_strdup(const char *s)
Duplicate the string s.
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)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static void show_format(InputFile *ifile)
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 const char unit_bit_per_second_str[]
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
rational number numerator/denominator
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
const char * name
Name of the codec described by this descriptor.
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)
void(* print_object_header)(const char *name)
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
This struct describes the properties of a single codec described by an AVCodecID. ...
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. ...
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
static int opt_output_format(void *optctx, const char *opt, const char *arg)
void(* print_array_header)(const char *name, int plain_values)
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
void(* print_header)(void)
static void old_print_object_footer(const char *name)
static void json_print_array_header(const char *name, int plain_values)
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.
int profile
Codec-specific bitstream restrictions that the stream conforms to.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
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
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
struct AVInputFormat * iformat
The input container format.
double av_display_rotation_get(const int32_t matrix[9])
The display transformation matrix specifies an affine transformation that should be applied to video ...
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
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
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...
static void * av_mallocz_array(size_t nmemb, size_t size)
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.
#define AV_DICT_IGNORE_SUFFIX
AVCodecParameters * codecpar
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
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)
static void show_packets(InputFile *ifile)
This structure stores compressed data.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int open_input_file(InputFile *ifile, const char *filename)
#define AV_NOPTS_VALUE
Undefined timestamp value.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2