27 #include "libavutil/ffversion.h"
57 # ifdef pthread_mutex_lock
58 # undef pthread_mutex_lock
60 # define pthread_mutex_lock(a)
61 # ifdef pthread_mutex_unlock
62 # undef pthread_mutex_unlock
64 # define pthread_mutex_unlock(a)
134 #define SECTION_MAX_NB_CHILDREN 10
140 #define SECTION_FLAG_IS_WRAPPER 1
141 #define SECTION_FLAG_IS_ARRAY 2
142 #define SECTION_FLAG_HAS_VARIABLE_FIELDS 4
254 static const struct {
260 { 1.0, 1.0,
"",
"" },
261 { 1.024e3, 1e3,
"Ki",
"K" },
262 { 1.048576e6, 1e6,
"Mi",
"M" },
263 { 1.073741824e9, 1e9,
"Gi",
"G" },
264 { 1.099511627776e12, 1e12,
"Ti",
"T" },
265 { 1.125899906842624e15, 1e15,
"Pi",
"P" },
298 static int print_prefix = 1;
299 void *new_log_buffer;
310 if (new_log_buffer) {
314 log_buffer = new_log_buffer;
315 memset(&log_buffer[
log_buffer_size], 0,
sizeof(log_buffer[log_buffer_size]));
323 for (i=strlen(msg) - 1; i>=0 && msg[i] ==
'\n'; i--) {
329 if (parent && *parent) {
332 (*parent)->get_category ? (*parent)->get_category(parent) :(*parent)->category;
354 union {
double d;
long long int i; }
val;
368 vald = vali = uv.
val.
i;
375 mins = (
int)secs / 60;
376 secs = secs - mins * 60;
379 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
381 const char *prefix_string =
"";
387 index = (
long long int) (
log2(vald)) / 10;
392 index = (
long long int) (log10(vald)) / 3;
401 snprintf(buf, buf_size,
"%f", vald);
403 snprintf(buf, buf_size,
"%lld", vali);
415 #define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS 1
416 #define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER 2
441 #define SECTION_MAX_NB_LEVELS 10
477 #define OFFSET(x) offsetof(WriterContext, x)
480 {
"string_validation",
"set string validation mode",
482 {
"sv",
"set string validation mode",
487 {
"string_validation_replacement",
"set string validation replacement string",
OFFSET(string_validation_replacement),
AV_OPT_TYPE_STRING, {.str=
""}},
488 {
"svr",
"set string validation replacement string",
OFFSET(string_validation_replacement),
AV_OPT_TYPE_STRING, {.str=
"\xEF\xBF\xBD"}},
515 if ((*wctx)->writer->uninit)
516 (*wctx)->writer->uninit(*wctx);
519 if ((*wctx)->writer->priv_class)
530 for (i = 0; i < ubuf_size; i++)
536 const struct section *sections,
int nb_sections)
551 (*wctx)->writer = writer;
554 (*wctx)->nb_sections = nb_sections;
559 void *priv_ctx = (*wctx)->priv;
570 av_log(*wctx,
AV_LOG_ERROR,
"Failed to parse option string '%s' provided to writer context\n", args);
577 av_log(*wctx,
AV_LOG_ERROR,
"Failed to set option '%s' with value '%s' provided to writer context\n",
589 const uint8_t *p = (*wctx)->string_validation_replacement;
590 const uint8_t *endp = p + strlen(p);
594 ret =
av_utf8_decode(&code, &p, endp, (*wctx)->string_validation_utf8_flags);
600 "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
601 bp.str, (*wctx)->string_validation_replacement);
610 if ((*wctx)->writer->init)
611 ret = (*wctx)->writer->init(*wctx);
625 int parent_section_id;
628 parent_section_id = wctx->
level ?
649 int parent_section_id = wctx->
level ?
664 const char *key,
long long int val)
678 int invalid_chars_nb = 0, ret = 0;
682 endp = src + strlen(src);
683 for (p = (
uint8_t *)src; *p;) {
693 "Invalid UTF-8 sequence %s found in string '%s'\n", bp.str, src);
703 "Invalid UTF-8 sequence found in string '%s'\n", src);
720 "%d invalid UTF-8 sequence(s) found in string '%s', replaced with '%s'\n",
729 #define PRINT_STRING_OPT 1
730 #define PRINT_STRING_VALIDATE 2
733 const char *key,
const char *
val,
int flags)
746 if (ret < 0)
goto end;
748 if (ret < 0)
goto end;
753 "Invalid key=value string combination %s=%s in section %s\n",
778 int64_t ts,
const AVRational *time_base,
int is_duration)
782 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
785 double d = ts *
av_q2d(*time_base);
796 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
814 for (i = 0; i < l; i++) {
820 for (i = 0; i < l; i++)
841 p = buf + strlen(buf);
848 int columns,
int bytes,
int offset_add)
857 l =
FFMIN(size, columns);
858 for (i = 0; i < l; i++) {
859 if (bytes == 1)
av_bprintf(&bp, format, *data);
866 offset += offset_add;
872 #define MAX_REGISTERED_WRITERS_NB 64
878 static int next_registered_writer_idx = 0;
883 registered_writers[next_registered_writer_idx++] = writer;
891 for (i = 0; registered_writers[
i]; i++)
892 if (!strcmp(registered_writers[i]->name, name))
893 return registered_writers[
i];
901 #define DEFINE_WRITER_CLASS(name) \
902 static const char *name##_get_name(void *ctx) \
906 static const AVClass name##_class = { \
907 .class_name = #name, \
908 .item_name = name##_get_name, \
909 .option = name##_options \
922 #define OFFSET(x) offsetof(DefaultContext, x)
925 {
"noprint_wrappers",
"do not print headers and footers",
OFFSET(noprint_wrappers),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
938 for (i = 0; src[i] && i < dst_size-1; i++)
949 const struct section *parent_section = wctx->
level ?
953 if (parent_section &&
988 printf(
"%s\n", value);
997 printf(
"%lld\n", value);
1008 .priv_class = &default_class,
1016 static const char *
c_escape_str(AVBPrint *dst,
const char *
src,
const char sep,
void *log_ctx)
1020 for (p = src; *p; p++) {
1022 case '\b':
av_bprintf(dst,
"%s",
"\\b");
break;
1023 case '\f':
av_bprintf(dst,
"%s",
"\\f");
break;
1024 case '\n':
av_bprintf(dst,
"%s",
"\\n");
break;
1025 case '\r':
av_bprintf(dst,
"%s",
"\\r");
break;
1026 case '\\':
av_bprintf(dst,
"%s",
"\\\\");
break;
1041 char meta_chars[] = { sep,
'"',
'\n',
'\r',
'\0' };
1042 int needs_quoting = !!src[strcspn(src, meta_chars)];
1047 for (; *
src; src++) {
1069 const char * (*escape_str)(AVBPrint *dst,
const char *
src,
const char sep,
void *log_ctx);
1076 #define OFFSET(x) offsetof(CompactContext, x)
1097 av_log(wctx,
AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
1118 const struct section *parent_section = wctx->
level ?
1160 if (!compact->
nokey)
1172 if (!compact->
nokey)
1174 printf(
"%lld", value);
1186 .priv_class = &compact_class,
1192 #define OFFSET(x) offsetof(CompactContext, x)
1217 .priv_class = &csv_class,
1230 #define OFFSET(x) offsetof(FlatContext, x)
1235 {
"hierarchical",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1236 {
"h",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1246 if (strlen(flat->
sep_str) != 1) {
1247 av_log(wctx,
AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
1260 for (p = src; *p; p++) {
1261 if (!((*p >=
'0' && *p <=
'9') ||
1262 (*p >=
'a' && *p <=
'z') ||
1263 (*p >=
'A' && *p <=
'Z')))
1275 for (p = src; *p; p++) {
1277 case '\n':
av_bprintf(dst,
"%s",
"\\n");
break;
1278 case '\r':
av_bprintf(dst,
"%s",
"\\r");
break;
1279 case '\\':
av_bprintf(dst,
"%s",
"\\\\");
break;
1280 case '"':
av_bprintf(dst,
"%s",
"\\\"");
break;
1281 case '`':
av_bprintf(dst,
"%s",
"\\`");
break;
1282 case '$':
av_bprintf(dst,
"%s",
"\\$");
break;
1294 const struct section *parent_section = wctx->
level ?
1299 if (!parent_section)
1341 .priv_class = &flat_class,
1352 #define OFFSET(x) offsetof(INIContext, x)
1355 {
"hierarchical",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1356 {
"h",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical),
AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1367 while (c = src[i++]) {
1369 case '\b':
av_bprintf(dst,
"%s",
"\\b");
break;
1370 case '\f':
av_bprintf(dst,
"%s",
"\\f");
break;
1371 case '\n':
av_bprintf(dst,
"%s",
"\\n");
break;
1372 case '\r':
av_bprintf(dst,
"%s",
"\\r");
break;
1373 case '\t':
av_bprintf(dst,
"%s",
"\\t");
break;
1379 if ((
unsigned char)c < 32)
1394 const struct section *parent_section = wctx->
level ?
1398 if (!parent_section) {
1399 printf(
"# ffprobe output\n\n");
1419 printf(
"[%s]\n", buf->str);
1435 printf(
"%s=%lld\n", key, value);
1445 .priv_class = &ini_class,
1458 #define OFFSET(x) offsetof(JSONContext, x)
1480 static const char json_escape[] = {
'"',
'\\',
'\b',
'\f',
'\n',
'\r',
'\t', 0};
1481 static const char json_subst[] = {
'"',
'\\',
'b',
'f',
'n',
'r',
't', 0};
1484 for (p = src; *p; p++) {
1485 char *
s = strchr(json_escape, *p);
1489 }
else if ((
unsigned char)*p < 32) {
1498 #define JSON_INDENT() printf("%*c", json->indent_level * 4, ' ')
1505 const struct section *parent_section = wctx->
level ?
1521 printf(
"\"%s\": [\n", buf.str);
1531 printf(
"\"type\": \"%s\"%s", section->
name, json->
item_sep);
1543 if (wctx->
level == 0) {
1561 const char *key,
const char *
value)
1607 .priv_class = &json_class,
1621 #define OFFSET(x) offsetof(XMLContext, x)
1624 {
"fully_qualified",
"specify if the output should be fully qualified",
OFFSET(fully_qualified),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1625 {
"q",
"specify if the output should be fully qualified",
OFFSET(fully_qualified),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1626 {
"xsd_strict",
"ensure that the output is XSD compliant",
OFFSET(xsd_strict),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1639 #define CHECK_COMPLIANCE(opt, opt_name) \
1641 av_log(wctx, AV_LOG_ERROR, \
1642 "XSD-compliant output selected but option '%s' was selected, XML output may be non-compliant.\n" \
1643 "You need to disable such option with '-no%s'\n", opt_name, opt_name); \
1644 return AVERROR(EINVAL); \
1652 "Interleaved frames and packets are not allowed in XSD. "
1653 "Select only one between the -show_frames and the -show_packets options.\n");
1665 for (p = src; *p; p++) {
1667 case '&' :
av_bprintf(dst,
"%s",
"&");
break;
1668 case '<' :
av_bprintf(dst,
"%s",
"<");
break;
1669 case '>' :
av_bprintf(dst,
"%s",
">");
break;
1670 case '"' :
av_bprintf(dst,
"%s",
""");
break;
1671 case '\'':
av_bprintf(dst,
"%s",
"'");
break;
1679 #define XML_INDENT() printf("%*c", xml->indent_level * 4, ' ')
1685 const struct section *parent_section = wctx->
level ?
1688 if (wctx->
level == 0) {
1689 const char *qual =
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
1690 "xmlns:ffprobe='http://www.ffmpeg.org/schema/ffprobe' "
1691 "xsi:schemaLocation='http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd'";
1693 printf(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1694 printf(
"<%sffprobe%s>\n",
1726 if (wctx->
level == 0) {
1750 printf(
"<%s key=\"%s\"",
1767 printf(
"%s=\"%lld\"", key, value);
1779 .priv_class = &xml_class,
1784 static int initialized;
1799 #define print_fmt(k, f, ...) do { \
1800 av_bprint_clear(&pbuf); \
1801 av_bprintf(&pbuf, f, __VA_ARGS__); \
1802 writer_print_string(w, k, pbuf.str, 0); \
1805 #define print_int(k, v) writer_print_integer(w, k, v)
1806 #define print_q(k, v, s) writer_print_rational(w, k, v, s)
1807 #define print_str(k, v) writer_print_string(w, k, v, 0)
1808 #define print_str_opt(k, v) writer_print_string(w, k, v, PRINT_STRING_OPT)
1809 #define print_str_validate(k, v) writer_print_string(w, k, v, PRINT_STRING_VALIDATE)
1810 #define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
1811 #define print_ts(k, v) writer_print_ts(w, k, v, 0)
1812 #define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
1813 #define print_duration_ts(k, v) writer_print_ts(w, k, v, 1)
1814 #define print_val(k, v, u) do { \
1815 struct unit_value uv; \
1818 writer_print_string(w, k, value_string(val_str, sizeof(val_str), uv), 0); \
1821 #define print_section_header(s) writer_print_section_header(w, s)
1822 #define print_section_footer(s) writer_print_section_footer(w, s)
1824 #define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
1826 ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
1829 memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
1860 for (i = 0; i < nb_side_data; i++) {
1865 print_str(
"side_data_type", name ? name :
"unknown");
1960 av_freep(&log_buffer[i].context_name);
1961 av_freep(&log_buffer[i].parent_name);
1962 av_freep(&log_buffer[i].log_message);
1964 log_buffer_size = 0;
1980 if (log_buffer[i].log_level <= log_level) {
1982 print_str(
"context", log_buffer[i].context_name);
1983 print_int(
"level", log_buffer[i].log_level);
1985 if (log_buffer[i].parent_name) {
1986 print_str(
"parent_context", log_buffer[i].parent_name);
1987 print_int(
"parent_category", log_buffer[i].parent_category);
1992 print_str(
"message", log_buffer[i].log_message);
2123 print_q(
"sample_aspect_ratio", sar,
':');
2162 print_str(
"side_data_type", name ? name :
"unknown");
2190 int ret = 0, got_frame = 0;
2193 if (dec_ctx && dec_ctx->
codec) {
2230 av_log(log_ctx, log_level,
"id:%d", interval->
id);
2236 av_log(log_ctx, log_level,
" start:N/A");
2242 av_log(log_ctx, log_level,
"#%"PRId64, interval->
end);
2246 av_log(log_ctx, log_level,
" end:N/A");
2249 av_log(log_ctx, log_level,
"\n");
2258 int ret = 0, i = 0, frame_count = 0;
2272 "Could not seek to relative position since current "
2273 "timestamp is not defined\n");
2277 target = *cur_ts + interval->
start;
2279 target = interval->
start;
2315 end = start + interval->
end;
2320 if (frame_count >= interval->
end)
2322 }
else if (has_end && *cur_ts !=
AV_NOPTS_VALUE && *cur_ts >= end) {
2416 char profile_num[12];
2426 #if FF_API_LAVF_AVCTX
2446 print_q(
"sample_aspect_ratio", sar,
':');
2451 print_q(
"display_aspect_ratio", dar,
':');
2468 print_str(
"field_order",
"progressive");
2480 #if FF_API_PRIVATE_OPT
2527 if (opt->
flags)
continue;
2546 #if FF_API_LAVF_AVCTX
2565 #define PRINT_DISPOSITION(flagname, name) do { \
2566 print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
2731 const char *errbuf_ptr = errbuf;
2744 int err, i, orig_nb_streams;
2748 int scan_all_pmts_set = 0;
2756 fmt_ctx->
flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
2760 scan_all_pmts_set = 1;
2768 if (scan_all_pmts_set)
2781 for (i = 0; i < orig_nb_streams; i++)
2808 "Failed to probe codec for input stream %d\n",
2816 "Unsupported codec with id %d for input stream %d\n",
2822 fmt_ctx, stream, codec);
2888 #define CHECK_END if (ret < 0) goto end
2967 print_fmt(
"copyright",
"Copyright (c) %d-%d the FFmpeg developers",
2970 print_str(
"configuration", FFMPEG_CONFIGURATION);
2976 #define SHOW_LIB_VERSION(libname, LIBNAME) \
2978 if (CONFIG_##LIBNAME) { \
2979 unsigned int version = libname##_version(); \
2980 writer_print_section_header(w, SECTION_ID_LIBRARY_VERSION); \
2981 print_str("name", "lib" #libname); \
2982 print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
2983 print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
2984 print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
2985 print_int("version", version); \
2986 print_str("ident", LIB##LIBNAME##_IDENT); \
2987 writer_print_section_footer(w); \
3005 #define PRINT_PIX_FMT_FLAG(flagname, name) \
3007 print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
3073 if (show_all_entries) {
3089 if (!strcmp(section_name, section->
name) ||
3092 "'%s' matches section with unique name '%s'\n", section_name,
3103 const char *p =
arg;
3111 if (!section_name) {
3113 "Missing section name for option '%s'\n", opt);
3119 while (*p && *p !=
':') {
3124 "Adding '%s' to the entries to show in section '%s'\n",
3125 entry, section_name);
3131 show_all_entries = 1;
3134 ret =
match_section(section_name, show_all_entries, entries);
3160 "Option '%s' is deprecated, use '-show_entries format=%s' instead\n",
3171 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3175 if (!strcmp(arg,
"-"))
3206 char *next, *p, *spec =
av_strdup(interval_spec);
3217 next = strchr(spec,
'%');
3259 lli = strtoll(p, &tail, 10);
3260 if (*tail || lli < 0) {
3262 "Invalid or negative value '%s' for duration number of frames\n", p);
3265 interval->
end = lli;
3286 char *p, *spec =
av_strdup(intervals_spec);
3291 for (n = 0, p = spec; *p; p++)
3297 if (!read_intervals) {
3305 for (i = 0; p; i++) {
3309 next = strchr(p,
',');
3313 read_intervals[i].
id = i;
3353 printf(
"%*c %s", level * 4,
' ', section->
name);
3364 printf(
"Sections:\n"
3365 "W.. = Section is a wrapper (contains other sections, no local entries)\n"
3366 ".A. = Section contains an array of elements of the same type\n"
3367 "..V = Section may contain a variable number of fields with variable keys\n"
3368 "FLAGS NAME/UNIQUE_NAME\n"
3381 #define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
3382 static int opt_show_##section(const char *opt, const char *arg) \
3384 mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL); \
3405 "use binary prefixes for byte units" },
3407 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
3409 "prettify the format of displayed values, make it more human readable" },
3411 "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)",
"format" },
3414 {
"sections",
OPT_EXIT, {.func_arg =
opt_sections},
"print sections structure and section information, and exit" },
3417 {
"show_error", 0, {(
void*)&opt_show_error},
"show probing error" },
3418 {
"show_format", 0, {(
void*)&opt_show_format},
"show format/container info" },
3419 {
"show_frames", 0, {(
void*)&opt_show_frames},
"show frames info" },
3421 "show a particular entry from the format/container info",
"entry" },
3423 "show a set of specified entries",
"entry_list" },
3427 {
"show_packets", 0, {(
void*)&opt_show_packets},
"show packets info" },
3428 {
"show_programs", 0, {(
void*)&opt_show_programs},
"show programs info" },
3429 {
"show_streams", 0, {(
void*)&opt_show_streams},
"show streams info" },
3430 {
"show_chapters", 0, {(
void*)&opt_show_chapters},
"show chapters info" },
3433 {
"show_program_version", 0, {(
void*)&opt_show_program_version},
"show ffprobe version" },
3434 {
"show_library_versions", 0, {(
void*)&opt_show_library_versions},
"show library versions" },
3435 {
"show_versions", 0, {(
void*)&
opt_show_versions},
"show program and library versions" },
3436 {
"show_pixel_formats", 0, {(
void*)&opt_show_pixel_formats},
"show pixel format descriptions" },
3458 #define SET_DO_SHOW(id, varname) do { \
3459 if (check_section_show_entries(SECTION_ID_##id)) \
3460 do_show_##varname = 1; \
3468 char *w_name =
NULL, *w_args =
NULL;
3505 SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
3506 SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components);
3510 SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
3511 SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
3523 "-bitexact and -show_program_version or -show_library_versions "
3524 "options are incompatible\n");
3540 "No name specified for the output format\n");
3551 "Unknown hash algorithm '%s'\nKnown algorithms:",
3570 if (w == &xml_writer)
unsigned int nb_chapters
Number of chapters in AVChapter array.
int32_t pitch
Rotation around the right vector [-90, 90].
void init_dynload(void)
Initialize dynamic library loading.
int(* init)(WriterContext *wctx)
codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it ...
AVClassCategory parent_category
enum AVChromaLocation chroma_location
const struct section * section[SECTION_MAX_NB_LEVELS]
section per each level
const struct AVCodec * codec
const char const char void * val
static char * value_string(char *buf, int buf_size, struct unit_value uv)
static int do_show_program_tags
enum AVFieldOrder field_order
Video only.
static const struct @38 si_prefixes[]
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
number of the item printed in the given section, starting from 0
enum AVColorTransferCharacteristic color_trc
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int show_tags(WriterContext *w, AVDictionary *tags, int section_id)
int64_t avio_size(AVIOContext *s)
Get the filesize.
int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags)
Read and decode a single UTF-8 code point (character) from the buffer in *buf, and update *buf to poi...
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int64_t av_frame_get_pkt_duration(const AVFrame *frame)
int nested_section[SECTION_MAX_NB_LEVELS]
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
int av_frame_get_pkt_size(const AVFrame *frame)
This structure describes decoded (raw) audio or video data.
#define pthread_mutex_lock(a)
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)
static void print_color_range(WriterContext *w, enum AVColorRange color_range, const char *fallback)
ptrdiff_t const GLvoid * data
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)
int coded_width
Bitstream width / height, may be different from width/height e.g.
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.
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
static const char * xml_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
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
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
static void writer_print_integer(WriterContext *wctx, const char *key, long long int val)
static int do_show_stream_tags
static char * ini_escape_str(AVBPrint *dst, const char *src)
static void print_chroma_location(WriterContext *w, enum AVChromaLocation chroma_location)
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...
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
static AVFormatContext * fmt_ctx
static int show_streams(WriterContext *w, InputFile *ifile)
static char * print_format
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection...
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
static const Writer json_writer
void av_codec_set_pkt_timebase(AVCodecContext *avctx, AVRational val)
int repeat_pict
When decoding, this signals how much the picture must be delayed.
int index
stream index in AVFormatContext
static const AVOption writer_options[]
static void writer_print_integers(WriterContext *wctx, const char *name, uint8_t *data, int size, const char *format, int columns, int bytes, int offset_add)
static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx, InputStream *ist, int in_program)
#define print_str_opt(k, v)
void(* print_integer)(WriterContext *wctx, const char *, long long int)
static int read_packets(WriterContext *w, InputFile *ifile)
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
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).
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
attribute_deprecated 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 AVClass writer_class
static int do_show_packets
static int do_show_format_tags
static int writer_open(WriterContext **wctx, const Writer *writer, const char *args, const struct section *sections, int nb_sections)
void(* uninit)(WriterContext *wctx)
static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static void json_print_item_str(WriterContext *wctx, const char *key, const char *value)
static const Writer default_writer
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
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)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static void mark_section_show_entries(SectionID section_id, int show_all_entries, AVDictionary *entries)
static av_always_inline int process_frame(WriterContext *w, InputFile *ifile, AVFrame *frame, AVPacket *pkt)
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
static uint64_t * nb_streams_frames
int has_nested_elems[SECTION_MAX_NB_LEVELS]
static int validate_string(WriterContext *wctx, char **dstp, const char *src)
static int open_input_file(InputFile *ifile, const char *filename)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
This struct describes the properties of an encoded stream.
AVColorTransferCharacteristic
Color Transfer Characteristic.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static int do_count_frames
#define SECTION_MAX_NB_LEVELS
enum AVColorSpace color_space
static void * writer_child_next(void *obj, void *prev)
const char * av_color_space_name(enum AVColorSpace space)
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() or another memory allocation function...
const char *(* escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
#define AV_HASH_MAX_SIZE
Maximum value that av_hash_get_size() will currently return.
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
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)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
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)
int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict)
Unpack a dictionary from side_data.
static int do_show_pixel_format_components
static int * selected_streams
const char * av_stereo3d_type_name(unsigned int type)
Provide a human-readable name of a given stereo3d type.
static void close_input_file(InputFile *ifile)
timestamp utils, mostly useful for debugging/logging purposes
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
#define va_copy(dst, src)
AVColorSpace
YUV colorspace type.
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)
const char * av_color_range_name(enum AVColorRange range)
static av_cold int end(AVCodecContext *avctx)
int id
unique ID to identify the chapter
static int show_chapters(WriterContext *w, InputFile *ifile)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static av_cold int compact_init(WriterContext *wctx)
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int id
Format-specific stream ID.
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.
void av_spherical_tile_bounds(const AVSphericalMapping *map, size_t width, size_t height, size_t *left, size_t *top, size_t *right, size_t *bottom)
Convert the bounding fields from an AVSphericalVideo from 0.32 fixed point to pixels.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int nb_side_data
The number of elements in the AVStream.side_data array.
static int match_section(const char *section_name, int show_all_entries, AVDictionary *entries)
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.
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
static void writer_print_data_hash(WriterContext *wctx, const char *name, uint8_t *data, int size)
Structure to hold side data for an AVFrame.
static const AVOption json_options[]
static void log_read_interval(const ReadInterval *interval, void *log_ctx, int log_level)
static const char * writer_get_name(void *p)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
#define PRINT_DISPOSITION(flagname, name)
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define SECTION_MAX_NB_CHILDREN
static int show_program(WriterContext *w, InputFile *ifile, AVProgram *program)
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.
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
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.
AVColorRange
MPEG vs JPEG YUV range.
void(* print_section_footer)(WriterContext *wctx)
int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame)
Accessors for some AVFrame fields.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
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
AVColorPrimaries
Chromaticity coordinates of the source primaries.
static void print_pkt_side_data(WriterContext *w, AVCodecParameters *par, const AVPacketSideData *side_data, int nb_side_data, SectionID id_data_list, SectionID id_data)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static const char * input_filename
unsigned int * stream_index
static void json_print_section_header(WriterContext *wctx)
AVFrameSideData ** side_data
uint64_t channel_layout
Audio only.
static void ffprobe_show_program_version(WriterContext *w)
static int do_show_chapter_tags
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#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)
Rescale a 64-bit integer by 2 rational numbers.
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 int read_interval_packets(WriterContext *w, InputFile *ifile, const ReadInterval *interval, int64_t *cur_ts)
static int do_show_chapters
char * string_validation_replacement
libswresample public header
static int opt_show_versions(const char *opt, const char *arg)
const char * av_chroma_location_name(enum AVChromaLocation location)
static const char unit_byte_str[]
void av_hash_init(AVHashContext *ctx)
Initialize or reset a hash context.
const int program_birth_year
program birth year, defined by the program for show_banner()
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
static int do_show_pixel_format_flags
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
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 flags
Additional information about the frame packing.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define AV_BPRINT_SIZE_UNLIMITED
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix)
Format a line of log the same way as the default callback.
static void opt_input_file(void *optctx, const char *arg)
static int opt_pretty(void *optctx, const char *opt, const char *arg)
#define SET_DO_SHOW(id, varname)
int priv_size
private size for the writer context
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static const AVOption xml_options[]
enum AVColorPrimaries color_primaries
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
int video_delay
Video only.
#define SECTION_FLAG_HAS_VARIABLE_FIELDS
the section may contain a variable number of fields with variable keys.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
#define av_fourcc2str(fourcc)
enum AVMediaType codec_type
General type of the encoded data.
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...
static av_cold int json_init(WriterContext *wctx)
simple assert() macros that are a bit more flexible than ISO C assert().
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
enum AVPacketSideDataType type
AVClassCategory category
Category used for visualization (like color) This is only set if the category is equal for all object...
static int show_log(WriterContext *w, int section_ids, int section_id, int log_level)
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 void flat_print_str(WriterContext *wctx, const char *key, const char *value)
int av_hash_alloc(AVHashContext **ctx, const char *name)
Allocate a hash context for the algorithm specified by name.
int id
unique id identifying a section
const char * long_name
A more descriptive name for this codec.
The GOP timecode in 25 bit timecode format.
static const uint8_t offset[127][2]
AVRational avg_frame_rate
Average framerate.
New fields can be added to the end with minor version bumps.
static void * av_mallocz_array(size_t nmemb, size_t size)
attribute_deprecated int64_t timecode_frame_start
static int parse_read_intervals(const char *intervals_spec)
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...
void av_log_default_callback(void *ptr, int level, const char *fmt, va_list vl)
Default logging callback.
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)
void * priv
private data for use by the filter
int extradata_size
Size of the extradata content in bytes.
uint32_t end_display_time
char * name
name of this writer instance
int64_t pts
Same as packet pts, in AV_TIME_BASE.
char * av_asprintf(const char *fmt,...)
#define SECTION_FLAG_IS_WRAPPER
the section only contains other sections, but has no data at its own level
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static void writer_print_data(WriterContext *wctx, const char *name, uint8_t *data, int size)
static int show_format(WriterContext *w, InputFile *ifile)
int refs
number of reference frames
static ReadInterval * read_intervals
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
uint8_t nb_components
The number of components each pixel has, (1-4)
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various writers
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
#define print_section_footer(s)
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.
char filename[1024]
input or output filename
static const char unit_bit_per_second_str[]
static const Writer * registered_writers[MAX_REGISTERED_WRITERS_NB+1]
#define AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES
exclude control codes not accepted by XML
const char * av_hash_names(int i)
Get the names of available hash algorithms.
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.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static int do_read_frames
#define PRINT_PIX_FMT_FLAG(flagname, name)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLsizei GLboolean const GLfloat * value
#define print_fmt(k, f,...)
#define FF_PROFILE_UNKNOWN
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
static void ffprobe_show_pixel_formats(WriterContext *w)
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
static void show_usage(void)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
const char * av_hash_get_name(const AVHashContext *ctx)
static int show_private_data
static int probe_file(WriterContext *wctx, const char *filename)
AVClassCategory(* get_category)(void *ctx)
Callback to return the category.
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static av_cold int xml_init(WriterContext *wctx)
int nb_sections
number of sections
const struct section * sections
array containing all sections
static const Writer flat_writer
static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
int32_t yaw
Rotation around the up vector [-180, 180].
static int opt_sections(void *optctx, const char *opt, const char *arg)
static int do_show_programs
static const OptionDef real_options[]
enum AVColorRange color_range
Video only.
#define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
#define pthread_mutex_unlock(a)
const char *(* item_name)(void *ctx)
A pointer to a function which returns the name of a context instance ctx associated with the class...
static int do_show_format
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
static void error(const char *err)
const char * item_start_end
#define FF_ARRAY_ELEMS(a)
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)
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.
uint32_t padding
Number of pixels to pad from the edge of each cube face.