31 #include "libavformat/avformat.h"
32 #include "libavcodec/avcodec.h"
33 #include "libavutil/avassert.h"
34 #include "libavutil/avstring.h"
35 #include "libavutil/bprint.h"
36 #include "libavutil/opt.h"
37 #include "libavutil/pixdesc.h"
38 #include "libavutil/dict.h"
40 #include "libavutil/parseutils.h"
41 #include "libavutil/timecode.h"
42 #include "libavutil/timestamp.h"
43 #include "libavdevice/avdevice.h"
44 #include "libswscale/swscale.h"
45 #include "libswresample/swresample.h"
46 #include "libpostproc/postprocess.h"
91 #define SECTION_MAX_NB_CHILDREN 10
97 #define SECTION_FLAG_IS_WRAPPER 1
98 #define SECTION_FLAG_IS_ARRAY 2
99 #define SECTION_FLAG_HAS_VARIABLE_FIELDS 4
198 union {
double d;
long long int i; }
val;
212 vald = vali = uv.
val.
i;
219 mins = (int)secs / 60;
220 secs = secs - mins * 60;
223 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
225 const char *prefix_string =
"";
231 index = (
long long int) (
log2(vald)) / 10;
233 vald /=
exp2(index * 10);
236 index = (
long long int) (log10(vald)) / 3;
238 vald /= pow(10, index * 3);
244 snprintf(buf, buf_size,
"%f", vald);
246 snprintf(buf, buf_size,
"%lld", vali);
258 #define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS 1
259 #define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER 2
277 #define SECTION_MAX_NB_LEVELS 10
323 if ((*wctx)->writer->uninit)
324 (*wctx)->writer->uninit(*wctx);
327 if ((*wctx)->writer->priv_class)
334 const struct section *sections,
int nb_sections)
349 (*wctx)->writer = writer;
352 (*wctx)->nb_sections = nb_sections;
355 void *priv_ctx = (*wctx)->priv;
367 if ((*wctx)->writer->init)
368 ret = (*wctx)->writer->init(*wctx);
382 int parent_section_id;
385 parent_section_id = wctx->
level ?
406 int parent_section_id = wctx->
level ?
421 const char *key,
long long int val)
432 const char *key,
const char *
val,
int opt)
455 int64_t ts,
const AVRational *time_base,
int is_duration)
459 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
462 double d = ts *
av_q2d(*time_base);
473 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
491 for (i = 0; i < l; i++) {
497 for (i = 0; i < l; i++)
508 #define MAX_REGISTERED_WRITERS_NB 64
514 static int next_registered_writer_idx = 0;
519 registered_writers[next_registered_writer_idx++] = writer;
527 for (i = 0; registered_writers[
i]; i++)
528 if (!strcmp(registered_writers[i]->name, name))
529 return registered_writers[
i];
537 #define DEFINE_WRITER_CLASS(name) \
538 static const char *name##_get_name(void *ctx) \
542 static const AVClass name##_class = { \
557 #define OFFSET(x) offsetof(DefaultContext, x)
560 {
"noprint_wrappers",
"do not print headers and footers",
OFFSET(noprint_wrappers),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1 },
561 {
"nw",
"do not print headers and footers",
OFFSET(noprint_wrappers),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1 },
573 for (i = 0; src[i] && i < dst_size-1; i++)
584 const struct section *parent_section = wctx->
level ?
588 if (parent_section &&
623 printf(
"%s\n", value);
632 printf(
"%lld\n", value);
643 .priv_class = &default_class,
655 for (p = src; *p; p++) {
657 case '\b':
av_bprintf(dst,
"%s",
"\\b");
break;
658 case '\f':
av_bprintf(dst,
"%s",
"\\f");
break;
659 case '\n':
av_bprintf(dst,
"%s",
"\\n");
break;
660 case '\r':
av_bprintf(dst,
"%s",
"\\r");
break;
661 case '\\':
av_bprintf(dst,
"%s",
"\\\\");
break;
676 char meta_chars[] = { sep,
'"',
'\n',
'\r',
'\0' };
677 int needs_quoting = !!src[strcspn(src, meta_chars)];
682 for (; *
src; src++) {
704 const char * (*escape_str)(
AVBPrint *dst,
const char *
src,
const char sep,
void *log_ctx);
711 #define OFFSET(x) offsetof(CompactContext, x)
732 av_log(wctx,
AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
753 const struct section *parent_section = wctx->
level ?
809 printf(
"%lld", value);
821 .priv_class = &compact_class,
827 #define OFFSET(x) offsetof(CompactContext, x)
852 .priv_class = &csv_class,
865 #define OFFSET(x) offsetof(FlatContext, x)
870 {
"hierarchical",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1 },
871 {
"h",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1 },
881 if (strlen(flat->
sep_str) != 1) {
882 av_log(wctx,
AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
895 for (p = src; *p; p++) {
896 if (!((*p >=
'0' && *p <=
'9') ||
897 (*p >=
'a' && *p <=
'z') ||
898 (*p >=
'A' && *p <=
'Z')))
910 for (p = src; *p; p++) {
912 case '\n':
av_bprintf(dst,
"%s",
"\\n");
break;
913 case '\r':
av_bprintf(dst,
"%s",
"\\r");
break;
914 case '\\':
av_bprintf(dst,
"%s",
"\\\\");
break;
915 case '"':
av_bprintf(dst,
"%s",
"\\\"");
break;
916 case '`':
av_bprintf(dst,
"%s",
"\\`");
break;
917 case '$':
av_bprintf(dst,
"%s",
"\\$");
break;
929 const struct section *parent_section = wctx->
level ?
976 .priv_class = &flat_class,
987 #define OFFSET(x) offsetof(INIContext, x)
990 {
"hierarchical",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1 },
991 {
"h",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1 },
1002 while (c = src[i++]) {
1004 case '\b':
av_bprintf(dst,
"%s",
"\\b");
break;
1005 case '\f':
av_bprintf(dst,
"%s",
"\\f");
break;
1006 case '\n':
av_bprintf(dst,
"%s",
"\\n");
break;
1007 case '\r':
av_bprintf(dst,
"%s",
"\\r");
break;
1008 case '\t':
av_bprintf(dst,
"%s",
"\\t");
break;
1014 if ((
unsigned char)c < 32)
1029 const struct section *parent_section = wctx->
level ?
1033 if (!parent_section) {
1034 printf(
"# ffprobe output\n\n");
1054 printf(
"[%s]\n", buf->str);
1070 printf(
"%s=%lld\n", key, value);
1080 .priv_class = &ini_class,
1093 #define OFFSET(x) offsetof(JSONContext, x)
1115 static const char json_escape[] = {
'"',
'\\',
'\b',
'\f',
'\n',
'\r',
'\t', 0};
1116 static const char json_subst[] = {
'"',
'\\',
'b',
'f',
'n',
'r',
't', 0};
1119 for (p = src; *p; p++) {
1120 char *
s = strchr(json_escape, *p);
1124 }
else if ((
unsigned char)*p < 32) {
1133 #define JSON_INDENT() printf("%*c", json->indent_level * 4, ' ')
1140 const struct section *parent_section = wctx->
level ?
1156 printf(
"\"%s\": [\n", buf.str);
1166 printf(
"\"type\": \"%s\"%s", section->
name, json->
item_sep);
1178 if (wctx->
level == 0) {
1196 const char *key,
const char *
value)
1242 .priv_class = &json_class,
1256 #define OFFSET(x) offsetof(XMLContext, x)
1259 {
"fully_qualified",
"specify if the output should be fully qualified",
OFFSET(fully_qualified),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1 },
1260 {
"q",
"specify if the output should be fully qualified",
OFFSET(fully_qualified),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1 },
1261 {
"xsd_strict",
"ensure that the output is XSD compliant",
OFFSET(xsd_strict),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1 },
1262 {
"x",
"ensure that the output is XSD compliant",
OFFSET(xsd_strict),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1 },
1274 #define CHECK_COMPLIANCE(opt, opt_name) \
1276 av_log(wctx, AV_LOG_ERROR, \
1277 "XSD-compliant output selected but option '%s' was selected, XML output may be non-compliant.\n" \
1278 "You need to disable such option with '-no%s'\n", opt_name, opt_name); \
1279 return AVERROR(EINVAL); \
1287 "Interleaved frames and packets are not allowed in XSD. "
1288 "Select only one between the -show_frames and the -show_packets options.\n");
1300 for (p = src; *p; p++) {
1302 case '&' :
av_bprintf(dst,
"%s",
"&");
break;
1303 case '<' :
av_bprintf(dst,
"%s",
"<");
break;
1304 case '>' :
av_bprintf(dst,
"%s",
">");
break;
1305 case '"' :
av_bprintf(dst,
"%s",
""");
break;
1306 case '\'':
av_bprintf(dst,
"%s",
"'");
break;
1314 #define XML_INDENT() printf("%*c", xml->indent_level * 4, ' ')
1320 const struct section *parent_section = wctx->
level ?
1323 if (wctx->
level == 0) {
1324 const char *qual =
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
1325 "xmlns:ffprobe='http://www.ffmpeg.org/schema/ffprobe' "
1326 "xsi:schemaLocation='http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd'";
1328 printf(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1329 printf(
"<%sffprobe%s>\n",
1361 if (wctx->
level == 0) {
1385 printf(
"<%s key=\"%s\"",
1402 printf(
"%s=\"%lld\"", key, value);
1414 .priv_class = &xml_class,
1419 static int initialized;
1434 #define print_fmt(k, f, ...) do { \
1435 av_bprint_clear(&pbuf); \
1436 av_bprintf(&pbuf, f, __VA_ARGS__); \
1437 writer_print_string(w, k, pbuf.str, 0); \
1440 #define print_int(k, v) writer_print_integer(w, k, v)
1441 #define print_q(k, v, s) writer_print_rational(w, k, v, s)
1442 #define print_str(k, v) writer_print_string(w, k, v, 0)
1443 #define print_str_opt(k, v) writer_print_string(w, k, v, 1)
1444 #define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
1445 #define print_ts(k, v) writer_print_ts(w, k, v, 0)
1446 #define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
1447 #define print_duration_ts(k, v) writer_print_ts(w, k, v, 1)
1448 #define print_val(k, v, u) do { \
1449 struct unit_value uv; \
1452 writer_print_string(w, k, value_string(val_str, sizeof(val_str), uv), 0); \
1455 #define print_section_header(s) writer_print_section_header(w, s)
1456 #define print_section_footer(s) writer_print_section_footer(w, s)
1541 print_q(
"sample_aspect_ratio", sar,
':');
1581 int ret = 0, got_frame = 0;
1584 if (dec_ctx->
codec) {
1611 av_log(log_ctx, log_level,
"id:%d", interval->
id);
1617 av_log(log_ctx, log_level,
" start:N/A");
1623 av_log(log_ctx, log_level,
"#%"PRId64, interval->
end);
1627 av_log(log_ctx, log_level,
" end:N/A");
1630 av_log(log_ctx, log_level,
"\n");
1652 "Could not seek to relative position since current "
1653 "timestamp is not defined\n");
1657 target = *cur_ts + interval->
start;
1659 target = interval->
start;
1684 end = start + interval->
end;
1691 }
else if (has_end && *cur_ts !=
AV_NOPTS_VALUE && *cur_ts >= end) {
1759 if ((dec_ctx = stream->
codec)) {
1760 const char *profile = NULL;
1761 dec = dec_ctx->
codec;
1797 print_q(
"sample_aspect_ratio", sar,
':');
1802 print_q(
"display_aspect_ratio", dar,
':');
1856 if (opt->
flags)
continue;
1886 #define PRINT_DISPOSITION(flagname, name) do { \
1887 print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
2014 const char *errbuf_ptr = errbuf;
2027 int err, i, orig_nb_streams;
2050 for (i = 0; i < orig_nb_streams; i++)
2063 "Failed to probe codec for input stream %d\n",
2067 "Unsupported codec with id %d for input stream %d\n",
2071 fmt_ctx, stream, codec);
2179 print_fmt(
"copyright",
"Copyright (c) %d-%d the FFmpeg developers",
2190 #define SHOW_LIB_VERSION(libname, LIBNAME) \
2192 if (CONFIG_##LIBNAME) { \
2193 unsigned int version = libname##_version(); \
2194 writer_print_section_header(w, SECTION_ID_LIBRARY_VERSION); \
2195 print_str("name", "lib" #libname); \
2196 print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
2197 print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
2198 print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
2199 print_int("version", version); \
2200 print_str("ident", LIB##LIBNAME##_IDENT); \
2201 writer_print_section_footer(w); \
2235 if (show_all_entries) {
2251 if (!strcmp(section_name, section->
name) ||
2254 "'%s' matches section with unique name '%s'\n", section_name,
2265 const char *p =
arg;
2273 if (!section_name) {
2275 "Missing section name for option '%s'\n", opt);
2281 while (*p && *p !=
':') {
2286 "Adding '%s' to the entries to show in section '%s'\n",
2287 entry, section_name);
2293 show_all_entries = 1;
2296 ret =
match_section(section_name, show_all_entries, entries);
2319 "Option '%s' is deprecated, use '-show_entries format=%s' instead\n",
2330 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
2334 if (!strcmp(arg,
"-"))
2364 char *next, *p, *spec =
av_strdup(interval_spec);
2375 next = strchr(spec,
'%');
2417 lli = strtoll(p, &tail, 10);
2418 if (*tail || lli < 0) {
2420 "Invalid or negative value '%s' for duration number of frames\n", p);
2423 interval->
end = lli;
2444 char *p, *spec =
av_strdup(intervals_spec);
2449 for (n = 0, p = spec; *p; p++)
2454 read_intervals =
av_malloc(n *
sizeof(*read_intervals));
2455 if (!read_intervals) {
2463 for (i = 0; p; i++) {
2467 next = strchr(p,
',');
2471 read_intervals[i].
id = i;
2511 printf(
"%*c %s", level * 4,
' ', section->
name);
2522 printf(
"Sections:\n"
2523 "W.. = Section is a wrapper (contains other sections, no local entries)\n"
2524 ".A. = Section contains an array of elements of the same type\n"
2525 "..V = Section may contain a variable number of fields with variable keys\n"
2526 "FLAGS NAME/UNIQUE_NAME\n"
2539 #define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
2540 static int opt_show_##section(const char *opt, const char *arg) \
2542 mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL); \
2562 "use binary prefixes for byte units" },
2564 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
2566 "prettify the format of displayed values, make it more human readable" },
2568 "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)",
"format" },
2571 {
"sections",
OPT_EXIT, {.func_arg =
opt_sections},
"print sections structure and section information, and exit" },
2573 {
"show_error", 0, {(
void*)&opt_show_error},
"show probing error" },
2574 {
"show_format", 0, {(
void*)&opt_show_format},
"show format/container info" },
2575 {
"show_frames", 0, {(
void*)&opt_show_frames},
"show frames info" },
2577 "show a particular entry from the format/container info",
"entry" },
2579 "show a set of specified entries",
"entry_list" },
2580 {
"show_packets", 0, {(
void*)&opt_show_packets},
"show packets info" },
2581 {
"show_programs", 0, {(
void*)&opt_show_programs},
"show programs info" },
2582 {
"show_streams", 0, {(
void*)&opt_show_streams},
"show streams info" },
2583 {
"show_chapters", 0, {(
void*)&opt_show_chapters},
"show chapters info" },
2586 {
"show_program_version", 0, {(
void*)&opt_show_program_version},
"show ffprobe version" },
2587 {
"show_library_versions", 0, {(
void*)&opt_show_library_versions},
"show library versions" },
2588 {
"show_versions", 0, {(
void*)&
opt_show_versions},
"show program and library versions" },
2610 #define SET_DO_SHOW(id, varname) do { \
2611 if (check_section_show_entries(SECTION_ID_##id)) \
2612 do_show_##varname = 1; \
2620 char *w_name = NULL, *w_args = NULL;
2648 SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
2649 SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
2653 "-bitexact and -show_program_version or -show_library_versions "
2654 "options are incompatible\n");
unsigned int nb_chapters
Number of chapters in AVChapter array.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
int(* init)(WriterContext *wctx)
codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it ...
const char const char void * val
static char * value_string(char *buf, int buf_size, struct unit_value uv)
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
number of the item printed in the given section, starting from 0
void * av_calloc(size_t nmemb, size_t size) av_malloc_attrib
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
int nested_section[SECTION_MAX_NB_LEVELS]
void av_free_packet(AVPacket *pkt)
Free a packet.
This structure describes decoded (raw) audio or video data.
static void json_print_int(WriterContext *wctx, const char *key, long long int value)
static void default_print_section_header(WriterContext *wctx)
static int writer_register(const Writer *writer)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
static int opt_format(void *optctx, const char *opt, const char *arg)
#define SHOW_LIB_VERSION(libname, LIBNAME)
static void writer_print_rational(WriterContext *wctx, const char *key, AVRational q, char sep)
void(* print_string)(WriterContext *wctx, const char *, const char *)
static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
static const char unit_hertz_str[]
#define AV_LOG_WARNING
Something somehow does not look correct.
static const char *const decimal_unit_prefixes[]
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define LIBAVUTIL_VERSION_INT
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.
static const char * xml_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
static void json_print_section_footer(WriterContext *wctx)
static void writer_close(WriterContext **wctx)
static av_cold int init(AVCodecContext *avctx)
static int read_intervals_nb
static void writer_print_integer(WriterContext *wctx, const char *key, long long int val)
static char * ini_escape_str(AVBPrint *dst, const char *src)
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio...
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
static char * print_format
AVCodecContext * codec
Codec context associated with this stream.
static const Writer json_writer
int repeat_pict
When decoding, this signals how much the picture must be delayed.
int index
stream index in AVFormatContext
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
#define print_str_opt(k, v)
void(* print_integer)(WriterContext *wctx, const char *, long long int)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static void close_input_file(AVFormatContext **ctx_ptr)
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const AVClass writer_class
static int do_show_packets
static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, const struct section *sections, int nb_sections)
void(* uninit)(WriterContext *wctx)
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.
static void json_print_item_str(WriterContext *wctx, const char *key, const char *value)
static const Writer default_writer
static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, AVFormatContext *fmt_ctx)
static const char * json_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
static void xml_print_section_footer(WriterContext *wctx)
static void mark_section_show_entries(SectionID section_id, int show_all_entries, AVDictionary *entries)
static uint64_t * nb_streams_frames
static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, int in_program)
int has_nested_elems[SECTION_MAX_NB_LEVELS]
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
static int do_count_frames
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define SECTION_MAX_NB_LEVELS
static const AVOption default_options[]
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() and children.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char *(* escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
unsigned int nb_stream_indexes
const char * element_name
name of the contained element, if provided
static void writer_print_section_header(WriterContext *wctx, int section_id)
static void compact_print_section_footer(WriterContext *wctx)
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
struct section * section[SECTION_MAX_NB_LEVELS]
section per each level
unsigned int nb_section_packet
number of the packet section in case we are in "packets_and_frames" section
static void ini_print_section_header(WriterContext *wctx)
#define print_duration_ts(k, v)
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
enum AVSampleFormat sample_fmt
audio sample format
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
static int do_read_packets
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 int opt_read_intervals(void *optctx, const char *opt, const char *arg)
static int * selected_streams
static const char * flat_escape_value_str(AVBPrint *dst, const char *src)
static void writer_print_time(WriterContext *wctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration)
static const uint8_t offset[511][2]
static av_cold int end(AVCodecContext *avctx)
int id
unique ID to identify the chapter
static av_cold int compact_init(WriterContext *wctx)
int id
Format-specific stream ID.
static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
static int do_show_library_versions
static void compact_print_section_header(WriterContext *wctx)
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
static int match_section(const char *section_name, int show_all_entries, AVDictionary *entries)
const char * name
Name of the codec implementation.
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
static const AVOption json_options[]
static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
static double av_q2d(AVRational a)
Convert rational to double.
static const char *const binary_unit_prefixes[]
static const char * writer_get_name(void *p)
#define PRINT_DISPOSITION(flagname, name)
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
#define SECTION_MAX_NB_CHILDREN
int avformat_network_init(void)
Do global initialization of network components.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
const AVClass * priv_class
private class of the writer, if any
#define AV_LOG_VERBOSE
Detailed information.
static int check_section_show_entries(int section_id)
int interlaced_frame
The content of the picture is interlaced.
static void print_section(SectionID id, int level)
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
void(* print_section_footer)(WriterContext *wctx)
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 const char * c_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Apply C-language-like string escaping.
static void writer_register_all(void)
static void xml_print_str(WriterContext *wctx, const char *key, const char *value)
int children_ids[SECTION_MAX_NB_CHILDREN+1]
list of children section IDS, terminated by -1
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
static const char * input_filename
static void json_print_section_header(WriterContext *wctx)
const AVOption * av_opt_next(void *obj, const AVOption *prev)
Iterate over all AVOptions belonging to obj.
static void ffprobe_show_program_version(WriterContext *w)
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVDictionary * format_opts
static int do_show_frames
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static int do_show_chapters
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
#define av_err2str(errnum)
static int opt_show_versions(const char *opt, const char *arg)
static const char unit_byte_str[]
int64_t av_frame_get_pkt_duration(const AVFrame *frame)
int level
current level, starting from 0
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * entries_to_show
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.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static void read_packets(WriterContext *w, AVFormatContext *fmt_ctx)
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
static void opt_input_file(void *optctx, const char *arg)
static int opt_pretty(void *optctx, const char *opt, const char *arg)
char filename[1024]
input or output filename
#define SET_DO_SHOW(id, varname)
int priv_size
private size for the writer context
#define AV_BPRINT_SIZE_UNLIMITED
Convenience macros for special values for av_bprint_init() size_max parameter.
static const AVOption xml_options[]
#define SECTION_FLAG_HAS_VARIABLE_FIELDS
the section may contain a variable number of fields with variable keys.
int64_t convergence_duration
Time difference in AVStream->time_base units from the pts of this packet to the point at which the ou...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
int nested_section[SECTION_MAX_NB_LEVELS]
static void default_print_int(WriterContext *wctx, const char *key, long long int value)
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static av_cold int json_init(WriterContext *wctx)
static void show_chapters(WriterContext *w, AVFormatContext *fmt_ctx)
int av_frame_get_channels(const AVFrame *frame)
static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
int id
unique id identifying a section
AVRational avg_frame_rate
Average framerate.
New fields can be added to the end with minor version bumps.
static int parse_read_intervals(const char *intervals_spec)
int flags
A combination of AV_PKT_FLAG values.
void * priv
private data for use by the filter
uint64_t channel_layout
Audio channel layout.
char * name
name of this writer instance
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
const int program_birth_year
program birth year, defined by the program for show_banner()
#define SECTION_FLAG_IS_WRAPPER
the section only contains other sections, but has no data at its own level
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
unsigned int nb_streams
A list of all streams in the file.
static void writer_print_data(WriterContext *wctx, const char *name, uint8_t *data, int size)
#define FF_ARRAY_ELEMS(a)
static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
static ReadInterval * read_intervals
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various writers
Buffer to print data progressively.
int bit_rate
the average bitrate
#define print_section_footer(s)
int64_t timecode_frame_start
GOP timecode frame start number.
static const char * csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
Quote fields containing special characters, check RFC4180.
enum AVPictureType pict_type
Picture type of the frame.
static const char unit_bit_per_second_str[]
static const Writer * registered_writers[MAX_REGISTERED_WRITERS_NB+1]
int display_picture_number
picture number in display order
static struct section sections[]
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
static void writer_print_string(WriterContext *wctx, const char *key, const char *val, int opt)
static int do_read_frames
int width
picture width / height.
#define print_fmt(k, f,...)
AVDictionary * av_frame_get_metadata(const AVFrame *frame)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int show_private_data
static int probe_file(WriterContext *wctx, const char *filename)
char * av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)
Get the timecode string from the 25-bit timecode format (MPEG GOP format).
static av_cold int xml_init(WriterContext *wctx)
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
int nb_sections
number of sections
#define AV_BPRINT_SIZE_AUTOMATIC
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
static const Writer flat_writer
static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
static int opt_sections(void *optctx, const char *opt, const char *arg)
static int do_show_programs
static const OptionDef real_options[]
#define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
static int do_show_format
size_t char * av_asprintf(const char *fmt,...) av_printf_format(1
Print arguments following specified format into a large enough auto allocated buffer.
const char * item_start_end
static const Writer ini_writer
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
static void compact_print_str(WriterContext *wctx, const char *key, const char *value)
static const Writer compact_writer
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
int64_t end
chapter start/end time in time_base units
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int coded_picture_number
picture number in bitstream order
static AVInputFormat * iformat
#define AV_LOG_INFO
Standard information.
unsigned int nb_section_frame
number of the frame section in case we are in "packets_and_frames" section
enum AVMediaType codec_type
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
typedef void(RENAME(mix_any_func_type))
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int sample_rate
samples per second
static void xml_print_int(WriterContext *wctx, const char *key, long long int value)
struct section * sections
array containing all sections
main external API structure.
static const Writer csv_writer
#define AV_TIMECODE_STR_SIZE
static void show_error(WriterContext *w, int err)
static void ini_print_str(WriterContext *wctx, const char *key, const char *value)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER
AVIOContext * pb
I/O context.
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
unsigned int nb_section_packet_frame
nb_section_packet or nb_section_frame according if is_packets_and_frames
int terminate_line[SECTION_MAX_NB_LEVELS]
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.
#define AVERROR_OPTION_NOT_FOUND
static int show_value_unit
static int use_value_sexagesimal_format
#define print_duration_time(k, v, tb)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
Describe the class of an AVClass context structure.
static AVFormatContext * fmt_ctx
#define DEFINE_WRITER_CLASS(name)
rational number numerator/denominator
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static void ffprobe_cleanup(int ret)
#define SECTION_FLAG_IS_ARRAY
the section contains an array of elements of the same type
static const AVOption compact_options[]
int64_t end
start, end in second/AV_TIME_BASE units
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
static uint64_t * nb_streams_packets
static void ffprobe_show_library_versions(WriterContext *w)
static int use_value_prefix
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
static void show_programs(WriterContext *w, AVFormatContext *fmt_ctx)
static int swscale(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static void flat_print_section_header(WriterContext *wctx)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static char * upcase_string(char *dst, size_t dst_size, const char *src)
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.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
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...
int av_frame_get_pkt_size(const AVFrame *frame)
const int this_year
this year, defined by the program for show_banner()
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
void av_opt_free(void *obj)
Free all string and binary options in obj.
AVDictionary * codec_opts
static void xml_print_section_header(WriterContext *wctx)
static int do_show_stream_disposition
int flags
For these sections the element_name field is mandatory.
void(* print_section_header)(WriterContext *wctx)
static void default_print_str(WriterContext *wctx, const char *key, const char *value)
static int do_count_packets
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 presentation order, in stream time base...
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
static const char unit_second_str[]
static int parse_read_interval(const char *interval_spec, ReadInterval *interval)
Parse interval specification, according to the format: INTERVAL ::= [START|+START_OFFSET][%[END|+END_...
static void show_tags(WriterContext *wctx, AVDictionary *tags, int section_id)
static av_cold int flat_init(WriterContext *wctx)
static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx)
AVRational time_base
time base in which the start/end timestamps are specified
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
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
static AVCodecContext * dec_ctx
static const AVOption csv_options[]
static const char * flat_escape_key_str(AVBPrint *dst, const char *src, const char sep)
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
#define FFMPEG_CONFIGURATION
void av_bprintf(AVBPrint *buf, const char *fmt,...) av_printf_format(2
Append a formatted string to a print buffer.
static int opt_show_entries(void *optctx, const char *opt, const char *arg)
static const AVOption flat_options[]
static int do_show_program_version
static int use_byte_value_binary_prefix
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
int top_field_first
If the content is interlaced, is top field displayed first.
int channels
number of audio channels
static av_always_inline int process_frame(WriterContext *w, AVFormatContext *fmt_ctx, AVFrame *frame, AVPacket *pkt)
static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
void(* print_rational)(WriterContext *wctx, AVRational *q, char *sep)
const AVClass * priv_class
AVClass for the private context.
static const AVOption ini_options[]
void av_log_set_flags(int arg)
#define CHECK_COMPLIANCE(opt, opt_name)
int key_frame
1 -> keyframe, 0-> not
static const char * none_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
static void json_print_str(WriterContext *wctx, const char *key, const char *value)
static void ini_print_int(WriterContext *wctx, const char *key, long long int value)
#define print_val(k, v, u)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static char * stream_specifier
int bit_rate
Decoding: total stream bitrate in bit/s, 0 if not available.
#define print_time(k, v, tb)
static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx, const ReadInterval *interval, int64_t *cur_ts)
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
static void default_print_section_footer(WriterContext *wctx)
#define AV_DICT_IGNORE_SUFFIX
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void show_program(WriterContext *w, AVFormatContext *fmt_ctx, AVProgram *program)
int main(int argc, char **argv)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
const Writer * writer
the Writer of which this is an instance
int64_t av_frame_get_channel_layout(const AVFrame *frame)
AVRational r_frame_rate
Real base framerate of the stream.
static const Writer * writer_get_by_name(const char *name)
unsigned int * stream_index
const char * unique_name
unique section name, in case the name is ambiguous
This structure stores compressed data.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
#define DEFINE_OPT_SHOW_SECTION(section, target_section_id)
int nb_samples
number of audio samples (per channel) described by this frame
#define MAX_REGISTERED_WRITERS_NB
int64_t av_frame_get_pkt_pos(const AVFrame *frame)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...) av_printf_format(3
Append output to a string, according to a format.
static void writer_print_section_footer(WriterContext *wctx)
const char program_name[]
program name, defined by the program for show_version().
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
union unit_value::@41 val
static int do_show_streams
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout)
Append a description of a channel layout to a bprint buffer.
#define print_section_header(s)
int flags
a combination or WRITER_FLAG_*