You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

699 lines
22KB

  1. /*
  2. * ffprobe : Simple Media Prober based on the FFmpeg libraries
  3. * Copyright (c) 2007-2010 Stefano Sabatini
  4. *
  5. * This file is part of FFmpeg.
  6. *
  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.
  11. *
  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.
  16. *
  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
  20. */
  21. #include "config.h"
  22. #include "libavformat/avformat.h"
  23. #include "libavcodec/avcodec.h"
  24. #include "libavutil/opt.h"
  25. #include "libavutil/pixdesc.h"
  26. #include "libavutil/dict.h"
  27. #include "libavdevice/avdevice.h"
  28. #include "cmdutils.h"
  29. const char program_name[] = "ffprobe";
  30. const int program_birth_year = 2007;
  31. static int do_show_format = 0;
  32. static int do_show_packets = 0;
  33. static int do_show_streams = 0;
  34. static int show_value_unit = 0;
  35. static int use_value_prefix = 0;
  36. static int use_byte_value_binary_prefix = 0;
  37. static int use_value_sexagesimal_format = 0;
  38. static char *print_format;
  39. /* globals */
  40. static const OptionDef options[];
  41. /* FFprobe context */
  42. static const char *input_filename;
  43. static AVInputFormat *iformat = NULL;
  44. static const char *binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
  45. static const char *decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P" };
  46. static const char *unit_second_str = "s" ;
  47. static const char *unit_hertz_str = "Hz" ;
  48. static const char *unit_byte_str = "byte" ;
  49. static const char *unit_bit_per_second_str = "bit/s";
  50. void exit_program(int ret)
  51. {
  52. exit(ret);
  53. }
  54. static char *value_string(char *buf, int buf_size, double val, const char *unit)
  55. {
  56. if (unit == unit_second_str && use_value_sexagesimal_format) {
  57. double secs;
  58. int hours, mins;
  59. secs = val;
  60. mins = (int)secs / 60;
  61. secs = secs - mins * 60;
  62. hours = mins / 60;
  63. mins %= 60;
  64. snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
  65. } else if (use_value_prefix) {
  66. const char *prefix_string;
  67. int index;
  68. if (unit == unit_byte_str && use_byte_value_binary_prefix) {
  69. index = (int) (log(val)/log(2)) / 10;
  70. index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) -1);
  71. val /= pow(2, index*10);
  72. prefix_string = binary_unit_prefixes[index];
  73. } else {
  74. index = (int) (log10(val)) / 3;
  75. index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) -1);
  76. val /= pow(10, index*3);
  77. prefix_string = decimal_unit_prefixes[index];
  78. }
  79. snprintf(buf, buf_size, "%.3f%s%s%s", val, prefix_string || show_value_unit ? " " : "",
  80. prefix_string, show_value_unit ? unit : "");
  81. } else {
  82. snprintf(buf, buf_size, "%f%s%s", val, show_value_unit ? " " : "",
  83. show_value_unit ? unit : "");
  84. }
  85. return buf;
  86. }
  87. static char *time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base)
  88. {
  89. if (val == AV_NOPTS_VALUE) {
  90. snprintf(buf, buf_size, "N/A");
  91. } else {
  92. value_string(buf, buf_size, val * av_q2d(*time_base), unit_second_str);
  93. }
  94. return buf;
  95. }
  96. static char *ts_value_string (char *buf, int buf_size, int64_t ts)
  97. {
  98. if (ts == AV_NOPTS_VALUE) {
  99. snprintf(buf, buf_size, "N/A");
  100. } else {
  101. snprintf(buf, buf_size, "%"PRId64, ts);
  102. }
  103. return buf;
  104. }
  105. static const char *media_type_string(enum AVMediaType media_type)
  106. {
  107. const char *s = av_get_media_type_string(media_type);
  108. return s ? s : "unknown";
  109. }
  110. struct writer {
  111. const char *name;
  112. const char *item_sep; ///< separator between key/value couples
  113. const char *items_sep; ///< separator between sets of key/value couples
  114. const char *section_sep; ///< separator between sections (streams, packets, ...)
  115. const char *header, *footer;
  116. void (*print_section_start)(const char *, int);
  117. void (*print_section_end) (const char *, int);
  118. void (*print_header)(const char *);
  119. void (*print_footer)(const char *);
  120. void (*print_integer)(const char *, int);
  121. void (*print_string)(const char *, const char *);
  122. void (*show_tags)(struct writer *w, AVDictionary *dict);
  123. };
  124. /* JSON output */
  125. static void json_print_header(const char *section)
  126. {
  127. printf("{\n");
  128. }
  129. static char *json_escape_str(const char *s)
  130. {
  131. static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
  132. static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0};
  133. char *ret, *p;
  134. int i, len = 0;
  135. // compute the length of the escaped string
  136. for (i = 0; s[i]; i++) {
  137. if (strchr(json_escape, s[i])) len += 2; // simple escape
  138. else if ((unsigned char)s[i] < 32) len += 6; // handle non-printable chars
  139. else len += 1; // char copy
  140. }
  141. p = ret = av_malloc(len + 1);
  142. if (!p)
  143. return NULL;
  144. for (i = 0; s[i]; i++) {
  145. char *q = strchr(json_escape, s[i]);
  146. if (q) {
  147. *p++ = '\\';
  148. *p++ = json_subst[q - json_escape];
  149. } else if ((unsigned char)s[i] < 32) {
  150. snprintf(p, 7, "\\u00%02x", s[i] & 0xff);
  151. p += 6;
  152. } else {
  153. *p++ = s[i];
  154. }
  155. }
  156. *p = 0;
  157. return ret;
  158. }
  159. static void json_print_str(const char *key, const char *value)
  160. {
  161. char *key_esc = json_escape_str(key);
  162. char *value_esc = json_escape_str(value);
  163. printf(" \"%s\": \"%s\"",
  164. key_esc ? key_esc : "",
  165. value_esc ? value_esc : "");
  166. av_free(key_esc);
  167. av_free(value_esc);
  168. }
  169. static void json_print_int(const char *key, int value)
  170. {
  171. char *key_esc = json_escape_str(key);
  172. printf(" \"%s\": %d", key_esc ? key_esc : "", value);
  173. av_free(key_esc);
  174. }
  175. static void json_print_footer(const char *section)
  176. {
  177. printf("\n }");
  178. }
  179. static void json_print_section_start(const char *section, int multiple_entries)
  180. {
  181. char *section_esc = json_escape_str(section);
  182. printf("\n \"%s\":%s", section_esc ? section_esc : "",
  183. multiple_entries ? " [" : " ");
  184. av_free(section_esc);
  185. }
  186. static void json_print_section_end(const char *section, int multiple_entries)
  187. {
  188. if (multiple_entries)
  189. printf("]");
  190. }
  191. /* Default output */
  192. static void default_print_header(const char *section)
  193. {
  194. printf("[%s]\n", section);
  195. }
  196. static void default_print_str(const char *key, const char *value)
  197. {
  198. printf("%s=%s", key, value);
  199. }
  200. static void default_print_int(const char *key, int value)
  201. {
  202. printf("%s=%d", key, value);
  203. }
  204. static void default_print_footer(const char *section)
  205. {
  206. printf("\n[/%s]", section);
  207. }
  208. /* Print helpers */
  209. struct print_buf {
  210. char *s;
  211. int len;
  212. };
  213. static char *fast_asprintf(struct print_buf *pbuf, const char *fmt, ...)
  214. {
  215. va_list va;
  216. int len;
  217. va_start(va, fmt);
  218. len = vsnprintf(NULL, 0, fmt, va);
  219. va_end(va);
  220. if (len < 0)
  221. goto fail;
  222. if (pbuf->len < len) {
  223. char *p = av_realloc(pbuf->s, len + 1);
  224. if (!p)
  225. goto fail;
  226. pbuf->s = p;
  227. pbuf->len = len;
  228. }
  229. va_start(va, fmt);
  230. len = vsnprintf(pbuf->s, len + 1, fmt, va);
  231. va_end(va);
  232. if (len < 0)
  233. goto fail;
  234. return pbuf->s;
  235. fail:
  236. av_freep(&pbuf->s);
  237. pbuf->len = 0;
  238. return NULL;
  239. }
  240. #define print_fmt0(k, f, ...) do { \
  241. if (fast_asprintf(&pbuf, f, __VA_ARGS__)) \
  242. w->print_string(k, pbuf.s); \
  243. } while (0)
  244. #define print_fmt( k, f, ...) do { \
  245. if (w->item_sep) \
  246. printf("%s", w->item_sep); \
  247. print_fmt0(k, f, __VA_ARGS__); \
  248. } while (0)
  249. #define print_int0(k, v) w->print_integer(k, v)
  250. #define print_int( k, v) do { \
  251. if (w->item_sep) \
  252. printf("%s", w->item_sep); \
  253. print_int0(k, v); \
  254. } while (0)
  255. #define print_str0(k, v) print_fmt0(k, "%s", v)
  256. #define print_str( k, v) print_fmt (k, "%s", v)
  257. static void show_packet(struct writer *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx)
  258. {
  259. char val_str[128];
  260. AVStream *st = fmt_ctx->streams[pkt->stream_index];
  261. struct print_buf pbuf = {.s = NULL};
  262. if (packet_idx)
  263. printf("%s", w->items_sep);
  264. w->print_header("PACKET");
  265. print_str0("codec_type", media_type_string(st->codec->codec_type));
  266. print_int("stream_index", pkt->stream_index);
  267. print_str("pts", ts_value_string (val_str, sizeof(val_str), pkt->pts));
  268. print_str("pts_time", time_value_string(val_str, sizeof(val_str), pkt->pts, &st->time_base));
  269. print_str("dts", ts_value_string (val_str, sizeof(val_str), pkt->dts));
  270. print_str("dts_time", time_value_string(val_str, sizeof(val_str), pkt->dts, &st->time_base));
  271. print_str("duration", ts_value_string (val_str, sizeof(val_str), pkt->duration));
  272. print_str("duration_time", time_value_string(val_str, sizeof(val_str), pkt->duration, &st->time_base));
  273. print_str("size", value_string (val_str, sizeof(val_str), pkt->size, unit_byte_str));
  274. print_fmt("pos", "%"PRId64, pkt->pos);
  275. print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
  276. w->print_footer("PACKET");
  277. av_free(pbuf.s);
  278. fflush(stdout);
  279. }
  280. static void show_packets(struct writer *w, AVFormatContext *fmt_ctx)
  281. {
  282. AVPacket pkt;
  283. int i = 0;
  284. av_init_packet(&pkt);
  285. while (!av_read_frame(fmt_ctx, &pkt))
  286. show_packet(w, fmt_ctx, &pkt, i++);
  287. }
  288. static void json_show_tags(struct writer *w, AVDictionary *dict)
  289. {
  290. AVDictionaryEntry *tag = NULL;
  291. struct print_buf pbuf = {.s = NULL};
  292. int first = 1;
  293. if (!dict)
  294. return;
  295. printf(",\n \"tags\": {\n");
  296. while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
  297. if (first) {
  298. print_str0(tag->key, tag->value);
  299. first = 0;
  300. } else {
  301. print_str(tag->key, tag->value);
  302. }
  303. }
  304. printf("\n }");
  305. av_free(pbuf.s);
  306. }
  307. static void default_show_tags(struct writer *w, AVDictionary *dict)
  308. {
  309. AVDictionaryEntry *tag = NULL;
  310. struct print_buf pbuf = {.s = NULL};
  311. while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
  312. printf("\nTAG:");
  313. print_str0(tag->key, tag->value);
  314. }
  315. av_free(pbuf.s);
  316. }
  317. static void show_stream(struct writer *w, AVFormatContext *fmt_ctx, int stream_idx)
  318. {
  319. AVStream *stream = fmt_ctx->streams[stream_idx];
  320. AVCodecContext *dec_ctx;
  321. AVCodec *dec;
  322. char val_str[128];
  323. AVRational display_aspect_ratio;
  324. struct print_buf pbuf = {.s = NULL};
  325. if (stream_idx)
  326. printf("%s", w->items_sep);
  327. w->print_header("STREAM");
  328. print_int0("index", stream->index);
  329. if ((dec_ctx = stream->codec)) {
  330. if ((dec = dec_ctx->codec)) {
  331. print_str("codec_name", dec->name);
  332. print_str("codec_long_name", dec->long_name);
  333. } else {
  334. print_str("codec_name", "unknown");
  335. }
  336. print_str("codec_type", media_type_string(dec_ctx->codec_type));
  337. print_fmt("codec_time_base", "%d/%d", dec_ctx->time_base.num, dec_ctx->time_base.den);
  338. /* print AVI/FourCC tag */
  339. av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
  340. print_str("codec_tag_string", val_str);
  341. print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag);
  342. switch (dec_ctx->codec_type) {
  343. case AVMEDIA_TYPE_VIDEO:
  344. print_int("width", dec_ctx->width);
  345. print_int("height", dec_ctx->height);
  346. print_int("has_b_frames", dec_ctx->has_b_frames);
  347. if (dec_ctx->sample_aspect_ratio.num) {
  348. print_fmt("sample_aspect_ratio", "%d:%d",
  349. dec_ctx->sample_aspect_ratio.num,
  350. dec_ctx->sample_aspect_ratio.den);
  351. av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
  352. dec_ctx->width * dec_ctx->sample_aspect_ratio.num,
  353. dec_ctx->height * dec_ctx->sample_aspect_ratio.den,
  354. 1024*1024);
  355. print_fmt("display_aspect_ratio", "%d:%d",
  356. display_aspect_ratio.num,
  357. display_aspect_ratio.den);
  358. }
  359. print_str("pix_fmt", dec_ctx->pix_fmt != PIX_FMT_NONE ? av_pix_fmt_descriptors[dec_ctx->pix_fmt].name : "unknown");
  360. print_int("level", dec_ctx->level);
  361. break;
  362. case AVMEDIA_TYPE_AUDIO:
  363. print_str("sample_rate", value_string(val_str, sizeof(val_str), dec_ctx->sample_rate, unit_hertz_str));
  364. print_int("channels", dec_ctx->channels);
  365. print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id));
  366. break;
  367. }
  368. } else {
  369. print_str("codec_type", "unknown");
  370. }
  371. if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS)
  372. print_fmt("id=", "0x%x", stream->id);
  373. print_fmt("r_frame_rate", "%d/%d", stream->r_frame_rate.num, stream->r_frame_rate.den);
  374. print_fmt("avg_frame_rate", "%d/%d", stream->avg_frame_rate.num, stream->avg_frame_rate.den);
  375. print_fmt("time_base", "%d/%d", stream->time_base.num, stream->time_base.den);
  376. print_str("start_time", time_value_string(val_str, sizeof(val_str), stream->start_time, &stream->time_base));
  377. print_str("duration", time_value_string(val_str, sizeof(val_str), stream->duration, &stream->time_base));
  378. if (stream->nb_frames)
  379. print_fmt("nb_frames", "%"PRId64, stream->nb_frames);
  380. w->show_tags(w, stream->metadata);
  381. w->print_footer("STREAM");
  382. av_free(pbuf.s);
  383. fflush(stdout);
  384. }
  385. static void show_streams(struct writer *w, AVFormatContext *fmt_ctx)
  386. {
  387. int i;
  388. for (i = 0; i < fmt_ctx->nb_streams; i++)
  389. show_stream(w, fmt_ctx, i);
  390. }
  391. static void show_format(struct writer *w, AVFormatContext *fmt_ctx)
  392. {
  393. char val_str[128];
  394. struct print_buf pbuf = {.s = NULL};
  395. w->print_header("FORMAT");
  396. print_str0("filename", fmt_ctx->filename);
  397. print_int("nb_streams", fmt_ctx->nb_streams);
  398. print_str("format_name", fmt_ctx->iformat->name);
  399. print_str("format_long_name", fmt_ctx->iformat->long_name);
  400. print_str("start_time", time_value_string(val_str, sizeof(val_str), fmt_ctx->start_time, &AV_TIME_BASE_Q));
  401. print_str("duration", time_value_string(val_str, sizeof(val_str), fmt_ctx->duration, &AV_TIME_BASE_Q));
  402. print_str("size", value_string(val_str, sizeof(val_str), fmt_ctx->file_size, unit_byte_str));
  403. print_str("bit_rate", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str));
  404. w->show_tags(w, fmt_ctx->metadata);
  405. w->print_footer("FORMAT");
  406. av_free(pbuf.s);
  407. fflush(stdout);
  408. }
  409. static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
  410. {
  411. int err, i;
  412. AVFormatContext *fmt_ctx = NULL;
  413. AVDictionaryEntry *t;
  414. if ((err = avformat_open_input(&fmt_ctx, filename, iformat, &format_opts)) < 0) {
  415. print_error(filename, err);
  416. return err;
  417. }
  418. if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
  419. av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
  420. return AVERROR_OPTION_NOT_FOUND;
  421. }
  422. /* fill the streams in the format context */
  423. if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
  424. print_error(filename, err);
  425. return err;
  426. }
  427. av_dump_format(fmt_ctx, 0, filename, 0);
  428. /* bind a decoder to each input stream */
  429. for (i = 0; i < fmt_ctx->nb_streams; i++) {
  430. AVStream *stream = fmt_ctx->streams[i];
  431. AVCodec *codec;
  432. if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
  433. fprintf(stderr, "Unsupported codec with id %d for input stream %d\n",
  434. stream->codec->codec_id, stream->index);
  435. } else if (avcodec_open2(stream->codec, codec, NULL) < 0) {
  436. fprintf(stderr, "Error while opening codec for input stream %d\n",
  437. stream->index);
  438. }
  439. }
  440. *fmt_ctx_ptr = fmt_ctx;
  441. return 0;
  442. }
  443. #define WRITER_FUNC(func) \
  444. .print_header = func ## _print_header, \
  445. .print_footer = func ## _print_footer, \
  446. .print_integer = func ## _print_int, \
  447. .print_string = func ## _print_str, \
  448. .show_tags = func ## _show_tags
  449. static struct writer writers[] = {{
  450. .name = "default",
  451. .item_sep = "\n",
  452. .items_sep = "\n",
  453. .section_sep = "\n",
  454. .footer = "\n",
  455. WRITER_FUNC(default),
  456. },{
  457. .name = "json",
  458. .header = "{",
  459. .item_sep = ",\n",
  460. .items_sep = ",",
  461. .section_sep = ",",
  462. .footer = "\n}\n",
  463. .print_section_start = json_print_section_start,
  464. .print_section_end = json_print_section_end,
  465. WRITER_FUNC(json),
  466. }
  467. };
  468. static int get_writer(const char *name)
  469. {
  470. int i;
  471. if (!name)
  472. return 0;
  473. for (i = 0; i < FF_ARRAY_ELEMS(writers); i++)
  474. if (!strcmp(writers[i].name, name))
  475. return i;
  476. return -1;
  477. }
  478. #define SECTION_PRINT(name, multiple_entries, left) do { \
  479. if (do_show_ ## name) { \
  480. if (w->print_section_start) \
  481. w->print_section_start(#name, multiple_entries); \
  482. show_ ## name (w, fmt_ctx); \
  483. if (w->print_section_end) \
  484. w->print_section_end(#name, multiple_entries); \
  485. if (left) \
  486. printf("%s", w->section_sep); \
  487. } \
  488. } while (0)
  489. static int probe_file(const char *filename)
  490. {
  491. AVFormatContext *fmt_ctx;
  492. int ret, writer_id;
  493. struct writer *w;
  494. writer_id = get_writer(print_format);
  495. if (writer_id < 0) {
  496. fprintf(stderr, "Invalid output format '%s'\n", print_format);
  497. return AVERROR(EINVAL);
  498. }
  499. w = &writers[writer_id];
  500. if ((ret = open_input_file(&fmt_ctx, filename)))
  501. return ret;
  502. if (w->header)
  503. printf("%s", w->header);
  504. SECTION_PRINT(packets, 1, do_show_streams || do_show_format);
  505. SECTION_PRINT(streams, 1, do_show_format);
  506. SECTION_PRINT(format, 0, 0);
  507. if (w->footer)
  508. printf("%s", w->footer);
  509. av_close_input_file(fmt_ctx);
  510. return 0;
  511. }
  512. static void show_usage(void)
  513. {
  514. printf("Simple multimedia streams analyzer\n");
  515. printf("usage: %s [OPTIONS] [INPUT_FILE]\n", program_name);
  516. printf("\n");
  517. }
  518. static int opt_format(const char *opt, const char *arg)
  519. {
  520. iformat = av_find_input_format(arg);
  521. if (!iformat) {
  522. fprintf(stderr, "Unknown input format: %s\n", arg);
  523. return AVERROR(EINVAL);
  524. }
  525. return 0;
  526. }
  527. static void opt_input_file(void *optctx, const char *arg)
  528. {
  529. if (input_filename) {
  530. fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
  531. arg, input_filename);
  532. exit(1);
  533. }
  534. if (!strcmp(arg, "-"))
  535. arg = "pipe:";
  536. input_filename = arg;
  537. }
  538. static int opt_help(const char *opt, const char *arg)
  539. {
  540. const AVClass *class = avformat_get_class();
  541. av_log_set_callback(log_callback_help);
  542. show_usage();
  543. show_help_options(options, "Main options:\n", 0, 0);
  544. printf("\n");
  545. av_opt_show2(&class, NULL,
  546. AV_OPT_FLAG_DECODING_PARAM, 0);
  547. return 0;
  548. }
  549. static int opt_pretty(const char *opt, const char *arg)
  550. {
  551. show_value_unit = 1;
  552. use_value_prefix = 1;
  553. use_byte_value_binary_prefix = 1;
  554. use_value_sexagesimal_format = 1;
  555. return 0;
  556. }
  557. static const OptionDef options[] = {
  558. #include "cmdutils_common_opts.h"
  559. { "f", HAS_ARG, {(void*)opt_format}, "force format", "format" },
  560. { "unit", OPT_BOOL, {(void*)&show_value_unit}, "show unit of the displayed values" },
  561. { "prefix", OPT_BOOL, {(void*)&use_value_prefix}, "use SI prefixes for the displayed values" },
  562. { "byte_binary_prefix", OPT_BOOL, {(void*)&use_byte_value_binary_prefix},
  563. "use binary prefixes for byte units" },
  564. { "sexagesimal", OPT_BOOL, {(void*)&use_value_sexagesimal_format},
  565. "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
  566. { "pretty", 0, {(void*)&opt_pretty},
  567. "prettify the format of displayed values, make it more human readable" },
  568. { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format}, "set the output printing format (available formats are: default, json)" },
  569. { "show_format", OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
  570. { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
  571. { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },
  572. { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
  573. { "i", HAS_ARG, {(void *)opt_input_file}, "read specified file", "input_file"},
  574. { NULL, },
  575. };
  576. int main(int argc, char **argv)
  577. {
  578. int ret;
  579. av_register_all();
  580. init_opts();
  581. #if CONFIG_AVDEVICE
  582. avdevice_register_all();
  583. #endif
  584. show_banner();
  585. parse_options(NULL, argc, argv, options, opt_input_file);
  586. if (!input_filename) {
  587. show_usage();
  588. fprintf(stderr, "You have to specify one input file.\n");
  589. fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
  590. exit(1);
  591. }
  592. ret = probe_file(input_filename);
  593. return ret;
  594. }