51#include "libavutil/ffversion.h"
55#include "libavformat/avformat.h"
56#include "libavcodec/avcodec.h"
57#include "libavutil/avassert.h"
58#include "libavutil/avstring.h"
59#include "libavutil/bprint.h"
60#include "libavutil/channel_layout.h"
61#include "libavutil/display.h"
62#include "libavutil/hash.h"
63#include "libavutil/hdr_dynamic_metadata.h"
64#include "libavutil/mastering_display_metadata.h"
65#include "libavutil/hdr_dynamic_vivid_metadata.h"
66#include "libavutil/dovi_meta.h"
67#include "libavutil/opt.h"
68#include "libavutil/pixdesc.h"
69#include "libavutil/spherical.h"
70#include "libavutil/stereo3d.h"
71#include "libavutil/dict.h"
72#include "libavutil/intreadwrite.h"
73#include "libavutil/libm.h"
74#include "libavutil/parseutils.h"
75#include "libavutil/timecode.h"
76#include "libavutil/timestamp.h"
77#include "libavdevice/avdevice.h"
78#include "libswscale/swscale.h"
79#include "libswresample/swresample.h"
83#include "libavutil/thread.h"
88# ifdef pthread_mutex_lock
89# undef pthread_mutex_lock
91# define pthread_mutex_lock(a) do{}while(0)
92# ifdef pthread_mutex_unlock
93# undef pthread_mutex_unlock
95# define pthread_mutex_unlock(a) do{}while(0)
145#define SHOW_OPTIONAL_FIELDS_AUTO -1
146#define SHOW_OPTIONAL_FIELDS_NEVER 0
147#define SHOW_OPTIONAL_FIELDS_ALWAYS 1
167#define SECTION_MAX_NB_CHILDREN 10
173#define SECTION_FLAG_IS_WRAPPER 1
174#define SECTION_FLAG_IS_ARRAY 2
175#define SECTION_FLAG_HAS_VARIABLE_FIELDS 4
299__thread
struct AVHashContext *
hash;
310 { 1.0, 1.0,
"",
"" },
311 { 1.024e3, 1e3,
"Ki",
"K" },
312 { 1.048576e6, 1e6,
"Mi",
"M" },
313 { 1.073741824e9, 1e9,
"Gi",
"G" },
314 { 1.099511627776e12, 1e12,
"Ti",
"T" },
315 { 1.125899906842624e15, 1e15,
"Pi",
"P" },
329__thread pthread_mutex_t log_mutex;
343static void log_callback(
void *ptr,
int level,
const char *fmt, va_list vl)
345 AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
348 static int print_prefix = 1;
349 void *new_log_buffer;
352 av_log_default_callback(ptr, level, fmt, vl);
353 av_log_format_line(ptr, level, fmt, vl2, line,
sizeof(line), &print_prefix);
360 if (new_log_buffer) {
373 for (i=strlen(msg) - 1; i>=0 && msg[i] ==
'\n'; i--) {
376 if (avc && avc->parent_log_context_offset) {
377 AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
378 avc->parent_log_context_offset);
379 if (parent && *parent) {
382 (*parent)->get_category ? (*parent)->get_category(parent) :(*parent)->category;
395 for (i = 0; i < FF_ARRAY_ELEMS(
sections); i++)
396 av_dict_free(&(
sections[i].entries_to_show));
399 pthread_mutex_destroy(&log_mutex);
404 union {
double d;
long long int i; }
val;
418 vald = vali = uv.
val.
i;
425 mins = (
int)secs / 60;
426 secs = secs - mins * 60;
429 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
431 const char *prefix_string =
"";
437 index = (
long long int) (log2(vald)) / 10;
438 index = av_clip(index, 0, FF_ARRAY_ELEMS(
si_prefixes) - 1);
442 index = (
long long int) (log10(vald)) / 3;
443 index = av_clip(index, 0, FF_ARRAY_ELEMS(
si_prefixes) - 1);
451 snprintf(buf, buf_size,
"%f", vald);
453 snprintf(buf, buf_size,
"%lld", vali);
454 av_strlcatf(buf, buf_size,
"%s%s%s", *prefix_string ||
show_value_unit ?
" " :
"",
465#define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS 1
466#define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER 2
491#define SECTION_MAX_NB_LEVELS 10
494 const AVClass *
class;
533#define OFFSET(x) offsetof(WriterContext, x)
536 {
"string_validation",
"set string validation mode",
538 {
"sv",
"set string validation mode",
543 {
"string_validation_replacement",
"set string validation replacement string",
OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=
""}},
544 {
"svr",
"set string validation replacement string",
OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=
"\xEF\xBF\xBD"}},
557 .class_name =
"Writer",
560 .version = LIBAVUTIL_VERSION_INT,
572 if ((*wctx)->writer->uninit)
573 (*wctx)->writer->uninit(*wctx);
575 av_bprint_finalize(&(*wctx)->section_pbuf[i], NULL);
576 if ((*wctx)->writer->priv_class)
577 av_opt_free((*wctx)->priv);
578 av_freep(&((*wctx)->priv));
581 avio_flush((*wctx)->avio);
582 ret = avio_close((*wctx)->avio);
588static void bprint_bytes(AVBPrint *bp,
const uint8_t *ubuf,
size_t ubuf_size)
591 av_bprintf(bp,
"0X");
592 for (i = 0; i < ubuf_size; i++)
593 av_bprintf(bp,
"%02X", ubuf[i]);
598 avio_w8(wctx->
avio, b);
603 avio_write(wctx->
avio, str, strlen(str));
611 avio_vprintf(wctx->
avio, fmt, ap);
639 ret = AVERROR(ENOMEM);
643 if (!((*wctx)->priv = av_mallocz(writer->
priv_size))) {
644 ret = AVERROR(ENOMEM);
649 (*wctx)->writer = writer;
652 (*wctx)->nb_sections = nb_sections;
654 av_opt_set_defaults(*wctx);
657 void *priv_ctx = (*wctx)->priv;
658 *((
const AVClass **)priv_ctx) = writer->
priv_class;
659 av_opt_set_defaults(priv_ctx);
664 AVDictionary *opts = NULL;
665 const AVDictionaryEntry *opt = NULL;
667 if ((ret = av_dict_parse_string(&opts, args,
"=",
":", 0)) < 0) {
668 av_log(*wctx, AV_LOG_ERROR,
"Failed to parse option string '%s' provided to writer context\n", args);
673 while ((opt = av_dict_get(opts,
"", opt, AV_DICT_IGNORE_SUFFIX))) {
674 if ((ret = av_opt_set(*wctx, opt->key, opt->value, AV_OPT_SEARCH_CHILDREN)) < 0) {
675 av_log(*wctx, AV_LOG_ERROR,
"Failed to set option '%s' with value '%s' provided to writer context\n",
676 opt->key, opt->value);
687 const uint8_t *p = (*wctx)->string_validation_replacement;
688 const uint8_t *endp = p + strlen(p);
690 const uint8_t *p0 = p;
692 ret = av_utf8_decode(&code, &p, endp, (*wctx)->string_validation_utf8_flags);
695 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
697 av_log(wctx, AV_LOG_ERROR,
698 "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
710 if ((ret = avio_open(&(*wctx)->avio, output, AVIO_FLAG_WRITE)) < 0) {
711 av_log(*wctx, AV_LOG_ERROR,
712 "Failed to open output '%s' with error: %s\n", output, av_err2str(ret));
721 av_bprint_init(&(*wctx)->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);
723 if ((*wctx)->writer->init)
724 ret = (*wctx)->writer->init(*wctx);
738 int parent_section_id;
741 parent_section_id = wctx->
level ?
762 int parent_section_id = wctx->
level ?
777 const char *key,
long long int val)
789 const uint8_t *p, *endp;
791 int invalid_chars_nb = 0, ret = 0;
793 av_bprint_init(&dstbuf, 0, AV_BPRINT_SIZE_UNLIMITED);
795 endp = src + strlen(src);
796 for (p = (uint8_t *)src; *p;) {
799 const uint8_t *p0 = p;
803 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
805 av_log(wctx, AV_LOG_DEBUG,
806 "Invalid UTF-8 sequence %s found in string '%s'\n", bp.str, src);
815 av_log(wctx, AV_LOG_ERROR,
816 "Invalid UTF-8 sequence found in string '%s'\n", src);
817 ret = AVERROR_INVALIDDATA;
828 av_bprint_append_data(&dstbuf, p0, p-p0);
832 av_log(wctx, AV_LOG_WARNING,
833 "%d invalid UTF-8 sequence(s) found in string '%s', replaced with '%s'\n",
838 av_bprint_finalize(&dstbuf, dstp);
842#define PRINT_STRING_OPT 1
843#define PRINT_STRING_VALIDATE 2
846 const char *key,
const char *val,
int flags)
859 char *key1 = NULL, *val1 = NULL;
861 if (ret < 0)
goto end;
863 if (ret < 0)
goto end;
867 av_log(wctx, AV_LOG_ERROR,
868 "Invalid key=value string combination %s=%s in section %s\n",
884 const char *key, AVRational q,
char sep)
887 av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
888 av_bprintf(&buf,
"%d%c%d", q.num, sep, q.den);
893 int64_t ts,
const AVRational *time_base,
int is_duration)
897 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
900 double d = ts * av_q2d(*time_base);
911 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
919 const uint8_t *data,
int size)
922 int offset = 0, l,
i;
924 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
925 av_bprintf(&bp,
"\n");
927 av_bprintf(&bp,
"%08x: ", offset);
929 for (
i = 0;
i < l;
i++) {
930 av_bprintf(&bp,
"%02x", data[
i]);
932 av_bprintf(&bp,
" ");
934 av_bprint_chars(&bp,
' ', 41 - 2 *
i -
i / 2);
935 for (
i = 0;
i < l;
i++)
936 av_bprint_chars(&bp, data[
i] - 32U < 95 ? data[
i] :
'.', 1);
937 av_bprintf(&bp,
"\n");
943 av_bprint_finalize(&bp, NULL);
947 const uint8_t *data,
int size)
949 char *p, buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };
954 av_hash_update(
hash, data, size);
955 snprintf(buf,
sizeof(buf),
"%s:", av_hash_get_name(
hash));
956 p = buf + strlen(buf);
957 av_hash_final_hex(
hash, p, buf +
sizeof(buf) - p);
962 uint8_t *data,
int size,
const char *format,
963 int columns,
int bytes,
int offset_add)
966 int offset = 0, l,
i;
968 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
969 av_bprintf(&bp,
"\n");
971 av_bprintf(&bp,
"%08x: ", offset);
972 l = FFMIN(size, columns);
973 for (
i = 0;
i < l;
i++) {
974 if (bytes == 1) av_bprintf(&bp, format, *data);
975 else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
976 else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
980 av_bprintf(&bp,
"\n");
981 offset += offset_add;
984 av_bprint_finalize(&bp, NULL);
987#define writer_w8(wctx_, b_) (wctx_)->writer_w8(wctx_, b_)
988#define writer_put_str(wctx_, str_) (wctx_)->writer_put_str(wctx_, str_)
989#define writer_printf(wctx_, fmt_, ...) (wctx_)->writer_printf(wctx_, fmt_, __VA_ARGS__)
991#define MAX_REGISTERED_WRITERS_NB 64
1000 return AVERROR(ENOMEM);
1020#define DEFINE_WRITER_CLASS(name) \
1021static const char *name##_get_name(void *ctx) \
1025static const AVClass name##_class = { \
1026 .class_name = #name, \
1027 .item_name = name##_get_name, \
1028 .option = name##_options \
1034 const AVClass *
class;
1041#define OFFSET(x) offsetof(DefaultContext, x)
1044 {
"noprint_wrappers",
"do not print headers and footers",
OFFSET(noprint_wrappers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1045 {
"nw",
"do not print headers and footers",
OFFSET(noprint_wrappers), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1046 {
"nokey",
"force no key printing",
OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1047 {
"nk",
"force no key printing",
OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1057 for (i = 0; src[i] && i < dst_size-1; i++)
1058 dst[i] = av_toupper(src[i]);
1072 if (parent_section &&
1127 .priv_class = &default_class,
1135static const char *
c_escape_str(AVBPrint *dst,
const char *src,
const char sep,
void *log_ctx)
1139 for (p = src; *p; p++) {
1141 case '\b': av_bprintf(dst,
"%s",
"\\b");
break;
1142 case '\f': av_bprintf(dst,
"%s",
"\\f");
break;
1143 case '\n': av_bprintf(dst,
"%s",
"\\n");
break;
1144 case '\r': av_bprintf(dst,
"%s",
"\\r");
break;
1145 case '\\': av_bprintf(dst,
"%s",
"\\\\");
break;
1148 av_bprint_chars(dst,
'\\', 1);
1149 av_bprint_chars(dst, *p, 1);
1158static const char *
csv_escape_str(AVBPrint *dst,
const char *src,
const char sep,
void *log_ctx)
1160 char meta_chars[] = { sep,
'"',
'\n',
'\r',
'\0' };
1161 int needs_quoting = !!src[strcspn(src, meta_chars)];
1164 av_bprint_chars(dst,
'"', 1);
1166 for (; *src; src++) {
1168 av_bprint_chars(dst,
'"', 1);
1169 av_bprint_chars(dst, *src, 1);
1172 av_bprint_chars(dst,
'"', 1);
1176static const char *
none_escape_str(AVBPrint *dst,
const char *src,
const char sep,
void *log_ctx)
1182 const AVClass *
class;
1188 const char * (*escape_str)(AVBPrint *dst,
const char *src,
const char sep,
void *log_ctx);
1195#define OFFSET(x) offsetof(CompactContext, x)
1198 {
"item_sep",
"set item separator",
OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=
"|"}, 0, 0 },
1199 {
"s",
"set item separator",
OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=
"|"}, 0, 0 },
1200 {
"nokey",
"force no key printing",
OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1201 {
"nk",
"force no key printing",
OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1202 {
"escape",
"set escape mode",
OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str=
"c"}, 0, 0 },
1203 {
"e",
"set escape mode",
OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str=
"c"}, 0, 0 },
1204 {
"print_section",
"print section name",
OFFSET(
print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1216 av_log(wctx, AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
1218 return AVERROR(EINVAL);
1226 av_log(wctx, AV_LOG_ERROR,
"Unknown escape mode '%s'\n", compact->
escape_mode_str);
1227 return AVERROR(EINVAL);
1281 if (!compact->
nokey)
1283 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1285 av_bprint_finalize(&buf, NULL);
1293 if (!compact->
nokey)
1307 .priv_class = &compact_class,
1313#define OFFSET(x) offsetof(CompactContext, x)
1316 {
"item_sep",
"set item separator",
OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=
","}, 0, 0 },
1317 {
"s",
"set item separator",
OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=
","}, 0, 0 },
1318 {
"nokey",
"force no key printing",
OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1319 {
"nk",
"force no key printing",
OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1320 {
"escape",
"set escape mode",
OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str=
"csv"}, 0, 0 },
1321 {
"e",
"set escape mode",
OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str=
"csv"}, 0, 0 },
1322 {
"print_section",
"print section name",
OFFSET(
print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1338 .priv_class = &csv_class,
1344 const AVClass *
class;
1351#define OFFSET(x) offsetof(FlatContext, x)
1354 {
"sep_char",
"set separator",
OFFSET(sep_str), AV_OPT_TYPE_STRING, {.str=
"."}, 0, 0 },
1355 {
"s",
"set separator",
OFFSET(sep_str), AV_OPT_TYPE_STRING, {.str=
"."}, 0, 0 },
1356 {
"hierarchical",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1357 {
"h",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1367 if (strlen(flat->
sep_str) != 1) {
1368 av_log(wctx, AV_LOG_ERROR,
"Item separator '%s' specified, but must contain a single character\n",
1370 return AVERROR(EINVAL);
1381 for (p = src; *p; p++) {
1382 if (!((*p >=
'0' && *p <=
'9') ||
1383 (*p >=
'a' && *p <=
'z') ||
1384 (*p >=
'A' && *p <=
'Z')))
1385 av_bprint_chars(dst,
'_', 1);
1387 av_bprint_chars(dst, *p, 1);
1396 for (p = src; *p; p++) {
1398 case '\n': av_bprintf(dst,
"%s",
"\\n");
break;
1399 case '\r': av_bprintf(dst,
"%s",
"\\r");
break;
1400 case '\\': av_bprintf(dst,
"%s",
"\\\\");
break;
1401 case '"': av_bprintf(dst,
"%s",
"\\\"");
break;
1402 case '`': av_bprintf(dst,
"%s",
"\\`");
break;
1403 case '$': av_bprintf(dst,
"%s",
"\\$");
break;
1404 default: av_bprint_chars(dst, *p, 1);
break;
1419 av_bprint_clear(buf);
1420 if (!parent_section)
1431 av_bprintf(buf,
"%d%s", n, flat->
sep_str);
1447 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1449 av_bprint_clear(&buf);
1451 av_bprint_finalize(&buf, NULL);
1462 .priv_class = &flat_class,
1468 const AVClass *
class;
1473#define OFFSET(x) offsetof(INIContext, x)
1476 {
"hierarchical",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1477 {
"h",
"specify if the section specification should be hierarchical",
OFFSET(hierarchical), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
1488 while ((c = src[i++])) {
1490 case '\b': av_bprintf(dst,
"%s",
"\\b");
break;
1491 case '\f': av_bprintf(dst,
"%s",
"\\f");
break;
1492 case '\n': av_bprintf(dst,
"%s",
"\\n");
break;
1493 case '\r': av_bprintf(dst,
"%s",
"\\r");
break;
1494 case '\t': av_bprintf(dst,
"%s",
"\\t");
break;
1498 case ':' : av_bprint_chars(dst,
'\\', 1);
1500 if ((
unsigned char)c < 32)
1501 av_bprintf(dst,
"\\x00%02x", c & 0xff);
1503 av_bprint_chars(dst, c, 1);
1518 av_bprint_clear(buf);
1519 if (!parent_section) {
1530 av_bprintf(buf,
"%s%s", buf->str[0] ?
"." :
"", wctx->
section[wctx->
level]->
name);
1535 av_bprintf(buf,
".%d", n);
1547 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1549 av_bprint_clear(&buf);
1551 av_bprint_finalize(&buf, NULL);
1566 .priv_class = &ini_class,
1572 const AVClass *
class;
1579#define OFFSET(x) offsetof(JSONContext, x)
1582 {
"compact",
"enable compact output",
OFFSET(compact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1583 {
"c",
"enable compact output",
OFFSET(compact), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1601 static const char json_escape[] = {
'"',
'\\',
'\b',
'\f',
'\n',
'\r',
'\t', 0};
1602 static const char json_subst[] = {
'"',
'\\',
'b',
'f',
'n',
'r',
't', 0};
1605 for (p = src; *p; p++) {
1606 char *s = strchr(json_escape, *p);
1608 av_bprint_chars(dst,
'\\', 1);
1609 av_bprint_chars(dst, json_subst[s - json_escape], 1);
1610 }
else if ((
unsigned char)*p < 32) {
1611 av_bprintf(dst,
"\\u00%02x", *p & 0xff);
1613 av_bprint_chars(dst, *p, 1);
1619#define JSON_INDENT() writer_printf(wctx, "%*c", json->indent_level * 4, ' ')
1636 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1656 av_bprint_finalize(&buf, NULL);
1665 if (wctx->
level == 0) {
1683 const char *key,
const char *value)
1687 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1689 av_bprint_clear(&buf);
1691 av_bprint_finalize(&buf, NULL);
1719 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1721 av_bprint_finalize(&buf, NULL);
1733 .priv_class = &json_class,
1739 const AVClass *
class;
1747#define OFFSET(x) offsetof(XMLContext, x)
1750 {
"fully_qualified",
"specify if the output should be fully qualified",
OFFSET(fully_qualified), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1751 {
"q",
"specify if the output should be fully qualified",
OFFSET(fully_qualified), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1752 {
"xsd_strict",
"ensure that the output is XSD compliant",
OFFSET(xsd_strict), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1753 {
"x",
"ensure that the output is XSD compliant",
OFFSET(xsd_strict), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
1765#define CHECK_COMPLIANCE(opt, opt_name) \
1767 av_log(wctx, AV_LOG_ERROR, \
1768 "XSD-compliant output selected but option '%s' was selected, XML output may be non-compliant.\n" \
1769 "You need to disable such option with '-no%s'\n", opt_name, opt_name); \
1770 return AVERROR(EINVAL); \
1780#define XML_INDENT() writer_printf(wctx, "%*c", xml->indent_level * 4, ' ')
1789 if (wctx->
level == 0) {
1790 const char *qual =
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
1791 "xmlns:ffprobe=\"http://www.ffmpeg.org/schema/ffprobe\" "
1792 "xsi:schemaLocation=\"http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd\"";
1794 writer_put_str(wctx,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1827 if (wctx->
level == 0) {
1847 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
1851 av_bprint_escape(&buf, key, NULL,
1852 AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
1855 av_bprint_clear(&buf);
1857 av_bprint_escape(&buf, value, NULL,
1858 AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
1864 av_bprint_escape(&buf, value, NULL,
1865 AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
1869 av_bprint_finalize(&buf, NULL);
1888 .priv_class = &xml_class,
1903#define print_fmt(k, f, ...) do { \
1904 av_bprint_clear(&pbuf); \
1905 av_bprintf(&pbuf, f, __VA_ARGS__); \
1906 writer_print_string(w, k, pbuf.str, 0); \
1909#define print_list_fmt(k, f, n, ...) do { \
1910 av_bprint_clear(&pbuf); \
1911 for (int idx = 0; idx < n; idx++) { \
1913 av_bprint_chars(&pbuf, ' ', 1); \
1914 av_bprintf(&pbuf, f, __VA_ARGS__); \
1916 writer_print_string(w, k, pbuf.str, 0); \
1919#define print_int(k, v) writer_print_integer(w, k, v)
1920#define print_q(k, v, s) writer_print_rational(w, k, v, s)
1921#define print_str(k, v) writer_print_string(w, k, v, 0)
1922#define print_str_opt(k, v) writer_print_string(w, k, v, PRINT_STRING_OPT)
1923#define print_str_validate(k, v) writer_print_string(w, k, v, PRINT_STRING_VALIDATE)
1924#define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
1925#define print_ts(k, v) writer_print_ts(w, k, v, 0)
1926#define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
1927#define print_duration_ts(k, v) writer_print_ts(w, k, v, 1)
1928#define print_val(k, v, u) do { \
1929 struct unit_value uv; \
1932 writer_print_string(w, k, value_string(val_str, sizeof(val_str), uv), 0); \
1935#define print_section_header(s) writer_print_section_header(w, s)
1936#define print_section_footer(s) writer_print_section_footer(w, s)
1938#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
1940 ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
1943 memset( (ptr) + (cur_n), 0, ((new_n) - (cur_n)) * sizeof(*(ptr)) ); \
1948 const AVDictionaryEntry *tag = NULL;
1955 while ((tag = av_dict_get(tags,
"", tag, AV_DICT_IGNORE_SUFFIX))) {
1970 const AVDOVIRpuDataHeader *hdr = av_dovi_get_header(dovi);
1971 const AVDOVIDataMapping *mapping = av_dovi_get_mapping(dovi);
1972 const AVDOVIColorMetadata *color = av_dovi_get_color(dovi);
1975 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
1979 print_int(
"rpu_format", hdr->rpu_format);
1980 print_int(
"vdr_rpu_profile", hdr->vdr_rpu_profile);
1981 print_int(
"vdr_rpu_level", hdr->vdr_rpu_level);
1982 print_int(
"chroma_resampling_explicit_filter_flag",
1983 hdr->chroma_resampling_explicit_filter_flag);
1984 print_int(
"coef_data_type", hdr->coef_data_type);
1985 print_int(
"coef_log2_denom", hdr->coef_log2_denom);
1986 print_int(
"vdr_rpu_normalized_idc", hdr->vdr_rpu_normalized_idc);
1987 print_int(
"bl_video_full_range_flag", hdr->bl_video_full_range_flag);
1988 print_int(
"bl_bit_depth", hdr->bl_bit_depth);
1989 print_int(
"el_bit_depth", hdr->el_bit_depth);
1990 print_int(
"vdr_bit_depth", hdr->vdr_bit_depth);
1991 print_int(
"spatial_resampling_filter_flag",
1992 hdr->spatial_resampling_filter_flag);
1993 print_int(
"el_spatial_resampling_filter_flag",
1994 hdr->el_spatial_resampling_filter_flag);
1995 print_int(
"disable_residual_flag", hdr->disable_residual_flag);
1998 print_int(
"vdr_rpu_id", mapping->vdr_rpu_id);
1999 print_int(
"mapping_color_space", mapping->mapping_color_space);
2001 mapping->mapping_chroma_format_idc);
2003 print_int(
"nlq_method_idc", mapping->nlq_method_idc);
2004 switch (mapping->nlq_method_idc) {
2005 case AV_DOVI_NLQ_NONE:
2006 print_str(
"nlq_method_idc_name",
"none");
2008 case AV_DOVI_NLQ_LINEAR_DZ:
2009 print_str(
"nlq_method_idc_name",
"linear_dz");
2012 print_str(
"nlq_method_idc_name",
"unknown");
2016 print_int(
"num_x_partitions", mapping->num_x_partitions);
2017 print_int(
"num_y_partitions", mapping->num_y_partitions);
2021 for (
int c = 0; c < 3; c++) {
2022 const AVDOVIReshapingCurve *curve = &mapping->curves[c];
2025 print_list_fmt(
"pivots",
"%"PRIu16, curve->num_pivots, curve->pivots[idx]);
2028 for (
int i = 0; i < curve->num_pivots - 1; i++) {
2031 print_int(
"mapping_idc", curve->mapping_idc[i]);
2032 switch (curve->mapping_idc[i]) {
2033 case AV_DOVI_MAPPING_POLYNOMIAL:
2034 print_str(
"mapping_idc_name",
"polynomial");
2035 print_int(
"poly_order", curve->poly_order[i]);
2037 curve->poly_order[i] + 1,
2038 curve->poly_coef[i][idx]);
2040 case AV_DOVI_MAPPING_MMR:
2042 print_int(
"mmr_order", curve->mmr_order[i]);
2043 print_int(
"mmr_constant", curve->mmr_constant[i]);
2045 curve->mmr_order[i] * 7,
2046 curve->mmr_coef[i][0][idx]);
2049 print_str(
"mapping_idc_name",
"unknown");
2060 if (mapping->nlq_method_idc != AV_DOVI_NLQ_NONE) {
2061 const AVDOVINLQParams *nlq = &mapping->nlq[c];
2062 print_int(
"nlq_offset", nlq->nlq_offset);
2063 print_int(
"vdr_in_max", nlq->vdr_in_max);
2065 switch (mapping->nlq_method_idc) {
2066 case AV_DOVI_NLQ_LINEAR_DZ:
2067 print_int(
"linear_deadzone_slope", nlq->linear_deadzone_slope);
2068 print_int(
"linear_deadzone_threshold", nlq->linear_deadzone_threshold);
2081 print_int(
"dm_metadata_id", color->dm_metadata_id);
2082 print_int(
"scene_refresh_flag", color->scene_refresh_flag);
2084 FF_ARRAY_ELEMS(color->ycc_to_rgb_matrix),
2085 color->ycc_to_rgb_matrix[idx].num,
2086 color->ycc_to_rgb_matrix[idx].den);
2088 FF_ARRAY_ELEMS(color->ycc_to_rgb_offset),
2089 color->ycc_to_rgb_offset[idx].num,
2090 color->ycc_to_rgb_offset[idx].den);
2092 FF_ARRAY_ELEMS(color->rgb_to_lms_matrix),
2093 color->rgb_to_lms_matrix[idx].num,
2094 color->rgb_to_lms_matrix[idx].den);
2095 print_int(
"signal_eotf", color->signal_eotf);
2096 print_int(
"signal_eotf_param0", color->signal_eotf_param0);
2097 print_int(
"signal_eotf_param1", color->signal_eotf_param1);
2098 print_int(
"signal_eotf_param2", color->signal_eotf_param2);
2099 print_int(
"signal_bit_depth", color->signal_bit_depth);
2100 print_int(
"signal_color_space", color->signal_color_space);
2101 print_int(
"signal_chroma_format", color->signal_chroma_format);
2102 print_int(
"signal_full_range_flag", color->signal_full_range_flag);
2103 print_int(
"source_min_pq", color->source_min_pq);
2104 print_int(
"source_max_pq", color->source_max_pq);
2105 print_int(
"source_diagonal", color->source_diagonal);
2107 av_bprint_finalize(&pbuf, NULL);
2115 print_int(
"application version", metadata->application_version);
2116 print_int(
"num_windows", metadata->num_windows);
2117 for (
int n = 1; n < metadata->num_windows; n++) {
2118 const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2119 print_q(
"window_upper_left_corner_x",
2120 params->window_upper_left_corner_x,
'/');
2121 print_q(
"window_upper_left_corner_y",
2122 params->window_upper_left_corner_y,
'/');
2123 print_q(
"window_lower_right_corner_x",
2124 params->window_lower_right_corner_x,
'/');
2125 print_q(
"window_lower_right_corner_y",
2126 params->window_lower_right_corner_y,
'/');
2127 print_q(
"window_upper_left_corner_x",
2128 params->window_upper_left_corner_x,
'/');
2129 print_q(
"window_upper_left_corner_y",
2130 params->window_upper_left_corner_y,
'/');
2132 params->center_of_ellipse_x ) ;
2134 params->center_of_ellipse_y );
2136 params->rotation_angle);
2137 print_int(
"semimajor_axis_internal_ellipse",
2138 params->semimajor_axis_internal_ellipse);
2139 print_int(
"semimajor_axis_external_ellipse",
2140 params->semimajor_axis_external_ellipse);
2141 print_int(
"semiminor_axis_external_ellipse",
2142 params->semiminor_axis_external_ellipse);
2144 params->overlap_process_option);
2146 print_q(
"targeted_system_display_maximum_luminance",
2147 metadata->targeted_system_display_maximum_luminance,
'/');
2148 if (metadata->targeted_system_display_actual_peak_luminance_flag) {
2149 print_int(
"num_rows_targeted_system_display_actual_peak_luminance",
2150 metadata->num_rows_targeted_system_display_actual_peak_luminance);
2151 print_int(
"num_cols_targeted_system_display_actual_peak_luminance",
2152 metadata->num_cols_targeted_system_display_actual_peak_luminance);
2153 for (
int i = 0; i < metadata->num_rows_targeted_system_display_actual_peak_luminance; i++) {
2154 for (
int j = 0; j < metadata->num_cols_targeted_system_display_actual_peak_luminance; j++) {
2155 print_q(
"targeted_system_display_actual_peak_luminance",
2156 metadata->targeted_system_display_actual_peak_luminance[i][j],
'/');
2160 for (
int n = 0; n < metadata->num_windows; n++) {
2161 const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2162 for (
int i = 0; i < 3; i++) {
2163 print_q(
"maxscl",params->maxscl[i],
'/');
2166 params->average_maxrgb,
'/');
2167 print_int(
"num_distribution_maxrgb_percentiles",
2168 params->num_distribution_maxrgb_percentiles);
2169 for (
int i = 0; i < params->num_distribution_maxrgb_percentiles; i++) {
2170 print_int(
"distribution_maxrgb_percentage",
2171 params->distribution_maxrgb[i].percentage);
2172 print_q(
"distribution_maxrgb_percentile",
2173 params->distribution_maxrgb[i].percentile,
'/');
2175 print_q(
"fraction_bright_pixels",
2176 params->fraction_bright_pixels,
'/');
2178 if (metadata->mastering_display_actual_peak_luminance_flag) {
2179 print_int(
"num_rows_mastering_display_actual_peak_luminance",
2180 metadata->num_rows_mastering_display_actual_peak_luminance);
2181 print_int(
"num_cols_mastering_display_actual_peak_luminance",
2182 metadata->num_cols_mastering_display_actual_peak_luminance);
2183 for (
int i = 0; i < metadata->num_rows_mastering_display_actual_peak_luminance; i++) {
2184 for (
int j = 0; j < metadata->num_cols_mastering_display_actual_peak_luminance; j++) {
2185 print_q(
"mastering_display_actual_peak_luminance",
2186 metadata->mastering_display_actual_peak_luminance[i][j],
'/');
2191 for (
int n = 0; n < metadata->num_windows; n++) {
2192 const AVHDRPlusColorTransformParams *params = &metadata->params[n];
2193 if (params->tone_mapping_flag) {
2194 print_q(
"knee_point_x", params->knee_point_x,
'/');
2195 print_q(
"knee_point_y", params->knee_point_y,
'/');
2197 params->num_bezier_curve_anchors );
2198 for (
int i = 0; i < params->num_bezier_curve_anchors; i++) {
2199 print_q(
"bezier_curve_anchors",
2200 params->bezier_curve_anchors[i],
'/');
2203 if (params->color_saturation_mapping_flag) {
2204 print_q(
"color_saturation_weight",
2205 params->color_saturation_weight,
'/');
2214 print_int(
"system_start_code", metadata->system_start_code);
2215 print_int(
"num_windows", metadata->num_windows);
2217 for (
int n = 0; n < metadata->num_windows; n++) {
2218 const AVHDRVividColorTransformParams *params = &metadata->params[n];
2220 print_q(
"minimum_maxrgb", params->minimum_maxrgb,
'/');
2221 print_q(
"average_maxrgb", params->average_maxrgb,
'/');
2222 print_q(
"variance_maxrgb", params->variance_maxrgb,
'/');
2223 print_q(
"maximum_maxrgb", params->maximum_maxrgb,
'/');
2226 for (
int n = 0; n < metadata->num_windows; n++) {
2227 const AVHDRVividColorTransformParams *params = &metadata->params[n];
2229 print_int(
"tone_mapping_mode_flag", params->tone_mapping_mode_flag);
2230 print_int(
"tone_mapping_param_num", params->tone_mapping_param_num);
2231 if (params->tone_mapping_mode_flag) {
2232 for (
int i = 0; i < params->tone_mapping_param_num; i++) {
2233 const AVHDRVividColorToneMappingParams *tm_params = ¶ms->tm_params[i];
2235 print_q(
"targeted_system_display_maximum_luminance",
2236 tm_params->targeted_system_display_maximum_luminance,
'/');
2237 print_int(
"base_enable_flag", tm_params->base_enable_flag);
2238 if (tm_params->base_enable_flag) {
2239 print_q(
"base_param_m_p", tm_params->base_param_m_p,
'/');
2240 print_q(
"base_param_m_m", tm_params->base_param_m_m,
'/');
2241 print_q(
"base_param_m_a", tm_params->base_param_m_a,
'/');
2242 print_q(
"base_param_m_b", tm_params->base_param_m_b,
'/');
2243 print_q(
"base_param_m_n", tm_params->base_param_m_n,
'/');
2245 print_int(
"base_param_k1", tm_params->base_param_k1);
2246 print_int(
"base_param_k2", tm_params->base_param_k2);
2247 print_int(
"base_param_k3", tm_params->base_param_k3);
2248 print_int(
"base_param_Delta_enable_mode",
2249 tm_params->base_param_Delta_enable_mode);
2250 print_q(
"base_param_Delta", tm_params->base_param_Delta,
'/');
2252 print_int(
"3Spline_enable_flag", tm_params->three_Spline_enable_flag);
2253 if (tm_params->three_Spline_enable_flag) {
2254 print_int(
"3Spline_num", tm_params->three_Spline_num);
2255 print_int(
"3Spline_TH_mode", tm_params->three_Spline_TH_mode);
2257 for (
int j = 0; j < tm_params->three_Spline_num; j++) {
2258 print_q(
"3Spline_TH_enable_MB", tm_params->three_Spline_TH_enable_MB,
'/');
2259 print_q(
"3Spline_TH_enable", tm_params->three_Spline_TH_enable,
'/');
2260 print_q(
"3Spline_TH_Delta1", tm_params->three_Spline_TH_Delta1,
'/');
2261 print_q(
"3Spline_TH_Delta2", tm_params->three_Spline_TH_Delta2,
'/');
2262 print_q(
"3Spline_enable_Strength", tm_params->three_Spline_enable_Strength,
'/');
2268 print_int(
"color_saturation_mapping_flag", params->color_saturation_mapping_flag);
2269 if (params->color_saturation_mapping_flag) {
2270 print_int(
"color_saturation_num", params->color_saturation_num);
2271 for (
int i = 0; i < params->color_saturation_num; i++) {
2272 print_q(
"color_saturation_gain", params->color_saturation_gain[i],
'/');
2279 AVCodecParameters *par,
2280 const AVPacketSideData *side_data,
2288 for (i = 0; i < nb_side_data; i++) {
2289 const AVPacketSideData *sd = &side_data[i];
2290 const char *
name = av_packet_side_data_name(sd->type);
2294 if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2296 print_int(
"rotation", av_display_rotation_get((int32_t *)sd->data));
2297 }
else if (sd->type == AV_PKT_DATA_STEREO3D) {
2298 const AVStereo3D *stereo = (AVStereo3D *)sd->data;
2299 print_str(
"type", av_stereo3d_type_name(stereo->type));
2300 print_int(
"inverted", !!(stereo->flags & AV_STEREO3D_FLAG_INVERT));
2301 }
else if (sd->type == AV_PKT_DATA_SPHERICAL) {
2302 const AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
2303 print_str(
"projection", av_spherical_projection_name(spherical->projection));
2304 if (spherical->projection == AV_SPHERICAL_CUBEMAP) {
2305 print_int(
"padding", spherical->padding);
2306 }
else if (spherical->projection == AV_SPHERICAL_EQUIRECTANGULAR_TILE) {
2308 av_spherical_tile_bounds(spherical, par->width, par->height,
2316 print_int(
"yaw", (
double) spherical->yaw / (1 << 16));
2317 print_int(
"pitch", (
double) spherical->pitch / (1 << 16));
2318 print_int(
"roll", (
double) spherical->roll / (1 << 16));
2319 }
else if (sd->type == AV_PKT_DATA_SKIP_SAMPLES && sd->size == 10) {
2320 print_int(
"skip_samples", AV_RL32(sd->data));
2321 print_int(
"discard_padding", AV_RL32(sd->data + 4));
2322 print_int(
"skip_reason", AV_RL8(sd->data + 8));
2323 print_int(
"discard_reason", AV_RL8(sd->data + 9));
2324 }
else if (sd->type == AV_PKT_DATA_MASTERING_DISPLAY_METADATA) {
2325 AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;
2327 if (metadata->has_primaries) {
2328 print_q(
"red_x", metadata->display_primaries[0][0],
'/');
2329 print_q(
"red_y", metadata->display_primaries[0][1],
'/');
2330 print_q(
"green_x", metadata->display_primaries[1][0],
'/');
2331 print_q(
"green_y", metadata->display_primaries[1][1],
'/');
2332 print_q(
"blue_x", metadata->display_primaries[2][0],
'/');
2333 print_q(
"blue_y", metadata->display_primaries[2][1],
'/');
2335 print_q(
"white_point_x", metadata->white_point[0],
'/');
2336 print_q(
"white_point_y", metadata->white_point[1],
'/');
2339 if (metadata->has_luminance) {
2340 print_q(
"min_luminance", metadata->min_luminance,
'/');
2341 print_q(
"max_luminance", metadata->max_luminance,
'/');
2343 }
else if (sd->type == AV_PKT_DATA_CONTENT_LIGHT_LEVEL) {
2344 AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data;
2345 print_int(
"max_content", metadata->MaxCLL);
2346 print_int(
"max_average", metadata->MaxFALL);
2347 }
else if (sd->type == AV_PKT_DATA_DOVI_CONF) {
2348 AVDOVIDecoderConfigurationRecord *dovi = (AVDOVIDecoderConfigurationRecord *)sd->data;
2349 print_int(
"dv_version_major", dovi->dv_version_major);
2350 print_int(
"dv_version_minor", dovi->dv_version_minor);
2351 print_int(
"dv_profile", dovi->dv_profile);
2353 print_int(
"rpu_present_flag", dovi->rpu_present_flag);
2354 print_int(
"el_present_flag", dovi->el_present_flag);
2355 print_int(
"bl_present_flag", dovi->bl_present_flag);
2356 print_int(
"dv_bl_signal_compatibility_id", dovi->dv_bl_signal_compatibility_id);
2357 }
else if (sd->type == AV_PKT_DATA_AUDIO_SERVICE_TYPE) {
2358 enum AVAudioServiceType *t = (
enum AVAudioServiceType *)sd->data;
2360 }
else if (sd->type == AV_PKT_DATA_MPEGTS_STREAM_ID) {
2362 }
else if (sd->type == AV_PKT_DATA_CPB_PROPERTIES) {
2363 const AVCPBProperties *prop = (AVCPBProperties *)sd->data;
2364 print_int(
"max_bitrate", prop->max_bitrate);
2365 print_int(
"min_bitrate", prop->min_bitrate);
2366 print_int(
"avg_bitrate", prop->avg_bitrate);
2367 print_int(
"buffer_size", prop->buffer_size);
2368 print_int(
"vbv_delay", prop->vbv_delay);
2369 }
else if (sd->type == AV_PKT_DATA_WEBVTT_IDENTIFIER ||
2370 sd->type == AV_PKT_DATA_WEBVTT_SETTINGS) {
2374 }
else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
2384 const char *val = av_color_range_name(color_range);
2385 if (!val || color_range == AVCOL_RANGE_UNSPECIFIED) {
2394 const char *val = av_color_space_name(color_space);
2395 if (!val || color_space == AVCOL_SPC_UNSPECIFIED) {
2404 const char *val = av_color_primaries_name(color_primaries);
2405 if (!val || color_primaries == AVCOL_PRI_UNSPECIFIED) {
2414 const char *val = av_color_transfer_name(color_trc);
2415 if (!val || color_trc == AVCOL_TRC_UNSPECIFIED) {
2424 const char *val = av_chroma_location_name(chroma_location);
2425 if (!val || chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
2487 AVStream *st = ifile->
streams[pkt->stream_index].
st;
2491 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2495 s = av_get_media_type_string(st->codecpar->codec_type);
2498 print_int(
"stream_index", pkt->stream_index);
2500 print_time(
"pts_time", pkt->pts, &st->time_base);
2502 print_time(
"dts_time", pkt->dts, &st->time_base);
2506 if (pkt->pos != -1)
print_fmt (
"pos",
"%"PRId64, pkt->pos);
2508 print_fmt(
"flags",
"%c%c", pkt->flags & AV_PKT_FLAG_KEY ?
'K' :
'_',
2509 pkt->flags & AV_PKT_FLAG_DISCARD ?
'D' :
'_');
2511 if (pkt->side_data_elems) {
2513 const uint8_t *side_metadata;
2515 side_metadata = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &size);
2517 AVDictionary *dict = NULL;
2518 if (av_packet_unpack_dictionary(side_metadata, size, &dict) >= 0)
2520 av_dict_free(&dict);
2533 av_bprint_finalize(&pbuf, NULL);
2538 AVFormatContext *fmt_ctx)
2542 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2548 print_time(
"pts_time", sub->pts, &AV_TIME_BASE_Q);
2550 print_int (
"start_display_time", sub->start_display_time);
2551 print_int (
"end_display_time", sub->end_display_time);
2552 print_int (
"num_rects", sub->num_rects);
2556 av_bprint_finalize(&pbuf, NULL);
2561 AVFormatContext *fmt_ctx)
2568 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2572 s = av_get_media_type_string(stream->codecpar->codec_type);
2575 print_int(
"stream_index", stream->index);
2576 print_int(
"key_frame", frame->key_frame);
2578 print_time(
"pts_time", frame->pts, &stream->time_base);
2579 print_ts (
"pkt_dts", frame->pkt_dts);
2580 print_time(
"pkt_dts_time", frame->pkt_dts, &stream->time_base);
2581 print_ts (
"best_effort_timestamp", frame->best_effort_timestamp);
2582 print_time(
"best_effort_timestamp_time", frame->best_effort_timestamp, &stream->time_base);
2585 if (frame->pkt_pos != -1)
print_fmt (
"pkt_pos",
"%"PRId64, frame->pkt_pos);
2590 switch (stream->codecpar->codec_type) {
2593 case AVMEDIA_TYPE_VIDEO:
2596 s = av_get_pix_fmt_name(frame->format);
2599 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);
2601 print_q(
"sample_aspect_ratio", sar,
':');
2605 print_fmt(
"pict_type",
"%c", av_get_picture_type_char(frame->pict_type));
2606 print_int(
"coded_picture_number", frame->coded_picture_number);
2607 print_int(
"display_picture_number", frame->display_picture_number);
2608 print_int(
"interlaced_frame", frame->interlaced_frame);
2609 print_int(
"top_field_first", frame->top_field_first);
2610 print_int(
"repeat_pict", frame->repeat_pict);
2619 case AVMEDIA_TYPE_AUDIO:
2620 s = av_get_sample_fmt_name(frame->format);
2623 print_int(
"nb_samples", frame->nb_samples);
2624 print_int(
"channels", frame->ch_layout.nb_channels);
2625 if (frame->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
2626 av_channel_layout_describe(&frame->ch_layout, val_str,
sizeof(val_str));
2636 if (frame->nb_side_data) {
2638 for (i = 0; i < frame->nb_side_data; i++) {
2639 AVFrameSideData *sd = frame->side_data[i];
2643 name = av_frame_side_data_name(sd->type);
2645 if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) {
2647 print_int(
"rotation", av_display_rotation_get((int32_t *)sd->data));
2648 }
else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) {
2650 }
else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) {
2651 char tcbuf[AV_TIMECODE_STR_SIZE];
2652 av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
2654 }
else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
2655 uint32_t *tc = (uint32_t*)sd->data;
2656 int m = FFMIN(tc[0],3);
2658 for (
int j = 1; j <= m ; j++) {
2659 char tcbuf[AV_TIMECODE_STR_SIZE];
2660 av_timecode_make_smpte_tc_string2(tcbuf, stream->avg_frame_rate, tc[j], 0, 0);
2666 }
else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
2667 AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;
2669 if (metadata->has_primaries) {
2670 print_q(
"red_x", metadata->display_primaries[0][0],
'/');
2671 print_q(
"red_y", metadata->display_primaries[0][1],
'/');
2672 print_q(
"green_x", metadata->display_primaries[1][0],
'/');
2673 print_q(
"green_y", metadata->display_primaries[1][1],
'/');
2674 print_q(
"blue_x", metadata->display_primaries[2][0],
'/');
2675 print_q(
"blue_y", metadata->display_primaries[2][1],
'/');
2677 print_q(
"white_point_x", metadata->white_point[0],
'/');
2678 print_q(
"white_point_y", metadata->white_point[1],
'/');
2681 if (metadata->has_luminance) {
2682 print_q(
"min_luminance", metadata->min_luminance,
'/');
2683 print_q(
"max_luminance", metadata->max_luminance,
'/');
2685 }
else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_PLUS) {
2686 AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
2688 }
else if (sd->type == AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) {
2689 AVContentLightMetadata *metadata = (AVContentLightMetadata *)sd->data;
2690 print_int(
"max_content", metadata->MaxCLL);
2691 print_int(
"max_average", metadata->MaxFALL);
2692 }
else if (sd->type == AV_FRAME_DATA_ICC_PROFILE) {
2693 const AVDictionaryEntry *tag = av_dict_get(sd->metadata,
"name", NULL, AV_DICT_MATCH_CASE);
2697 }
else if (sd->type == AV_FRAME_DATA_DOVI_METADATA) {
2699 }
else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
2700 AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
2710 av_bprint_finalize(&pbuf, NULL);
2716 AVFrame *frame, AVPacket *pkt,
2719 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
2720 AVCodecContext *dec_ctx = ifile->
streams[pkt->stream_index].
dec_ctx;
2721 AVCodecParameters *par = ifile->
streams[pkt->stream_index].
st->codecpar;
2723 int ret = 0, got_frame = 0;
2727 switch (par->codec_type) {
2728 case AVMEDIA_TYPE_VIDEO:
2729 case AVMEDIA_TYPE_AUDIO:
2731 ret = avcodec_send_packet(dec_ctx, pkt);
2732 if (ret == AVERROR(EAGAIN)) {
2734 }
else if (ret >= 0 || ret == AVERROR_EOF) {
2740 ret = avcodec_receive_frame(dec_ctx, frame);
2743 }
else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
2749 case AVMEDIA_TYPE_SUBTITLE:
2751 ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_frame, pkt);
2764 int is_sub = (par->codec_type == AVMEDIA_TYPE_SUBTITLE);
2774 avsubtitle_free(&sub);
2777 return got_frame || *packet_new;
2782 av_log(log_ctx, log_level,
"id:%d", interval->
id);
2785 av_log(log_ctx, log_level,
" start:%s%s", interval->
start_is_offset ?
"+" :
"",
2786 av_ts2timestr(interval->
start, &AV_TIME_BASE_Q));
2788 av_log(log_ctx, log_level,
" start:N/A");
2792 av_log(log_ctx, log_level,
" end:%s", interval->
end_is_offset ?
"+" :
"");
2794 av_log(log_ctx, log_level,
"#%"PRId64, interval->
end);
2796 av_log(log_ctx, log_level,
"%s", av_ts2timestr(interval->
end, &AV_TIME_BASE_Q));
2798 av_log(log_ctx, log_level,
" end:N/A");
2801 av_log(log_ctx, log_level,
"\n");
2807 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
2808 AVPacket *pkt = NULL;
2809 AVFrame *frame = NULL;
2810 int ret = 0, i = 0, frame_count = 0;
2811 int64_t start = -INT64_MAX, end = interval->
end;
2814 av_log(NULL, AV_LOG_VERBOSE,
"Processing read interval ");
2820 if (*cur_ts == AV_NOPTS_VALUE) {
2821 av_log(NULL, AV_LOG_ERROR,
2822 "Could not seek to relative position since current "
2823 "timestamp is not defined\n");
2824 ret = AVERROR(EINVAL);
2827 target = *cur_ts + interval->
start;
2829 target = interval->
start;
2832 av_log(NULL, AV_LOG_VERBOSE,
"Seeking to read interval start point %s\n",
2833 av_ts2timestr(target, &AV_TIME_BASE_Q));
2834 if ((ret = avformat_seek_file(fmt_ctx, -1, -INT64_MAX, target, INT64_MAX, 0)) < 0) {
2835 av_log(NULL, AV_LOG_ERROR,
"Could not seek to position %"PRId64
": %s\n",
2836 interval->
start, av_err2str(ret));
2841 frame = av_frame_alloc();
2843 ret = AVERROR(ENOMEM);
2846 pkt = av_packet_alloc();
2848 ret = AVERROR(ENOMEM);
2851 while (!av_read_frame(fmt_ctx, pkt)) {
2859 AVRational tb = ifile->
streams[pkt->stream_index].
st->time_base;
2861 if (pkt->pts != AV_NOPTS_VALUE)
2862 *cur_ts = av_rescale_q(pkt->pts, tb, AV_TIME_BASE_Q);
2864 if (!has_start && *cur_ts != AV_NOPTS_VALUE) {
2870 end = start + interval->
end;
2875 if (frame_count >= interval->
end)
2877 }
else if (has_end && *cur_ts != AV_NOPTS_VALUE && *cur_ts >= end) {
2889 while (
process_frame(w, ifile, frame, pkt, &packet_new) > 0);
2892 av_packet_unref(pkt);
2894 av_packet_unref(pkt);
2896 for (i = 0; i < fmt_ctx->nb_streams; i++) {
2897 pkt->stream_index = i;
2906 av_frame_free(&frame);
2907 av_packet_free(&pkt);
2909 av_log(NULL, AV_LOG_ERROR,
"Could not read packets in interval ");
2917 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
2919 int64_t cur_ts = fmt_ctx->start_time;
2937 AVStream *stream = ist->
st;
2938 AVCodecParameters *par;
2939 AVCodecContext *dec_ctx;
2942 AVRational sar, dar;
2944 const AVCodecDescriptor *cd;
2946 const char *profile = NULL;
2948 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
2954 par = stream->codecpar;
2956 if ((cd = avcodec_descriptor_get(par->codec_id))) {
2960 cd->long_name ? cd->long_name :
"unknown");
2969 if (!
do_bitexact && (profile = avcodec_profile_name(par->codec_id, par->profile)))
2972 if (par->profile != FF_PROFILE_UNKNOWN) {
2973 char profile_num[12];
2974 snprintf(profile_num,
sizeof(profile_num),
"%d", par->profile);
2980 s = av_get_media_type_string(par->codec_type);
2985 print_str(
"codec_tag_string", av_fourcc2str(par->codec_tag));
2986 print_fmt(
"codec_tag",
"0x%04"PRIx32, par->codec_tag);
2988 switch (par->codec_type) {
2989 case AVMEDIA_TYPE_VIDEO:
2993 print_int(
"coded_width", dec_ctx->coded_width);
2994 print_int(
"coded_height", dec_ctx->coded_height);
2995 print_int(
"closed_captions", !!(dec_ctx->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
2996 print_int(
"film_grain", !!(dec_ctx->properties & FF_CODEC_PROPERTY_FILM_GRAIN));
2998 print_int(
"has_b_frames", par->video_delay);
2999 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
3001 print_q(
"sample_aspect_ratio", sar,
':');
3002 av_reduce(&dar.num, &dar.den,
3003 par->width * sar.num,
3004 par->height * sar.den,
3006 print_q(
"display_aspect_ratio", dar,
':');
3011 s = av_get_pix_fmt_name(par->format);
3022 if (par->field_order == AV_FIELD_PROGRESSIVE)
3023 print_str(
"field_order",
"progressive");
3024 else if (par->field_order == AV_FIELD_TT)
3026 else if (par->field_order == AV_FIELD_BB)
3028 else if (par->field_order == AV_FIELD_TB)
3030 else if (par->field_order == AV_FIELD_BT)
3039 case AVMEDIA_TYPE_AUDIO:
3040 s = av_get_sample_fmt_name(par->format);
3044 print_int(
"channels", par->ch_layout.nb_channels);
3046 if (par->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
3047 av_channel_layout_describe(&par->ch_layout, val_str,
sizeof(val_str));
3053 print_int(
"bits_per_sample", av_get_bits_per_sample(par->codec_id));
3056 case AVMEDIA_TYPE_SUBTITLE:
3069 const AVOption *opt = NULL;
3070 while ((opt = av_opt_next(dec_ctx->priv_data,opt))) {
3072 if (!(opt->flags & AV_OPT_FLAG_EXPORT))
continue;
3073 if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) {
3080 if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS)
print_fmt (
"id",
"0x%x", stream->id);
3082 print_q(
"r_frame_rate", stream->r_frame_rate,
'/');
3083 print_q(
"avg_frame_rate", stream->avg_frame_rate,
'/');
3084 print_q(
"time_base", stream->time_base,
'/');
3085 print_ts (
"start_pts", stream->start_time);
3086 print_time(
"start_time", stream->start_time, &stream->time_base);
3087 print_ts (
"duration_ts", stream->duration);
3088 print_time(
"duration", stream->duration, &stream->time_base);
3091 if (dec_ctx && dec_ctx->rc_max_rate > 0)
3095 if (dec_ctx && dec_ctx->bits_per_raw_sample > 0)
print_fmt(
"bits_per_raw_sample",
"%d", dec_ctx->bits_per_raw_sample);
3097 if (stream->nb_frames)
print_fmt (
"nb_frames",
"%"PRId64, stream->nb_frames);
3105 par->extradata_size);
3107 if (par->extradata_size > 0) {
3108 print_int(
"extradata_size", par->extradata_size);
3110 par->extradata_size);
3114#define PRINT_DISPOSITION(flagname, name) do { \
3115 print_int(name, !!(stream->disposition & AV_DISPOSITION_##flagname)); \
3143 if (stream->nb_side_data) {
3150 av_bprint_finalize(&pbuf, NULL);
3158 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
3175 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
3180 print_int(
"program_num", program->program_num);
3181 print_int(
"nb_streams", program->nb_stream_indexes);
3190 for (i = 0; i < program->nb_stream_indexes; i++) {
3192 ret =
show_stream(w, fmt_ctx, program->stream_index[i], &ifile->
streams[program->stream_index[i]], 1);
3206 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
3210 for (i = 0; i < fmt_ctx->nb_programs; i++) {
3211 AVProgram *program = fmt_ctx->programs[i];
3224 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
3228 for (i = 0; i < fmt_ctx->nb_chapters; i++) {
3229 AVChapter *chapter = fmt_ctx->chapters[i];
3233 print_q (
"time_base", chapter->time_base,
'/');
3235 print_time(
"start_time", chapter->start, &chapter->time_base);
3237 print_time(
"end_time", chapter->end, &chapter->time_base);
3249 AVFormatContext *fmt_ctx = ifile->
fmt_ctx;
3251 int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
3256 print_int(
"nb_streams", fmt_ctx->nb_streams);
3257 print_int(
"nb_programs", fmt_ctx->nb_programs);
3258 print_str(
"format_name", fmt_ctx->iformat->name);
3260 if (fmt_ctx->iformat->long_name)
print_str (
"format_long_name", fmt_ctx->iformat->long_name);
3263 print_time(
"start_time", fmt_ctx->start_time, &AV_TIME_BASE_Q);
3264 print_time(
"duration", fmt_ctx->duration, &AV_TIME_BASE_Q);
3269 print_int(
"probe_score", fmt_ctx->probe_score);
3281 const char *errbuf_ptr = errbuf;
3283 if (av_strerror(err, errbuf,
sizeof(errbuf)) < 0)
3284 errbuf_ptr = strerror(AVUNERROR(err));
3293 const char *print_filename)
3296 AVFormatContext *fmt_ctx = NULL;
3297 const AVDictionaryEntry *t = NULL;
3298 int scan_all_pmts_set = 0;
3300 fmt_ctx = avformat_alloc_context();
3306 if (!av_dict_get(
format_opts,
"scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
3307 av_dict_set(&
format_opts,
"scan_all_pmts",
"1", AV_DICT_DONT_OVERWRITE);
3308 scan_all_pmts_set = 1;
3310 if ((err = avformat_open_input(&fmt_ctx, filename,
3315 if (print_filename) {
3316 av_freep(&fmt_ctx->url);
3317 fmt_ctx->url = av_strdup(print_filename);
3320 if (scan_all_pmts_set)
3321 av_dict_set(&
format_opts,
"scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
3322 while ((t = av_dict_get(
format_opts,
"", t, AV_DICT_IGNORE_SUFFIX)))
3323 av_log(NULL, AV_LOG_WARNING,
"Option %s skipped - not known to demuxer.\n", t->key);
3327 int orig_nb_streams = fmt_ctx->nb_streams;
3329 err = avformat_find_stream_info(fmt_ctx, opts);
3331 for (i = 0; i < orig_nb_streams; i++)
3332 av_dict_free(&opts[i]);
3341 av_dump_format(fmt_ctx, 0, filename, 0);
3343 ifile->
streams = av_calloc(fmt_ctx->nb_streams,
sizeof(*ifile->
streams));
3349 for (i = 0; i < fmt_ctx->nb_streams; i++) {
3351 AVStream *stream = fmt_ctx->streams[i];
3352 const AVCodec *codec;
3356 if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
3357 av_log(NULL, AV_LOG_WARNING,
3358 "Failed to probe codec for input stream %d\n",
3363 codec = avcodec_find_decoder(stream->codecpar->codec_id);
3365 av_log(NULL, AV_LOG_WARNING,
3366 "Unsupported codec with id %d for input stream %d\n",
3367 stream->codecpar->codec_id, stream->index);
3372 fmt_ctx, stream, codec);
3374 ist->
dec_ctx = avcodec_alloc_context3(codec);
3378 err = avcodec_parameters_to_context(ist->
dec_ctx, stream->codecpar);
3389 ist->
dec_ctx->pkt_timebase = stream->time_base;
3391 if (avcodec_open2(ist->
dec_ctx, codec, &opts) < 0) {
3392 av_log(NULL, AV_LOG_WARNING,
"Could not open codec for input stream %d\n",
3397 if ((t = av_dict_get(opts,
"", NULL, AV_DICT_IGNORE_SUFFIX))) {
3398 av_log(NULL, AV_LOG_ERROR,
"Option %s for input stream %d not found\n",
3399 t->key, stream->index);
3400 return AVERROR_OPTION_NOT_FOUND;
3420 avformat_close_input(&ifile->
fmt_ctx);
3424 const char *print_filename)
3437#define CHECK_END if (ret < 0) goto end
3444 for (i = 0; i < ifile.
fmt_ctx->nb_streams; i++) {
3446 ret = avformat_match_stream_specifier(ifile.
fmt_ctx,
3457 ifile.
fmt_ctx->streams[i]->discard = AVDISCARD_ALL;
3506 av_log(NULL, AV_LOG_INFO,
"Simple multimedia streams analyzer\n");
3507 av_log(NULL, AV_LOG_INFO,
"usage: %s [OPTIONS] INPUT_FILE\n",
program_name);
3508 av_log(NULL, AV_LOG_INFO,
"\n");
3514 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
3518 print_fmt(
"copyright",
"Copyright (c) %d-%d the FFmpeg developers",
3521 print_str(
"configuration", FFMPEG_CONFIGURATION);
3524 av_bprint_finalize(&pbuf, NULL);
3527#define SHOW_LIB_VERSION(libname, LIBNAME) \
3529 if (CONFIG_##LIBNAME) { \
3530 unsigned int version = libname##_version(); \
3531 writer_print_section_header(w, SECTION_ID_LIBRARY_VERSION); \
3532 print_str("name", "lib" #libname); \
3533 print_int("major", LIB##LIBNAME##_VERSION_MAJOR); \
3534 print_int("minor", LIB##LIBNAME##_VERSION_MINOR); \
3535 print_int("micro", LIB##LIBNAME##_VERSION_MICRO); \
3536 print_int("version", version); \
3537 print_str("ident", LIB##LIBNAME##_IDENT); \
3538 writer_print_section_footer(w); \
3555#define PRINT_PIX_FMT_FLAG(flagname, name) \
3557 print_int(name, !!(pixdesc->flags & AV_PIX_FMT_FLAG_##flagname)); \
3562 const AVPixFmtDescriptor *pixdesc = NULL;
3566 while ((pixdesc = av_pix_fmt_desc_next(pixdesc))) {
3569 print_int(
"nb_components", pixdesc->nb_components);
3570 if ((pixdesc->nb_components >= 3) && !(pixdesc->flags & AV_PIX_FMT_FLAG_RGB)) {
3571 print_int (
"log2_chroma_w", pixdesc->log2_chroma_w);
3572 print_int (
"log2_chroma_h", pixdesc->log2_chroma_h);
3577 n = av_get_bits_per_pixel(pixdesc);
3593 for (i = 0; i < pixdesc->nb_components; i++) {
3596 print_int(
"bit_depth", pixdesc->comp[i].depth);
3617static int opt_format(
void *optctx,
const char *opt,
const char *arg)
3619 iformat = av_find_input_format(arg);
3621 av_log(NULL, AV_LOG_ERROR,
"Unknown input format: %s\n", arg);
3622 return AVERROR(EINVAL);
3647 for (i = 0; i < FF_ARRAY_ELEMS(
sections); i++) {
3651 av_log(NULL, AV_LOG_DEBUG,
3652 "'%s' matches section with unique name '%s'\n", section_name,
3663 const char *p = arg;
3667 AVDictionary *entries = NULL;
3668 char *section_name = av_get_token(&p,
"=:");
3671 if (!section_name) {
3672 av_log(NULL, AV_LOG_ERROR,
3673 "Missing section name for option '%s'\n", opt);
3674 return AVERROR(EINVAL);
3679 while (*p && *p !=
':') {
3680 char *entry = av_get_token(&p,
",:");
3683 av_log(NULL, AV_LOG_VERBOSE,
3684 "Adding '%s' to the entries to show in section '%s'\n",
3685 entry, section_name);
3686 av_dict_set(&entries, entry,
"", AV_DICT_DONT_STRDUP_KEY);
3696 av_log(NULL, AV_LOG_ERROR,
"No match for section '%s'\n", section_name);
3697 ret = AVERROR(EINVAL);
3699 av_dict_free(&entries);
3700 av_free(section_name);
3714 av_log(NULL, AV_LOG_ERROR,
3715 "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3719 if (!strcmp(arg,
"-"))
3733 av_log(NULL, AV_LOG_ERROR,
3734 "Argument '%s' provided as output filename, but '%s' was already specified.\n",
3738 if (!strcmp(arg,
"-"))
3774 char *next, *p, *spec = av_strdup(interval_spec);
3776 return AVERROR(ENOMEM);
3779 av_log(NULL, AV_LOG_ERROR,
"Invalid empty interval specification\n");
3780 ret = AVERROR(EINVAL);
3785 next = strchr(spec,
'%');
3800 ret = av_parse_time(&interval->
start, p, 1);
3802 av_log(NULL, AV_LOG_ERROR,
"Invalid interval start specification '%s'\n", p);
3827 lli = strtoll(p, &tail, 10);
3828 if (*tail || lli < 0) {
3829 av_log(NULL, AV_LOG_ERROR,
3830 "Invalid or negative value '%s' for duration number of frames\n", p);
3833 interval->
end = lli;
3836 ret = av_parse_time(&us, p, 1);
3838 av_log(NULL, AV_LOG_ERROR,
"Invalid interval end/duration specification '%s'\n", p);
3855 char *p, *spec = av_strdup(intervals_spec);
3857 return AVERROR(ENOMEM);
3860 for (n = 0, p = spec; *p; p++)
3867 ret = AVERROR(ENOMEM);
3874 for (i = 0; p; i++) {
3878 next = strchr(p,
',');
3885 av_log(NULL, AV_LOG_ERROR,
"Error parsing read interval #%d '%s'\n",
3889 av_log(NULL, AV_LOG_VERBOSE,
"Parsed log interval ");
3905static int opt_pretty(
void *optctx,
const char *opt,
const char *arg)
3934 "W.. = Section is a wrapper (contains other sections, no local entries)\n"
3935 ".A. = Section contains an array of elements of the same type\n"
3936 "..V = Section may contain a variable number of fields with variable keys\n"
3937 "FLAGS NAME/UNIQUE_NAME\n"
3950#define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
3951 static int opt_show_##section(void *optctx, const char *opt, const char *arg) \
3953 mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL); \
3980#define SET_DO_SHOW(id, varname) do { \
3981 if (check_section_show_entries(SECTION_ID_##id)) \
3982 do_show_##varname = 1; \
4052 char _program_name[] =
"ffprobe";
4071 {
"bsfs",
OPT_EXIT, { .func_arg =
show_bsfs },
"show available bit stream filters" },
4081 {
"report", 0, { .func_arg =
opt_report },
"generate a report" },
4082 {
"max_alloc",
HAS_ARG, { .func_arg =
opt_max_alloc },
"set maximum size of a single allocated block",
"bytes" },
4089 "list sources of the input device",
"device" },
4091 "list sinks of the output device",
"device" },
4098 "use binary prefixes for byte units" },
4100 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
4102 "prettify the format of displayed values, make it more human readable" },
4104 "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)",
"format" },
4107 {
"sections",
OPT_EXIT, {.func_arg =
opt_sections},
"print sections structure and section information, and exit" },
4110 {
"show_error", 0, { .func_arg = &opt_show_error },
"show probing error" },
4111 {
"show_format", 0, { .func_arg = &opt_show_format },
"show format/container info" },
4112 {
"show_frames", 0, { .func_arg = &opt_show_frames },
"show frames info" },
4114 "show a set of specified entries",
"entry_list" },
4118 {
"show_packets", 0, { .func_arg = &opt_show_packets },
"show packets info" },
4119 {
"show_programs", 0, { .func_arg = &opt_show_programs },
"show programs info" },
4120 {
"show_streams", 0, { .func_arg = &opt_show_streams },
"show streams info" },
4121 {
"show_chapters", 0, { .func_arg = &opt_show_chapters },
"show chapters info" },
4124 {
"show_program_version", 0, { .func_arg = &opt_show_program_version },
"show ffprobe version" },
4125 {
"show_library_versions", 0, { .func_arg = &opt_show_library_versions },
"show library versions" },
4126 {
"show_versions", 0, { .func_arg = &
opt_show_versions },
"show program and library versions" },
4127 {
"show_pixel_formats", 0, { .func_arg = &opt_show_pixel_formats },
"show pixel format descriptions" },
4137 "read and decode the streams to fill missing information with heuristics" },
4144 char *w_name = NULL, *w_args = NULL;
4145 int ret, input_ret, i;
4148 if (savedCode == 0) {
4155 ret = pthread_mutex_init(&log_mutex, NULL);
4160 av_log_set_flags(AV_LOG_SKIP_REPEATED);
4165 avformat_network_init();
4167 avdevice_register_all();
4184 SET_DO_SHOW(PIXEL_FORMAT_FLAGS, pixel_format_flags);
4185 SET_DO_SHOW(PIXEL_FORMAT_COMPONENTS, pixel_format_components);
4189 SET_DO_SHOW(STREAM_DISPOSITION, stream_disposition);
4190 SET_DO_SHOW(PROGRAM_STREAM_DISPOSITION, stream_disposition);
4201 av_log(NULL, AV_LOG_ERROR,
4202 "-bitexact and -show_program_version or -show_library_versions "
4203 "options are incompatible\n");
4204 ret = AVERROR(EINVAL);
4213 ret = AVERROR(ENOMEM);
4218 av_log(NULL, AV_LOG_ERROR,
4219 "No name specified for the output format\n");
4220 ret = AVERROR(EINVAL);
4227 if (ret == AVERROR(EINVAL)) {
4229 av_log(NULL, AV_LOG_ERROR,
4230 "Unknown hash algorithm '%s'\nKnown algorithms:",
4232 for (i = 0; (n = av_hash_names(i)); i++)
4233 av_log(NULL, AV_LOG_ERROR,
" %s", n);
4234 av_log(NULL, AV_LOG_ERROR,
"\n");
4242 av_log(NULL, AV_LOG_ERROR,
"Unknown output format with name '%s'\n", w_name);
4243 ret = AVERROR(EINVAL);
4265 av_log(NULL, AV_LOG_ERROR,
"You have to specify one input file.\n");
4266 av_log(NULL, AV_LOG_ERROR,
"Use -h to get full help or, even better, run 'man %s'.\n",
program_name);
4267 ret = AVERROR(EINVAL);
4279 av_log(NULL, AV_LOG_ERROR,
"Writing output failed: %s\n", av_err2str(ret));
4281 ret = FFMIN(ret, input_ret);
4293 av_hash_freep(&
hash);
4296 for (i = 0; i < FF_ARRAY_ELEMS(
sections); i++)
4299 avformat_network_deinit();
__thread jmp_buf ex_buf__
int terminate_line[SECTION_MAX_NB_LEVELS]
int has_nested_elems[SECTION_MAX_NB_LEVELS]
int nested_section[SECTION_MAX_NB_LEVELS]
const char *(* escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
int nested_section[SECTION_MAX_NB_LEVELS]
const char * item_start_end
AVClassCategory parent_category
int64_t end
start, end in second/AV_TIME_BASE units
unsigned int nb_section_frame
number of the frame section in case we are in "packets_and_frames" section
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
const struct section * section[SECTION_MAX_NB_LEVELS]
void(* writer_put_str)(WriterContext *wctx, const char *str)
char * string_validation_replacement
char * name
name of this writer instance
void * priv
private data for use by the filter
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
void(* writer_w8)(WriterContext *wctx, int b)
unsigned int nb_section_packet_frame
nb_section_packet or nb_section_frame according if is_packets_and_frames
int level
current level, starting from 0
unsigned int nb_section_packet
number of the packet section in case we are in "packets_and_frames" section
AVIOContext * avio
the I/O context used to write
void(* writer_printf)(WriterContext *wctx, const char *fmt,...)
int nb_sections
number of sections
const struct section * sections
array containing all sections
unsigned int string_validation_utf8_flags
const Writer * writer
the Writer of which this is an instance
void(* print_string)(WriterContext *wctx, const char *, const char *)
int flags
a combination or WRITER_FLAG_*
int priv_size
private size for the writer context
const AVClass * priv_class
private class of the writer, if any
void(* print_integer)(WriterContext *wctx, const char *, long long int)
void(* print_rational)(WriterContext *wctx, AVRational *q, char *sep)
int(* init)(WriterContext *wctx)
void(* print_section_header)(WriterContext *wctx)
void(* print_section_footer)(WriterContext *wctx)
void(* uninit)(WriterContext *wctx)
AVDictionary * entries_to_show
const char * element_name
name of the contained element, if provided
int id
unique id identifying a section
const char * unique_name
unique section name, in case the name is ambiguous
int children_ids[SECTION_MAX_NB_CHILDREN+1]
list of children section IDS, terminated by -1