SECTION_ID_FRAME_TAGS,
SECTION_ID_FRAME_SIDE_DATA_LIST,
SECTION_ID_FRAME_SIDE_DATA,
+ SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST,
+ SECTION_ID_FRAME_SIDE_DATA_TIMECODE,
SECTION_ID_FRAME_LOG,
SECTION_ID_FRAME_LOGS,
SECTION_ID_LIBRARY_VERSION,
[SECTION_ID_FRAME] = { SECTION_ID_FRAME, "frame", 0, { SECTION_ID_FRAME_TAGS, SECTION_ID_FRAME_SIDE_DATA_LIST, SECTION_ID_FRAME_LOGS, -1 } },
[SECTION_ID_FRAME_TAGS] = { SECTION_ID_FRAME_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "frame_tags" },
[SECTION_ID_FRAME_SIDE_DATA_LIST] ={ SECTION_ID_FRAME_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA, -1 }, .element_name = "side_data", .unique_name = "frame_side_data_list" },
- [SECTION_ID_FRAME_SIDE_DATA] = { SECTION_ID_FRAME_SIDE_DATA, "side_data", 0, { -1 } },
+ [SECTION_ID_FRAME_SIDE_DATA] = { SECTION_ID_FRAME_SIDE_DATA, "side_data", 0, { SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, -1 } },
+ [SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST, "timecodes", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, -1 } },
+ [SECTION_ID_FRAME_SIDE_DATA_TIMECODE] = { SECTION_ID_FRAME_SIDE_DATA_TIMECODE, "timecode", 0, { -1 } },
[SECTION_ID_FRAME_LOGS] = { SECTION_ID_FRAME_LOGS, "logs", SECTION_FLAG_IS_ARRAY, { SECTION_ID_FRAME_LOG, -1 } },
[SECTION_ID_FRAME_LOG] = { SECTION_ID_FRAME_LOG, "log", 0, { -1 }, },
[SECTION_ID_LIBRARY_VERSIONS] = { SECTION_ID_LIBRARY_VERSIONS, "library_versions", SECTION_FLAG_IS_ARRAY, { SECTION_ID_LIBRARY_VERSION, -1 } },
/* FFprobe context */
static const char *input_filename;
+static const char *print_input_filename;
static AVInputFormat *iformat = NULL;
static struct AVHashContext *hash;
if (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES) {
if (!json->compact)
JSON_INDENT();
- printf("\"type\": \"%s\"%s", section->name, json->item_sep);
+ printf("\"type\": \"%s\"", section->name);
}
}
av_bprint_finalize(&buf, NULL);
static void json_print_str(WriterContext *wctx, const char *key, const char *value)
{
JSONContext *json = wctx->priv;
+ const struct section *parent_section = wctx->level ?
+ wctx->section[wctx->level-1] : NULL;
- if (wctx->nb_item[wctx->level])
+ if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES))
printf("%s", json->item_sep);
if (!json->compact)
JSON_INDENT();
static void json_print_int(WriterContext *wctx, const char *key, long long int value)
{
JSONContext *json = wctx->priv;
+ const struct section *parent_section = wctx->level ?
+ wctx->section[wctx->level-1] : NULL;
AVBPrint buf;
- if (wctx->nb_item[wctx->level])
+ if (wctx->nb_item[wctx->level] || (parent_section && parent_section->id == SECTION_ID_PACKETS_AND_FRAMES))
printf("%s", json->item_sep);
if (!json->compact)
JSON_INDENT();
char tcbuf[AV_TIMECODE_STR_SIZE];
av_timecode_make_mpeg_tc_string(tcbuf, *(int64_t *)(sd->data));
print_str("timecode", tcbuf);
+ } else if (sd->type == AV_FRAME_DATA_S12M_TIMECODE && sd->size == 16) {
+ uint32_t *tc = (uint32_t*)sd->data;
+ int m = FFMIN(tc[0],3);
+ writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST);
+ for (int j = 1; j <= m ; j++) {
+ char tcbuf[AV_TIMECODE_STR_SIZE];
+ av_timecode_make_smpte_tc_string(tcbuf, tc[j], 0);
+ writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_TIMECODE);
+ print_str("value", tcbuf);
+ writer_print_section_footer(w);
+ }
+ writer_print_section_footer(w);
} else if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) {
AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data;
}
av_packet_unref(&pkt);
}
- av_init_packet(&pkt);
- pkt.data = NULL;
- pkt.size = 0;
+ av_packet_unref(&pkt);
//Flush remaining frames that are cached in the decoder
for (i = 0; i < fmt_ctx->nb_streams; i++) {
pkt.stream_index = i;
writer_print_section_footer(w);
}
-static int open_input_file(InputFile *ifile, const char *filename)
+static int open_input_file(InputFile *ifile, const char *filename,
+ const char *print_filename)
{
int err, i;
AVFormatContext *fmt_ctx = NULL;
print_error(filename, err);
return err;
}
+ if (print_filename) {
+ av_freep(&fmt_ctx->url);
+ fmt_ctx->url = av_strdup(print_filename);
+ }
ifile->fmt_ctx = fmt_ctx;
if (scan_all_pmts_set)
av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
avformat_close_input(&ifile->fmt_ctx);
}
-static int probe_file(WriterContext *wctx, const char *filename)
+static int probe_file(WriterContext *wctx, const char *filename,
+ const char *print_filename)
{
InputFile ifile = { 0 };
int ret, i;
do_read_frames = do_show_frames || do_count_frames;
do_read_packets = do_show_packets || do_count_packets;
- ret = open_input_file(&ifile, filename);
+ ret = open_input_file(&ifile, filename, print_filename);
if (ret < 0)
goto end;
return 0;
}
+static int opt_print_filename(void *optctx, const char *opt, const char *arg)
+{
+ print_input_filename = arg;
+ return 0;
+}
+
void show_help_default(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
return 0;
}
-static int opt_show_versions(const char *opt, const char *arg)
+static int opt_show_versions(void *optctx, const char *opt, const char *arg)
{
mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL);
mark_section_show_entries(SECTION_ID_LIBRARY_VERSION, 1, NULL);
}
#define DEFINE_OPT_SHOW_SECTION(section, target_section_id) \
- static int opt_show_##section(const char *opt, const char *arg) \
+ static int opt_show_##section(void *optctx, const char *opt, const char *arg) \
{ \
mark_section_show_entries(SECTION_ID_##target_section_id, 1, NULL); \
return 0; \
{ "sections", OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
{ "show_data", OPT_BOOL, {(void*)&do_show_data}, "show packets data" },
{ "show_data_hash", OPT_STRING | HAS_ARG, {(void*)&show_data_hash}, "show packets data hash" },
- { "show_error", 0, {(void*)&opt_show_error}, "show probing error" },
- { "show_format", 0, {(void*)&opt_show_format}, "show format/container info" },
- { "show_frames", 0, {(void*)&opt_show_frames}, "show frames info" },
+ { "show_error", 0, { .func_arg = &opt_show_error }, "show probing error" },
+ { "show_format", 0, { .func_arg = &opt_show_format }, "show format/container info" },
+ { "show_frames", 0, { .func_arg = &opt_show_frames }, "show frames info" },
{ "show_format_entry", HAS_ARG, {.func_arg = opt_show_format_entry},
"show a particular entry from the format/container info", "entry" },
{ "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
#if HAVE_THREADS
{ "show_log", OPT_INT|HAS_ARG, {(void*)&do_show_log}, "show log" },
#endif
- { "show_packets", 0, {(void*)&opt_show_packets}, "show packets info" },
- { "show_programs", 0, {(void*)&opt_show_programs}, "show programs info" },
- { "show_streams", 0, {(void*)&opt_show_streams}, "show streams info" },
- { "show_chapters", 0, {(void*)&opt_show_chapters}, "show chapters info" },
+ { "show_packets", 0, { .func_arg = &opt_show_packets }, "show packets info" },
+ { "show_programs", 0, { .func_arg = &opt_show_programs }, "show programs info" },
+ { "show_streams", 0, { .func_arg = &opt_show_streams }, "show streams info" },
+ { "show_chapters", 0, { .func_arg = &opt_show_chapters }, "show chapters info" },
{ "count_frames", OPT_BOOL, {(void*)&do_count_frames}, "count the number of frames per stream" },
{ "count_packets", OPT_BOOL, {(void*)&do_count_packets}, "count the number of packets per stream" },
- { "show_program_version", 0, {(void*)&opt_show_program_version}, "show ffprobe version" },
- { "show_library_versions", 0, {(void*)&opt_show_library_versions}, "show library versions" },
- { "show_versions", 0, {(void*)&opt_show_versions}, "show program and library versions" },
- { "show_pixel_formats", 0, {(void*)&opt_show_pixel_formats}, "show pixel format descriptions" },
+ { "show_program_version", 0, { .func_arg = &opt_show_program_version }, "show ffprobe version" },
+ { "show_library_versions", 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
+ { "show_versions", 0, { .func_arg = &opt_show_versions }, "show program and library versions" },
+ { "show_pixel_formats", 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
{ "show_private_data", OPT_BOOL, {(void*)&show_private_data}, "show private data" },
{ "private", OPT_BOOL, {(void*)&show_private_data}, "same as show_private_data" },
{ "bitexact", OPT_BOOL, {&do_bitexact}, "force bitexact output" },
{ "read_intervals", HAS_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" },
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default}, "generic catch all option", "" },
{ "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"},
+ { "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
{ "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
"read and decode the streams to fill missing information with heuristics" },
{ NULL, },
av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
ret = AVERROR(EINVAL);
} else if (input_filename) {
- ret = probe_file(wctx, input_filename);
+ ret = probe_file(wctx, input_filename, print_input_filename);
if (ret < 0 && do_show_error)
show_error(wctx, ret);
}