2 * ffprobe : Simple Media Prober based on the FFmpeg libraries
3 * Copyright (c) 2007-2010 Stefano Sabatini
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavformat/avformat.h"
25 #include "libavcodec/avcodec.h"
26 #include "libavutil/avstring.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/pixdesc.h"
29 #include "libavutil/dict.h"
30 #include "libavdevice/avdevice.h"
33 const char program_name[] = "ffprobe";
34 const int program_birth_year = 2007;
36 static int do_show_format = 0;
37 static int do_show_packets = 0;
38 static int do_show_streams = 0;
40 static int show_value_unit = 0;
41 static int use_value_prefix = 0;
42 static int use_byte_value_binary_prefix = 0;
43 static int use_value_sexagesimal_format = 0;
45 static char *print_format;
47 static const OptionDef options[];
50 static const char *input_filename;
51 static AVInputFormat *iformat = NULL;
53 static const char *binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
54 static const char *decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P" };
56 static const char *unit_second_str = "s" ;
57 static const char *unit_hertz_str = "Hz" ;
58 static const char *unit_byte_str = "byte" ;
59 static const char *unit_bit_per_second_str = "bit/s";
61 void exit_program(int ret)
66 static char *value_string(char *buf, int buf_size, double val, const char *unit)
68 if (unit == unit_second_str && use_value_sexagesimal_format) {
72 mins = (int)secs / 60;
73 secs = secs - mins * 60;
76 snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
77 } else if (use_value_prefix) {
78 const char *prefix_string;
81 if (unit == unit_byte_str && use_byte_value_binary_prefix) {
82 index = (int) (log(val)/log(2)) / 10;
83 index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) -1);
84 val /= pow(2, index*10);
85 prefix_string = binary_unit_prefixes[index];
87 index = (int) (log10(val)) / 3;
88 index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) -1);
89 val /= pow(10, index*3);
90 prefix_string = decimal_unit_prefixes[index];
93 snprintf(buf, buf_size, "%.3f%s%s%s", val, prefix_string || show_value_unit ? " " : "",
94 prefix_string, show_value_unit ? unit : "");
96 snprintf(buf, buf_size, "%f%s%s", val, show_value_unit ? " " : "",
97 show_value_unit ? unit : "");
103 static char *time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base)
105 if (val == AV_NOPTS_VALUE) {
106 snprintf(buf, buf_size, "N/A");
108 value_string(buf, buf_size, val * av_q2d(*time_base), unit_second_str);
114 static char *ts_value_string (char *buf, int buf_size, int64_t ts)
116 if (ts == AV_NOPTS_VALUE) {
117 snprintf(buf, buf_size, "N/A");
119 snprintf(buf, buf_size, "%"PRId64, ts);
127 typedef struct WriterContext WriterContext;
129 typedef struct Writer {
130 int priv_size; ///< private size for the writer context
133 int (*init) (WriterContext *wctx, const char *args, void *opaque);
134 void (*uninit)(WriterContext *wctx);
136 void (*print_header)(WriterContext *ctx);
137 void (*print_footer)(WriterContext *ctx);
139 void (*print_chapter_header)(WriterContext *wctx, const char *);
140 void (*print_chapter_footer)(WriterContext *wctx, const char *);
141 void (*print_section_header)(WriterContext *wctx, const char *);
142 void (*print_section_footer)(WriterContext *wctx, const char *);
143 void (*print_integer) (WriterContext *wctx, const char *, int);
144 void (*print_string) (WriterContext *wctx, const char *, const char *);
145 void (*show_tags) (WriterContext *wctx, AVDictionary *dict);
148 struct WriterContext {
149 const AVClass *class; ///< class of the writer
150 const Writer *writer; ///< the Writer of which this is an instance
151 char *name; ///< name of this writer instance
152 void *priv; ///< private data for use by the filter
153 unsigned int nb_item; ///< number of the item printed in the given section, starting at 0
154 unsigned int nb_section; ///< number of the section printed in the given section sequence, starting at 0
155 unsigned int nb_chapter; ///< number of the chapter, starting at 0
158 static const char *writer_get_name(void *p)
160 WriterContext *wctx = p;
161 return wctx->writer->name;
164 static const AVClass writer_class = {
168 LIBAVUTIL_VERSION_INT,
171 static void writer_close(WriterContext **wctx)
173 if (*wctx && (*wctx)->writer->uninit)
174 (*wctx)->writer->uninit(*wctx);
176 av_freep(&((*wctx)->priv));
180 static int writer_open(WriterContext **wctx, const Writer *writer,
181 const char *args, void *opaque)
185 if (!(*wctx = av_malloc(sizeof(WriterContext)))) {
186 ret = AVERROR(ENOMEM);
190 if (!((*wctx)->priv = av_mallocz(writer->priv_size))) {
191 ret = AVERROR(ENOMEM);
195 (*wctx)->class = &writer_class;
196 (*wctx)->writer = writer;
197 if ((*wctx)->writer->init)
198 ret = (*wctx)->writer->init(*wctx, args, opaque);
209 static inline void writer_print_header(WriterContext *wctx)
211 if (wctx->writer->print_header)
212 wctx->writer->print_header(wctx);
213 wctx->nb_chapter = 0;
216 static inline void writer_print_footer(WriterContext *wctx)
218 if (wctx->writer->print_footer)
219 wctx->writer->print_footer(wctx);
222 static inline void writer_print_chapter_header(WriterContext *wctx,
225 if (wctx->writer->print_chapter_header)
226 wctx->writer->print_chapter_header(wctx, header);
227 wctx->nb_section = 0;
230 static inline void writer_print_chapter_footer(WriterContext *wctx,
233 if (wctx->writer->print_chapter_footer)
234 wctx->writer->print_chapter_footer(wctx, footer);
238 static inline void writer_print_section_header(WriterContext *wctx,
241 if (wctx->writer->print_section_header)
242 wctx->writer->print_section_header(wctx, header);
246 static inline void writer_print_section_footer(WriterContext *wctx,
249 if (wctx->writer->print_section_footer)
250 wctx->writer->print_section_footer(wctx, footer);
254 static inline void writer_print_integer(WriterContext *wctx,
255 const char *key, int val)
257 wctx->writer->print_integer(wctx, key, val);
261 static inline void writer_print_string(WriterContext *wctx,
262 const char *key, const char *val)
264 wctx->writer->print_string(wctx, key, val);
268 static inline void writer_show_tags(WriterContext *wctx, AVDictionary *dict)
270 wctx->writer->show_tags(wctx, dict);
273 #define MAX_REGISTERED_WRITERS_NB 64
275 static Writer *registered_writers[MAX_REGISTERED_WRITERS_NB + 1];
277 static int writer_register(Writer *writer)
279 static int next_registered_writer_idx = 0;
281 if (next_registered_writer_idx == MAX_REGISTERED_WRITERS_NB)
282 return AVERROR(ENOMEM);
284 registered_writers[next_registered_writer_idx++] = writer;
288 static Writer *writer_get_by_name(const char *name)
292 for (i = 0; registered_writers[i]; i++)
293 if (!strcmp(registered_writers[i]->name, name))
294 return registered_writers[i];
306 static char *fast_asprintf(struct print_buf *pbuf, const char *fmt, ...)
312 len = vsnprintf(NULL, 0, fmt, va);
317 if (pbuf->len < len) {
318 char *p = av_realloc(pbuf->s, len + 1);
326 len = vsnprintf(pbuf->s, len + 1, fmt, va);
342 static void default_print_footer(WriterContext *wctx)
347 static void default_print_chapter_header(WriterContext *wctx, const char *chapter)
349 if (wctx->nb_chapter)
353 /* lame uppercasing routine, assumes the string is lower case ASCII */
354 static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
357 for (i = 0; src[i] && i < dst_size-1; i++)
363 static void default_print_section_header(WriterContext *wctx, const char *section)
367 if (wctx->nb_section)
369 printf("[%s]\n", upcase_string(buf, sizeof(buf), section));
372 static void default_print_section_footer(WriterContext *wctx, const char *section)
376 printf("[/%s]", upcase_string(buf, sizeof(buf), section));
379 static void default_print_str(WriterContext *wctx, const char *key, const char *value)
381 printf("%s=%s\n", key, value);
384 static void default_print_int(WriterContext *wctx, const char *key, int value)
386 printf("%s=%d\n", key, value);
389 static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
391 AVDictionaryEntry *tag = NULL;
392 while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
394 writer_print_string(wctx, tag->key, tag->value);
398 static Writer default_writer = {
400 .print_footer = default_print_footer,
401 .print_chapter_header = default_print_chapter_header,
402 .print_section_header = default_print_section_header,
403 .print_section_footer = default_print_section_footer,
404 .print_integer = default_print_int,
405 .print_string = default_print_str,
406 .show_tags = default_show_tags
412 int multiple_entries; ///< tells if the given chapter requires multiple entries
415 static char *json_escape_str(const char *s)
417 static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
418 static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
422 // compute the length of the escaped string
423 for (i = 0; s[i]; i++) {
424 if (strchr(json_escape, s[i])) len += 2; // simple escape
425 else if ((unsigned char)s[i] < 32) len += 6; // handle non-printable chars
426 else len += 1; // char copy
429 p = ret = av_malloc(len + 1);
432 for (i = 0; s[i]; i++) {
433 char *q = strchr(json_escape, s[i]);
436 *p++ = json_subst[q - json_escape];
437 } else if ((unsigned char)s[i] < 32) {
438 snprintf(p, 7, "\\u00%02x", s[i] & 0xff);
448 static void json_print_header(WriterContext *wctx)
453 static void json_print_footer(WriterContext *wctx)
458 static void json_print_chapter_header(WriterContext *wctx, const char *chapter)
460 JSONContext *json = wctx->priv;
463 if (wctx->nb_chapter)
465 json->multiple_entries = !strcmp(chapter, "packets") || !strcmp(chapter, "streams");
466 chapter_esc = json_escape_str(chapter);
467 printf("\n \"%s\":%s", chapter_esc ? chapter_esc : "",
468 json->multiple_entries ? " [" : " ");
469 av_free(chapter_esc);
472 static void json_print_chapter_footer(WriterContext *wctx, const char *chapter)
474 JSONContext *json = wctx->priv;
476 if (json->multiple_entries)
480 static void json_print_section_header(WriterContext *wctx, const char *section)
482 if (wctx->nb_section) printf(",");
486 static void json_print_section_footer(WriterContext *wctx, const char *section)
491 static inline void json_print_item_str(WriterContext *wctx,
492 const char *key, const char *value,
495 char *key_esc = json_escape_str(key);
496 char *value_esc = json_escape_str(value);
498 printf("%s\"%s\": \"%s\"", indent,
499 key_esc ? key_esc : "",
500 value_esc ? value_esc : "");
507 static void json_print_str(WriterContext *wctx, const char *key, const char *value)
509 if (wctx->nb_item) printf(",\n");
510 json_print_item_str(wctx, key, value, INDENT);
513 static void json_print_int(WriterContext *wctx, const char *key, int value)
515 char *key_esc = json_escape_str(key);
517 if (wctx->nb_item) printf(",\n");
518 printf(INDENT "\"%s\": %d", key_esc ? key_esc : "", value);
522 static void json_show_tags(WriterContext *wctx, AVDictionary *dict)
524 AVDictionaryEntry *tag = NULL;
528 printf(",\n" INDENT "\"tags\": {\n");
529 while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
530 if (is_first) is_first = 0;
532 json_print_item_str(wctx, tag->key, tag->value, INDENT INDENT);
537 static Writer json_writer = {
539 .priv_size = sizeof(JSONContext),
541 .print_header = json_print_header,
542 .print_footer = json_print_footer,
543 .print_chapter_header = json_print_chapter_header,
544 .print_chapter_footer = json_print_chapter_footer,
545 .print_section_header = json_print_section_header,
546 .print_section_footer = json_print_section_footer,
547 .print_integer = json_print_int,
548 .print_string = json_print_str,
549 .show_tags = json_show_tags,
552 static void writer_register_all(void)
554 static int initialized;
560 writer_register(&default_writer);
561 writer_register(&json_writer);
564 #define print_fmt(k, f, ...) do { \
565 if (fast_asprintf(&pbuf, f, __VA_ARGS__)) \
566 writer_print_string(w, k, pbuf.s); \
569 #define print_int(k, v) writer_print_integer(w, k, v)
570 #define print_str(k, v) writer_print_string(w, k, v)
571 #define print_section_header(s) writer_print_section_header(w, s)
572 #define print_section_footer(s) writer_print_section_footer(w, s)
573 #define show_tags(metadata) writer_show_tags(w, metadata)
575 static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx)
578 AVStream *st = fmt_ctx->streams[pkt->stream_index];
579 struct print_buf pbuf = {.s = NULL};
581 print_section_header("packet");
582 print_str("codec_type", av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown"));
583 print_int("stream_index", pkt->stream_index);
584 print_str("pts", ts_value_string (val_str, sizeof(val_str), pkt->pts));
585 print_str("pts_time", time_value_string(val_str, sizeof(val_str), pkt->pts, &st->time_base));
586 print_str("dts", ts_value_string (val_str, sizeof(val_str), pkt->dts));
587 print_str("dts_time", time_value_string(val_str, sizeof(val_str), pkt->dts, &st->time_base));
588 print_str("duration", ts_value_string (val_str, sizeof(val_str), pkt->duration));
589 print_str("duration_time", time_value_string(val_str, sizeof(val_str), pkt->duration, &st->time_base));
590 print_str("size", value_string (val_str, sizeof(val_str), pkt->size, unit_byte_str));
591 print_fmt("pos", "%"PRId64, pkt->pos);
592 print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
593 print_section_footer("packet");
599 static void show_packets(WriterContext *w, AVFormatContext *fmt_ctx)
604 av_init_packet(&pkt);
606 while (!av_read_frame(fmt_ctx, &pkt))
607 show_packet(w, fmt_ctx, &pkt, i++);
610 static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx)
612 AVStream *stream = fmt_ctx->streams[stream_idx];
613 AVCodecContext *dec_ctx;
616 AVRational display_aspect_ratio;
617 struct print_buf pbuf = {.s = NULL};
619 print_section_header("stream");
621 print_int("index", stream->index);
623 if ((dec_ctx = stream->codec)) {
624 if ((dec = dec_ctx->codec)) {
625 print_str("codec_name", dec->name);
626 print_str("codec_long_name", dec->long_name);
628 print_str("codec_name", "unknown");
631 print_str("codec_type", av_x_if_null(av_get_media_type_string(dec_ctx->codec_type), "unknown"));
632 print_fmt("codec_time_base", "%d/%d", dec_ctx->time_base.num, dec_ctx->time_base.den);
634 /* print AVI/FourCC tag */
635 av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
636 print_str("codec_tag_string", val_str);
637 print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag);
639 switch (dec_ctx->codec_type) {
640 case AVMEDIA_TYPE_VIDEO:
641 print_int("width", dec_ctx->width);
642 print_int("height", dec_ctx->height);
643 print_int("has_b_frames", dec_ctx->has_b_frames);
644 if (dec_ctx->sample_aspect_ratio.num) {
645 print_fmt("sample_aspect_ratio", "%d:%d",
646 dec_ctx->sample_aspect_ratio.num,
647 dec_ctx->sample_aspect_ratio.den);
648 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
649 dec_ctx->width * dec_ctx->sample_aspect_ratio.num,
650 dec_ctx->height * dec_ctx->sample_aspect_ratio.den,
652 print_fmt("display_aspect_ratio", "%d:%d",
653 display_aspect_ratio.num,
654 display_aspect_ratio.den);
656 print_str("pix_fmt", av_x_if_null(av_get_pix_fmt_name(dec_ctx->pix_fmt), "unknown"));
657 print_int("level", dec_ctx->level);
660 case AVMEDIA_TYPE_AUDIO:
661 print_str("sample_fmt",
662 av_x_if_null(av_get_sample_fmt_name(dec_ctx->sample_fmt), "unknown"));
663 print_str("sample_rate", value_string(val_str, sizeof(val_str), dec_ctx->sample_rate, unit_hertz_str));
664 print_int("channels", dec_ctx->channels);
665 print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id));
669 print_str("codec_type", "unknown");
672 if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS)
673 print_fmt("id", "0x%x", stream->id);
674 print_fmt("r_frame_rate", "%d/%d", stream->r_frame_rate.num, stream->r_frame_rate.den);
675 print_fmt("avg_frame_rate", "%d/%d", stream->avg_frame_rate.num, stream->avg_frame_rate.den);
676 print_fmt("time_base", "%d/%d", stream->time_base.num, stream->time_base.den);
677 print_str("start_time", time_value_string(val_str, sizeof(val_str), stream->start_time, &stream->time_base));
678 print_str("duration", time_value_string(val_str, sizeof(val_str), stream->duration, &stream->time_base));
679 if (stream->nb_frames)
680 print_fmt("nb_frames", "%"PRId64, stream->nb_frames);
682 show_tags(stream->metadata);
684 print_section_footer("stream");
689 static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
692 for (i = 0; i < fmt_ctx->nb_streams; i++)
693 show_stream(w, fmt_ctx, i);
696 static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
699 struct print_buf pbuf = {.s = NULL};
701 print_section_header("format");
702 print_str("filename", fmt_ctx->filename);
703 print_int("nb_streams", fmt_ctx->nb_streams);
704 print_str("format_name", fmt_ctx->iformat->name);
705 print_str("format_long_name", fmt_ctx->iformat->long_name);
706 print_str("start_time", time_value_string(val_str, sizeof(val_str), fmt_ctx->start_time, &AV_TIME_BASE_Q));
707 print_str("duration", time_value_string(val_str, sizeof(val_str), fmt_ctx->duration, &AV_TIME_BASE_Q));
708 print_str("size", value_string(val_str, sizeof(val_str), fmt_ctx->file_size, unit_byte_str));
709 print_str("bit_rate", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str));
710 show_tags(fmt_ctx->metadata);
711 print_section_footer("format");
716 static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
719 AVFormatContext *fmt_ctx = NULL;
720 AVDictionaryEntry *t;
722 if ((err = avformat_open_input(&fmt_ctx, filename, iformat, &format_opts)) < 0) {
723 print_error(filename, err);
726 if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
727 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
728 return AVERROR_OPTION_NOT_FOUND;
732 /* fill the streams in the format context */
733 if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
734 print_error(filename, err);
738 av_dump_format(fmt_ctx, 0, filename, 0);
740 /* bind a decoder to each input stream */
741 for (i = 0; i < fmt_ctx->nb_streams; i++) {
742 AVStream *stream = fmt_ctx->streams[i];
745 if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
746 fprintf(stderr, "Unsupported codec with id %d for input stream %d\n",
747 stream->codec->codec_id, stream->index);
748 } else if (avcodec_open2(stream->codec, codec, NULL) < 0) {
749 fprintf(stderr, "Error while opening codec for input stream %d\n",
754 *fmt_ctx_ptr = fmt_ctx;
758 #define PRINT_CHAPTER(name) do { \
759 if (do_show_ ## name) { \
760 writer_print_chapter_header(wctx, #name); \
761 show_ ## name (wctx, fmt_ctx); \
762 writer_print_chapter_footer(wctx, #name); \
766 static int probe_file(const char *filename)
768 AVFormatContext *fmt_ctx;
771 const char *buf = print_format;
772 char *w_str = NULL, *w_args = NULL;
775 writer_register_all();
778 w_str = av_get_token(&buf, "=");
781 w_args = av_get_token(&buf, "");
786 w_str = av_strdup("default");
788 w = writer_get_by_name(w_str);
790 av_log(NULL, AV_LOG_ERROR, "Invalid output format '%s'\n", w_str);
791 ret = AVERROR(EINVAL);
795 if ((ret = writer_open(&wctx, w, w_args, NULL)) < 0)
797 if ((ret = open_input_file(&fmt_ctx, filename)))
800 writer_print_header(wctx);
801 PRINT_CHAPTER(packets);
802 PRINT_CHAPTER(streams);
803 PRINT_CHAPTER(format);
804 writer_print_footer(wctx);
806 av_close_input_file(fmt_ctx);
816 static void show_usage(void)
818 printf("Simple multimedia streams analyzer\n");
819 printf("usage: %s [OPTIONS] [INPUT_FILE]\n", program_name);
823 static int opt_format(const char *opt, const char *arg)
825 iformat = av_find_input_format(arg);
827 fprintf(stderr, "Unknown input format: %s\n", arg);
828 return AVERROR(EINVAL);
833 static void opt_input_file(void *optctx, const char *arg)
835 if (input_filename) {
836 fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
837 arg, input_filename);
840 if (!strcmp(arg, "-"))
842 input_filename = arg;
845 static int opt_help(const char *opt, const char *arg)
847 av_log_set_callback(log_callback_help);
849 show_help_options(options, "Main options:\n", 0, 0);
852 show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
857 static int opt_pretty(const char *opt, const char *arg)
860 use_value_prefix = 1;
861 use_byte_value_binary_prefix = 1;
862 use_value_sexagesimal_format = 1;
866 static const OptionDef options[] = {
867 #include "cmdutils_common_opts.h"
868 { "f", HAS_ARG, {(void*)opt_format}, "force format", "format" },
869 { "unit", OPT_BOOL, {(void*)&show_value_unit}, "show unit of the displayed values" },
870 { "prefix", OPT_BOOL, {(void*)&use_value_prefix}, "use SI prefixes for the displayed values" },
871 { "byte_binary_prefix", OPT_BOOL, {(void*)&use_byte_value_binary_prefix},
872 "use binary prefixes for byte units" },
873 { "sexagesimal", OPT_BOOL, {(void*)&use_value_sexagesimal_format},
874 "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
875 { "pretty", 0, {(void*)&opt_pretty},
876 "prettify the format of displayed values, make it more human readable" },
877 { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format}, "set the output printing format (available formats are: default, json)", "format" },
878 { "show_format", OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
879 { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
880 { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },
881 { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
882 { "i", HAS_ARG, {(void *)opt_input_file}, "read specified file", "input_file"},
886 int main(int argc, char **argv)
890 parse_loglevel(argc, argv, options);
894 avdevice_register_all();
898 parse_options(NULL, argc, argv, options, opt_input_file);
900 if (!input_filename) {
902 fprintf(stderr, "You have to specify one input file.\n");
903 fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
907 ret = probe_file(input_filename);