void (*print_chapter_footer)(WriterContext *wctx, const char *);
void (*print_section_header)(WriterContext *wctx, const char *);
void (*print_section_footer)(WriterContext *wctx, const char *);
- void (*print_integer) (WriterContext *wctx, const char *, int);
+ void (*print_integer) (WriterContext *wctx, const char *, long long int);
void (*print_string) (WriterContext *wctx, const char *, const char *);
void (*show_tags) (WriterContext *wctx, AVDictionary *dict);
int flags; ///< a combination or WRITER_FLAG_*
}
static inline void writer_print_integer(WriterContext *wctx,
- const char *key, int val)
+ const char *key, long long int val)
{
wctx->writer->print_integer(wctx, key, val);
wctx->nb_item++;
static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts)
{
- char buf[128];
-
if (ts == AV_NOPTS_VALUE) {
writer_print_string(wctx, key, "N/A", 1);
} else {
- snprintf(buf, sizeof(buf), "%"PRId64, ts);
- writer_print_string(wctx, key, buf, 0);
+ writer_print_integer(wctx, key, ts);
}
}
#define MAX_REGISTERED_WRITERS_NB 64
-static Writer *registered_writers[MAX_REGISTERED_WRITERS_NB + 1];
+static const Writer *registered_writers[MAX_REGISTERED_WRITERS_NB + 1];
-static int writer_register(Writer *writer)
+static int writer_register(const Writer *writer)
{
static int next_registered_writer_idx = 0;
return 0;
}
-static Writer *writer_get_by_name(const char *name)
+static const Writer *writer_get_by_name(const char *name)
{
int i;
printf("%s=%s\n", key, value);
}
-static void default_print_int(WriterContext *wctx, const char *key, int value)
+static void default_print_int(WriterContext *wctx, const char *key, long long int value)
{
- printf("%s=%d\n", key, value);
+ printf("%s=%lld\n", key, value);
}
static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
}
}
-static Writer default_writer = {
+static const Writer default_writer = {
.name = "default",
.print_footer = default_print_footer,
.print_chapter_header = default_print_chapter_header,
value, compact->item_sep, wctx));
}
-static void compact_print_int(WriterContext *wctx, const char *key, int value)
+static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
{
CompactContext *compact = wctx->priv;
if (wctx->nb_item) printf("%c", compact->item_sep);
if (!compact->nokey)
printf("%s=", key);
- printf("%d", value);
+ printf("%lld", value);
}
static void compact_show_tags(WriterContext *wctx, AVDictionary *dict)
}
}
-static Writer compact_writer = {
- .name = "compact",
- .priv_size = sizeof(CompactContext),
+static const Writer compact_writer = {
+ .name = "compact",
+ .priv_size = sizeof(CompactContext),
+ .init = compact_init,
+ .uninit = compact_uninit,
+ .print_section_header = compact_print_section_header,
+ .print_section_footer = compact_print_section_footer,
+ .print_integer = compact_print_int,
+ .print_string = compact_print_str,
+ .show_tags = compact_show_tags,
+ .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
+};
+
+/* CSV output */
- .init = compact_init,
- .uninit = compact_uninit,
- .print_section_header = compact_print_section_header,
- .print_section_footer = compact_print_section_footer,
- .print_integer = compact_print_int,
- .print_string = compact_print_str,
- .show_tags = compact_show_tags,
- .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
+static av_cold int csv_init(WriterContext *wctx, const char *args, void *opaque)
+{
+ return compact_init(wctx, "item_sep=,:nokey=1:escape=csv", opaque);
+}
+
+static const Writer csv_writer = {
+ .name = "csv",
+ .priv_size = sizeof(CompactContext),
+ .init = csv_init,
+ .uninit = compact_uninit,
+ .print_section_header = compact_print_section_header,
+ .print_section_footer = compact_print_section_footer,
+ .print_integer = compact_print_int,
+ .print_string = compact_print_str,
+ .show_tags = compact_show_tags,
+ .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
};
/* JSON output */
json_print_item_str(wctx, key, value, INDENT);
}
-static void json_print_int(WriterContext *wctx, const char *key, int value)
+static void json_print_int(WriterContext *wctx, const char *key, long long int value)
{
JSONContext *json = wctx->priv;
if (wctx->nb_item) printf(",\n");
- printf(INDENT "\"%s\": %d",
+ printf(INDENT "\"%s\": %lld",
json_escape_str(&json->buf, &json->buf_size, key, wctx), value);
}
printf("\n }");
}
-static Writer json_writer = {
- .name = "json",
- .priv_size = sizeof(JSONContext),
-
+static const Writer json_writer = {
+ .name = "json",
+ .priv_size = sizeof(JSONContext),
.init = json_init,
.uninit = json_uninit,
.print_header = json_print_header,
writer_register(&default_writer);
writer_register(&compact_writer);
+ writer_register(&csv_writer);
writer_register(&json_writer);
}
#define print_time(k, v, tb) writer_print_time(w, k, v, tb)
#define print_ts(k, v) writer_print_ts(w, k, v)
#define print_val(k, v, u) writer_print_string(w, k, \
- value_string(val_str, sizeof(val_str), (struct unit_value){.val.i = v, .unit=u}), 1)
+ value_string(val_str, sizeof(val_str), (struct unit_value){.val.i = v, .unit=u}), 0)
#define print_section_header(s) writer_print_section_header(w, s)
#define print_section_footer(s) writer_print_section_footer(w, s)
#define show_tags(metadata) writer_show_tags(w, metadata)
if (s) print_str ("pix_fmt", s);
else print_str_opt("pix_fmt", "unknown");
print_int("level", dec_ctx->level);
+ if (dec_ctx->timecode_frame_start >= 0) {
+ uint32_t tc = dec_ctx->timecode_frame_start;
+ print_fmt("timecode", "%02d:%02d:%02d%c%02d",
+ tc>>19 & 0x1f, // hours
+ tc>>13 & 0x3f, // minutes
+ tc>>6 & 0x3f, // seconds
+ tc & 1<<24 ? ';' : ':', // drop
+ tc & 0x3f); // frames
+ } else {
+ print_str_opt("timecode", "N/A");
+ }
break;
case AVMEDIA_TYPE_AUDIO:
{
AVFormatContext *fmt_ctx;
int ret;
- Writer *w;
+ const Writer *w;
char *buf;
char *w_name = NULL, *w_args = NULL;
WriterContext *wctx;
"use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
{ "pretty", 0, {(void*)&opt_pretty},
"prettify the format of displayed values, make it more human readable" },
- { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format}, "set the output printing format (available formats are: default, compact, json)", "format" },
+ { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format},
+ "set the output printing format (available formats are: default, compact, csv, json)", "format" },
{ "show_format", OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
{ "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
{ "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },