Libav
avprobe.c
Go to the documentation of this file.
1 /*
2  * avprobe : Simple Media Prober based on the Libav libraries
3  * Copyright (c) 2007-2010 Stefano Sabatini
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "config.h"
23 
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 "libavutil/libm.h"
31 #include "libavdevice/avdevice.h"
32 #include "cmdutils.h"
33 
34 const char program_name[] = "avprobe";
35 const int program_birth_year = 2007;
36 
37 static int do_show_format = 0;
40 static int do_show_packets = 0;
41 static int do_show_streams = 0;
42 
43 static int show_value_unit = 0;
44 static int use_value_prefix = 0;
47 
48 /* globals */
49 static const OptionDef *options;
50 
51 /* AVprobe context */
52 static const char *input_filename;
54 
55 static const char *const binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
56 static const char *const decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P" };
57 
58 static const char unit_second_str[] = "s" ;
59 static const char unit_hertz_str[] = "Hz" ;
60 static const char unit_byte_str[] = "byte" ;
61 static const char unit_bit_per_second_str[] = "bit/s";
62 
63 static void avprobe_cleanup(int ret)
64 {
65  av_dict_free(&fmt_entries_to_show);
66 }
67 
68 /*
69  * The output is structured in array and objects that might contain items
70  * Array could require the objects within to not be named.
71  * Object could require the items within to be named.
72  *
73  * For flat representation the name of each section is saved on prefix so it
74  * can be rendered in order to represent nested structures (e.g. array of
75  * objects for the packets list).
76  *
77  * Within an array each element can need an unique identifier or an index.
78  *
79  * Nesting level is accounted separately.
80  */
81 
82 typedef enum {
86 
87 typedef struct {
88  const char *name;
90  int64_t index;
91  int64_t nb_elems;
92 } PrintElement;
93 
94 typedef struct {
96  int level;
97  void (*print_header)(void);
98  void (*print_footer)(void);
99 
100  void (*print_array_header) (const char *name);
101  void (*print_array_footer) (const char *name);
102  void (*print_object_header)(const char *name);
103  void (*print_object_footer)(const char *name);
104 
105  void (*print_integer) (const char *key, int64_t value);
106  void (*print_string) (const char *key, const char *value);
107 } PrintContext;
108 
111 #define AVP_INDENT() avio_printf(probe_out, "%*c", octx.level * 2, ' ')
112 
113 /*
114  * Default format, INI
115  *
116  * - all key and values are utf8
117  * - '.' is the subgroup separator
118  * - newlines and the following characters are escaped
119  * - '\' is the escape character
120  * - '#' is the comment
121  * - '=' is the key/value separators
122  * - ':' is not used but usually parsed as key/value separator
123  */
124 
125 static void ini_print_header(void)
126 {
127  avio_printf(probe_out, "# avprobe output\n\n");
128 }
129 static void ini_print_footer(void)
130 {
131  avio_w8(probe_out, '\n');
132 }
133 
134 static void ini_escape_print(const char *s)
135 {
136  int i = 0;
137  char c = 0;
138 
139  while (c = s[i++]) {
140  switch (c) {
141  case '\r': avio_printf(probe_out, "%s", "\\r"); break;
142  case '\n': avio_printf(probe_out, "%s", "\\n"); break;
143  case '\f': avio_printf(probe_out, "%s", "\\f"); break;
144  case '\b': avio_printf(probe_out, "%s", "\\b"); break;
145  case '\t': avio_printf(probe_out, "%s", "\\t"); break;
146  case '\\':
147  case '#' :
148  case '=' :
149  case ':' : avio_w8(probe_out, '\\');
150  default:
151  if ((unsigned char)c < 32)
152  avio_printf(probe_out, "\\x00%02x", c & 0xff);
153  else
154  avio_w8(probe_out, c);
155  break;
156  }
157  }
158 }
159 
160 static void ini_print_array_header(const char *name)
161 {
162  if (octx.prefix[octx.level -1].nb_elems)
163  avio_printf(probe_out, "\n");
164 }
165 
166 static void ini_print_object_header(const char *name)
167 {
168  int i;
169  PrintElement *el = octx.prefix + octx.level -1;
170 
171  if (el->nb_elems)
172  avio_printf(probe_out, "\n");
173 
174  avio_printf(probe_out, "[");
175 
176  for (i = 1; i < octx.level; i++) {
177  el = octx.prefix + i;
178  avio_printf(probe_out, "%s.", el->name);
179  if (el->index >= 0)
180  avio_printf(probe_out, "%"PRId64".", el->index);
181  }
182 
183  avio_printf(probe_out, "%s", name);
184  if (el && el->type == ARRAY)
185  avio_printf(probe_out, ".%"PRId64"", el->nb_elems);
186  avio_printf(probe_out, "]\n");
187 }
188 
189 static void ini_print_integer(const char *key, int64_t value)
190 {
191  ini_escape_print(key);
192  avio_printf(probe_out, "=%"PRId64"\n", value);
193 }
194 
195 
196 static void ini_print_string(const char *key, const char *value)
197 {
198  ini_escape_print(key);
199  avio_printf(probe_out, "=");
200  ini_escape_print(value);
201  avio_w8(probe_out, '\n');
202 }
203 
204 /*
205  * Alternate format, JSON
206  */
207 
208 static void json_print_header(void)
209 {
210  avio_printf(probe_out, "{");
211 }
212 static void json_print_footer(void)
213 {
214  avio_printf(probe_out, "}\n");
215 }
216 
217 static void json_print_array_header(const char *name)
218 {
219  if (octx.prefix[octx.level -1].nb_elems)
220  avio_printf(probe_out, ",\n");
221  AVP_INDENT();
222  avio_printf(probe_out, "\"%s\" : ", name);
223  avio_printf(probe_out, "[\n");
224 }
225 
226 static void json_print_array_footer(const char *name)
227 {
228  avio_printf(probe_out, "\n");
229  AVP_INDENT();
230  avio_printf(probe_out, "]");
231 }
232 
233 static void json_print_object_header(const char *name)
234 {
235  if (octx.prefix[octx.level -1].nb_elems)
236  avio_printf(probe_out, ",\n");
237  AVP_INDENT();
238  if (octx.prefix[octx.level -1].type == OBJECT)
239  avio_printf(probe_out, "\"%s\" : ", name);
240  avio_printf(probe_out, "{\n");
241 }
242 
243 static void json_print_object_footer(const char *name)
244 {
245  avio_printf(probe_out, "\n");
246  AVP_INDENT();
247  avio_printf(probe_out, "}");
248 }
249 
250 static void json_print_integer(const char *key, int64_t value)
251 {
252  if (octx.prefix[octx.level -1].nb_elems)
253  avio_printf(probe_out, ",\n");
254  AVP_INDENT();
255  avio_printf(probe_out, "\"%s\" : %"PRId64"", key, value);
256 }
257 
258 static void json_escape_print(const char *s)
259 {
260  int i = 0;
261  char c = 0;
262 
263  while (c = s[i++]) {
264  switch (c) {
265  case '\r': avio_printf(probe_out, "%s", "\\r"); break;
266  case '\n': avio_printf(probe_out, "%s", "\\n"); break;
267  case '\f': avio_printf(probe_out, "%s", "\\f"); break;
268  case '\b': avio_printf(probe_out, "%s", "\\b"); break;
269  case '\t': avio_printf(probe_out, "%s", "\\t"); break;
270  case '\\':
271  case '"' : avio_w8(probe_out, '\\');
272  default:
273  if ((unsigned char)c < 32)
274  avio_printf(probe_out, "\\u00%02x", c & 0xff);
275  else
276  avio_w8(probe_out, c);
277  break;
278  }
279  }
280 }
281 
282 static void json_print_string(const char *key, const char *value)
283 {
284  if (octx.prefix[octx.level -1].nb_elems)
285  avio_printf(probe_out, ",\n");
286  AVP_INDENT();
287  avio_w8(probe_out, '\"');
288  json_escape_print(key);
289  avio_printf(probe_out, "\" : \"");
290  json_escape_print(value);
291  avio_w8(probe_out, '\"');
292 }
293 
294 /*
295  * old-style pseudo-INI
296  */
297 static void old_print_object_header(const char *name)
298 {
299  char *str, *p;
300 
301  if (!strcmp(name, "tags"))
302  return;
303 
304  str = p = av_strdup(name);
305  while (*p) {
306  *p = av_toupper(*p);
307  p++;
308  }
309 
310  avio_printf(probe_out, "[%s]\n", str);
311  av_freep(&str);
312 }
313 
314 static void old_print_object_footer(const char *name)
315 {
316  char *str, *p;
317 
318  if (!strcmp(name, "tags"))
319  return;
320 
321  str = p = av_strdup(name);
322  while (*p) {
323  *p = av_toupper(*p);
324  p++;
325  }
326 
327  avio_printf(probe_out, "[/%s]\n", str);
328  av_freep(&str);
329 }
330 
331 static void old_print_string(const char *key, const char *value)
332 {
333  if (!strcmp(octx.prefix[octx.level - 1].name, "tags"))
334  avio_printf(probe_out, "TAG:");
335  ini_print_string(key, value);
336 }
337 
338 /*
339  * Simple Formatter for single entries.
340  */
341 
342 static void show_format_entry_integer(const char *key, int64_t value)
343 {
344  if (key && av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
345  if (nb_fmt_entries_to_show > 1)
346  avio_printf(probe_out, "%s=", key);
347  avio_printf(probe_out, "%"PRId64"\n", value);
348  }
349 }
350 
351 static void show_format_entry_string(const char *key, const char *value)
352 {
353  if (key && av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
354  if (nb_fmt_entries_to_show > 1)
355  avio_printf(probe_out, "%s=", key);
356  avio_printf(probe_out, "%s\n", value);
357  }
358 }
359 
360 static void probe_group_enter(const char *name, int type)
361 {
362  int64_t count = -1;
363 
364  octx.prefix =
365  av_realloc(octx.prefix, sizeof(PrintElement) * (octx.level + 1));
366 
367  if (!octx.prefix || !name) {
368  fprintf(stderr, "Out of memory\n");
369  exit_program(1);
370  }
371 
372  if (octx.level) {
373  PrintElement *parent = octx.prefix + octx.level -1;
374  if (parent->type == ARRAY)
375  count = parent->nb_elems;
376  parent->nb_elems++;
377  }
378 
379  octx.prefix[octx.level++] = (PrintElement){name, type, count, 0};
380 }
381 
382 static void probe_group_leave(void)
383 {
384  --octx.level;
385 }
386 
387 static void probe_header(void)
388 {
389  if (octx.print_header)
390  octx.print_header();
391  probe_group_enter("root", OBJECT);
392 }
393 
394 static void probe_footer(void)
395 {
396  if (octx.print_footer)
397  octx.print_footer();
399 }
400 
401 
402 static void probe_array_header(const char *name)
403 {
404  if (octx.print_array_header)
405  octx.print_array_header(name);
406 
407  probe_group_enter(name, ARRAY);
408 }
409 
410 static void probe_array_footer(const char *name)
411 {
413  if (octx.print_array_footer)
414  octx.print_array_footer(name);
415 }
416 
417 static void probe_object_header(const char *name)
418 {
419  if (octx.print_object_header)
420  octx.print_object_header(name);
421 
422  probe_group_enter(name, OBJECT);
423 }
424 
425 static void probe_object_footer(const char *name)
426 {
428  if (octx.print_object_footer)
429  octx.print_object_footer(name);
430 }
431 
432 static void probe_int(const char *key, int64_t value)
433 {
434  octx.print_integer(key, value);
435  octx.prefix[octx.level -1].nb_elems++;
436 }
437 
438 static void probe_str(const char *key, const char *value)
439 {
440  octx.print_string(key, value);
441  octx.prefix[octx.level -1].nb_elems++;
442 }
443 
444 static void probe_dict(AVDictionary *dict, const char *name)
445 {
446  AVDictionaryEntry *entry = NULL;
447  if (!dict)
448  return;
449  probe_object_header(name);
450  while ((entry = av_dict_get(dict, "", entry, AV_DICT_IGNORE_SUFFIX))) {
451  probe_str(entry->key, entry->value);
452  }
453  probe_object_footer(name);
454 }
455 
456 static char *value_string(char *buf, int buf_size, double val, const char *unit)
457 {
459  double secs;
460  int hours, mins;
461  secs = val;
462  mins = (int)secs / 60;
463  secs = secs - mins * 60;
464  hours = mins / 60;
465  mins %= 60;
466  snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
467  } else if (use_value_prefix) {
468  const char *prefix_string;
469  int index;
470 
472  index = (int) log2(val) / 10;
473  index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) - 1);
474  val /= pow(2, index * 10);
475  prefix_string = binary_unit_prefixes[index];
476  } else {
477  index = (int) (log10(val)) / 3;
478  index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) - 1);
479  val /= pow(10, index * 3);
480  prefix_string = decimal_unit_prefixes[index];
481  }
482  snprintf(buf, buf_size, "%.*f%s%s",
483  index ? 3 : 0, val,
484  prefix_string,
485  show_value_unit ? unit : "");
486  } else {
487  snprintf(buf, buf_size, "%f%s", val, show_value_unit ? unit : "");
488  }
489 
490  return buf;
491 }
492 
493 static char *time_value_string(char *buf, int buf_size, int64_t val,
494  const AVRational *time_base)
495 {
496  if (val == AV_NOPTS_VALUE) {
497  snprintf(buf, buf_size, "N/A");
498  } else {
499  value_string(buf, buf_size, val * av_q2d(*time_base), unit_second_str);
500  }
501 
502  return buf;
503 }
504 
505 static char *ts_value_string(char *buf, int buf_size, int64_t ts)
506 {
507  if (ts == AV_NOPTS_VALUE) {
508  snprintf(buf, buf_size, "N/A");
509  } else {
510  snprintf(buf, buf_size, "%"PRId64, ts);
511  }
512 
513  return buf;
514 }
515 
516 static char *rational_string(char *buf, int buf_size, const char *sep,
517  const AVRational *rat)
518 {
519  snprintf(buf, buf_size, "%d%s%d", rat->num, sep, rat->den);
520  return buf;
521 }
522 
523 static char *tag_string(char *buf, int buf_size, int tag)
524 {
525  snprintf(buf, buf_size, "0x%04x", tag);
526  return buf;
527 }
528 
529 static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt)
530 {
531  char val_str[128];
532  AVStream *st = fmt_ctx->streams[pkt->stream_index];
533 
534  probe_object_header("packet");
535  probe_str("codec_type", media_type_string(st->codec->codec_type));
536  probe_int("stream_index", pkt->stream_index);
537  probe_str("pts", ts_value_string(val_str, sizeof(val_str), pkt->pts));
538  probe_str("pts_time", time_value_string(val_str, sizeof(val_str),
539  pkt->pts, &st->time_base));
540  probe_str("dts", ts_value_string(val_str, sizeof(val_str), pkt->dts));
541  probe_str("dts_time", time_value_string(val_str, sizeof(val_str),
542  pkt->dts, &st->time_base));
543  probe_str("duration", ts_value_string(val_str, sizeof(val_str),
544  pkt->duration));
545  probe_str("duration_time", time_value_string(val_str, sizeof(val_str),
546  pkt->duration,
547  &st->time_base));
548  probe_str("size", value_string(val_str, sizeof(val_str),
549  pkt->size, unit_byte_str));
550  probe_int("pos", pkt->pos);
551  probe_str("flags", pkt->flags & AV_PKT_FLAG_KEY ? "K" : "_");
552  probe_object_footer("packet");
553 }
554 
555 static void show_packets(AVFormatContext *fmt_ctx)
556 {
557  AVPacket pkt;
558 
559  av_init_packet(&pkt);
560  probe_array_header("packets");
561  while (!av_read_frame(fmt_ctx, &pkt))
562  show_packet(fmt_ctx, &pkt);
563  probe_array_footer("packets");
564 }
565 
566 static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
567 {
568  AVStream *stream = fmt_ctx->streams[stream_idx];
569  AVCodecContext *dec_ctx;
570  const AVCodec *dec;
571  const char *profile;
572  char val_str[128];
573  AVRational display_aspect_ratio, *sar = NULL;
574  const AVPixFmtDescriptor *desc;
575 
576  probe_object_header("stream");
577 
578  probe_int("index", stream->index);
579 
580  if ((dec_ctx = stream->codec)) {
581  if ((dec = dec_ctx->codec)) {
582  probe_str("codec_name", dec->name);
583  probe_str("codec_long_name", dec->long_name);
584  } else {
585  probe_str("codec_name", "unknown");
586  }
587 
588  probe_str("codec_type", media_type_string(dec_ctx->codec_type));
589  probe_str("codec_time_base",
590  rational_string(val_str, sizeof(val_str),
591  "/", &dec_ctx->time_base));
592 
593  /* print AVI/FourCC tag */
594  av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
595  probe_str("codec_tag_string", val_str);
596  probe_str("codec_tag", tag_string(val_str, sizeof(val_str),
597  dec_ctx->codec_tag));
598 
599  /* print profile, if there is one */
600  if (dec && (profile = av_get_profile_name(dec, dec_ctx->profile)))
601  probe_str("profile", profile);
602 
603  switch (dec_ctx->codec_type) {
604  case AVMEDIA_TYPE_VIDEO:
605  probe_int("width", dec_ctx->width);
606  probe_int("height", dec_ctx->height);
607  probe_int("has_b_frames", dec_ctx->has_b_frames);
608  if (dec_ctx->sample_aspect_ratio.num)
609  sar = &dec_ctx->sample_aspect_ratio;
610  else if (stream->sample_aspect_ratio.num)
611  sar = &stream->sample_aspect_ratio;
612 
613  if (sar) {
614  probe_str("sample_aspect_ratio",
615  rational_string(val_str, sizeof(val_str), ":", sar));
616  av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
617  dec_ctx->width * sar->num, dec_ctx->height * sar->den,
618  1024*1024);
619  probe_str("display_aspect_ratio",
620  rational_string(val_str, sizeof(val_str), ":",
621  &display_aspect_ratio));
622  }
623  desc = av_pix_fmt_desc_get(dec_ctx->pix_fmt);
624  probe_str("pix_fmt", desc ? desc->name : "unknown");
625  probe_int("level", dec_ctx->level);
626  break;
627 
628  case AVMEDIA_TYPE_AUDIO:
629  probe_str("sample_rate",
630  value_string(val_str, sizeof(val_str),
631  dec_ctx->sample_rate,
632  unit_hertz_str));
633  probe_int("channels", dec_ctx->channels);
634  probe_int("bits_per_sample",
635  av_get_bits_per_sample(dec_ctx->codec_id));
636  break;
637  }
638  } else {
639  probe_str("codec_type", "unknown");
640  }
641 
642  if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS)
643  probe_int("id", stream->id);
644  probe_str("avg_frame_rate",
645  rational_string(val_str, sizeof(val_str), "/",
646  &stream->avg_frame_rate));
647  if (dec_ctx->bit_rate)
648  probe_str("bit_rate",
649  value_string(val_str, sizeof(val_str),
650  dec_ctx->bit_rate, unit_bit_per_second_str));
651  probe_str("time_base",
652  rational_string(val_str, sizeof(val_str), "/",
653  &stream->time_base));
654  probe_str("start_time",
655  time_value_string(val_str, sizeof(val_str),
656  stream->start_time, &stream->time_base));
657  probe_str("duration",
658  time_value_string(val_str, sizeof(val_str),
659  stream->duration, &stream->time_base));
660  if (stream->nb_frames)
661  probe_int("nb_frames", stream->nb_frames);
662 
663  probe_dict(stream->metadata, "tags");
664 
665  probe_object_footer("stream");
666 }
667 
668 static void show_format(AVFormatContext *fmt_ctx)
669 {
670  char val_str[128];
671  int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
672 
673  probe_object_header("format");
674  probe_str("filename", fmt_ctx->filename);
675  probe_int("nb_streams", fmt_ctx->nb_streams);
676  probe_str("format_name", fmt_ctx->iformat->name);
677  probe_str("format_long_name", fmt_ctx->iformat->long_name);
678  probe_str("start_time",
679  time_value_string(val_str, sizeof(val_str),
680  fmt_ctx->start_time, &AV_TIME_BASE_Q));
681  probe_str("duration",
682  time_value_string(val_str, sizeof(val_str),
683  fmt_ctx->duration, &AV_TIME_BASE_Q));
684  probe_str("size",
685  size >= 0 ? value_string(val_str, sizeof(val_str),
686  size, unit_byte_str)
687  : "unknown");
688  probe_str("bit_rate",
689  value_string(val_str, sizeof(val_str),
690  fmt_ctx->bit_rate, unit_bit_per_second_str));
691 
692  probe_dict(fmt_ctx->metadata, "tags");
693 
694  probe_object_footer("format");
695 }
696 
697 static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
698 {
699  int err, i;
700  AVFormatContext *fmt_ctx = NULL;
702 
703  if ((err = avformat_open_input(&fmt_ctx, filename,
704  iformat, &format_opts)) < 0) {
705  print_error(filename, err);
706  return err;
707  }
709  av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
711  }
712 
713 
714  /* fill the streams in the format context */
715  if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
716  print_error(filename, err);
717  return err;
718  }
719 
720  av_dump_format(fmt_ctx, 0, filename, 0);
721 
722  /* bind a decoder to each input stream */
723  for (i = 0; i < fmt_ctx->nb_streams; i++) {
724  AVStream *stream = fmt_ctx->streams[i];
725  AVCodec *codec;
726 
727  if (stream->codec->codec_id == AV_CODEC_ID_PROBE) {
728  fprintf(stderr, "Failed to probe codec for input stream %d\n",
729  stream->index);
730  } else if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
731  fprintf(stderr,
732  "Unsupported codec with id %d for input stream %d\n",
733  stream->codec->codec_id, stream->index);
734  } else if (avcodec_open2(stream->codec, codec, NULL) < 0) {
735  fprintf(stderr, "Error while opening codec for input stream %d\n",
736  stream->index);
737  }
738  }
739 
740  *fmt_ctx_ptr = fmt_ctx;
741  return 0;
742 }
743 
744 static void close_input_file(AVFormatContext **ctx_ptr)
745 {
746  int i;
747  AVFormatContext *fmt_ctx = *ctx_ptr;
748 
749  /* close decoder for each stream */
750  for (i = 0; i < fmt_ctx->nb_streams; i++) {
751  AVStream *stream = fmt_ctx->streams[i];
752 
753  avcodec_close(stream->codec);
754  }
755  avformat_close_input(ctx_ptr);
756 }
757 
758 static int probe_file(const char *filename)
759 {
760  AVFormatContext *fmt_ctx;
761  int ret, i;
762 
763  if ((ret = open_input_file(&fmt_ctx, filename)))
764  return ret;
765 
766  if (do_show_format)
767  show_format(fmt_ctx);
768 
769  if (do_show_streams) {
770  probe_array_header("streams");
771  for (i = 0; i < fmt_ctx->nb_streams; i++)
772  show_stream(fmt_ctx, i);
773  probe_array_footer("streams");
774  }
775 
776  if (do_show_packets)
777  show_packets(fmt_ctx);
778 
779  close_input_file(&fmt_ctx);
780  return 0;
781 }
782 
783 static void show_usage(void)
784 {
785  printf("Simple multimedia streams analyzer\n");
786  printf("usage: %s [OPTIONS] [INPUT_FILE]\n", program_name);
787  printf("\n");
788 }
789 
790 static int opt_format(void *optctx, const char *opt, const char *arg)
791 {
792  iformat = av_find_input_format(arg);
793  if (!iformat) {
794  fprintf(stderr, "Unknown input format: %s\n", arg);
795  return AVERROR(EINVAL);
796  }
797  return 0;
798 }
799 
800 static int opt_output_format(void *optctx, const char *opt, const char *arg)
801 {
802 
803  if (!strcmp(arg, "json")) {
810 
813  } else if (!strcmp(arg, "ini")) {
818 
821  } else if (!strcmp(arg, "old")) {
822  octx.print_header = NULL;
825 
827  } else {
828  av_log(NULL, AV_LOG_ERROR, "Unsupported formatter %s\n", arg);
829  return AVERROR(EINVAL);
830  }
831  return 0;
832 }
833 
834 static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
835 {
836  do_show_format = 1;
838  octx.print_header = NULL;
839  octx.print_footer = NULL;
840  octx.print_array_header = NULL;
841  octx.print_array_footer = NULL;
842  octx.print_object_header = NULL;
843  octx.print_object_footer = NULL;
844 
847  av_dict_set(&fmt_entries_to_show, arg, "", 0);
848  return 0;
849 }
850 
851 static void opt_input_file(void *optctx, const char *arg)
852 {
853  if (input_filename) {
854  fprintf(stderr,
855  "Argument '%s' provided as input filename, but '%s' was already specified.\n",
856  arg, input_filename);
857  exit_program(1);
858  }
859  if (!strcmp(arg, "-"))
860  arg = "pipe:";
861  input_filename = arg;
862 }
863 
864 void show_help_default(const char *opt, const char *arg)
865 {
867  show_usage();
868  show_help_options(options, "Main options:", 0, 0, 0);
869  printf("\n");
871 }
872 
873 static int opt_pretty(void *optctx, const char *opt, const char *arg)
874 {
875  show_value_unit = 1;
876  use_value_prefix = 1;
879  return 0;
880 }
881 
882 static const OptionDef real_options[] = {
883 #include "cmdutils_common_opts.h"
884  { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
885  { "of", HAS_ARG, {.func_arg = opt_output_format}, "output the document either as ini or json", "output_format" },
886  { "unit", OPT_BOOL, {&show_value_unit},
887  "show unit of the displayed values" },
888  { "prefix", OPT_BOOL, {&use_value_prefix},
889  "use SI prefixes for the displayed values" },
890  { "byte_binary_prefix", OPT_BOOL, {&use_byte_value_binary_prefix},
891  "use binary prefixes for byte units" },
892  { "sexagesimal", OPT_BOOL, {&use_value_sexagesimal_format},
893  "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
894  { "pretty", 0, {.func_arg = opt_pretty},
895  "prettify the format of displayed values, make it more human readable" },
896  { "show_format", OPT_BOOL, {&do_show_format} , "show format/container info" },
897  { "show_format_entry", HAS_ARG, {.func_arg = opt_show_format_entry},
898  "show a particular entry from the format/container info", "entry" },
899  { "show_packets", OPT_BOOL, {&do_show_packets}, "show packets info" },
900  { "show_streams", OPT_BOOL, {&do_show_streams}, "show streams info" },
901  { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default},
902  "generic catch all option", "" },
903  { NULL, },
904 };
905 
906 static int probe_buf_write(void *opaque, uint8_t *buf, int buf_size)
907 {
908  printf("%.*s", buf_size, buf);
909  return 0;
910 }
911 
912 #define AVP_BUFFSIZE 4096
913 
914 int main(int argc, char **argv)
915 {
916  int ret;
918 
919  if (!buffer)
920  exit(1);
921 
923 
924  options = real_options;
925  parse_loglevel(argc, argv, options);
926  av_register_all();
928  init_opts();
929 #if CONFIG_AVDEVICE
931 #endif
932 
933  show_banner();
934 
937 
940 
943 
944  parse_options(NULL, argc, argv, options, opt_input_file);
945 
946  if (!input_filename) {
947  show_usage();
948  fprintf(stderr, "You have to specify one input file.\n");
949  fprintf(stderr,
950  "Use -h to get full help or, even better, run 'man %s'.\n",
951  program_name);
952  exit_program(1);
953  }
954 
955  probe_out = avio_alloc_context(buffer, AVP_BUFFSIZE, 1, NULL, NULL,
957  if (!probe_out)
958  exit_program(1);
959 
960  probe_header();
961  ret = probe_file(input_filename);
962  probe_footer();
963  avio_flush(probe_out);
964  avio_close(probe_out);
965 
967 
968  return ret;
969 }
void(* print_object_header)(const char *name)
Definition: avprobe.c:102
static void ini_print_integer(const char *key, int64_t value)
Definition: avprobe.c:189
codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it ...
Definition: avcodec.h:464
const struct AVCodec * codec
Definition: avcodec.h:1059
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:62
const char * name
Definition: avprobe.c:88
Bytestream IO Context.
Definition: avio.h:68
#define OPT_EXPERT
Definition: cmdutils.h:144
static char * time_value_string(char *buf, int buf_size, int64_t val, const AVRational *time_base)
Definition: avprobe.c:493
void(* print_object_footer)(const char *name)
Definition: avprobe.c:103
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:241
int size
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1599
static void probe_header(void)
Definition: avprobe.c:387
static void probe_footer(void)
Definition: avprobe.c:394
#define OPT_VIDEO
Definition: cmdutils.h:146
int64_t pos
byte position in stream, -1 if unknown
Definition: avcodec.h:998
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:247
static PrintContext octx
Definition: avprobe.c:110
void show_banner(void)
Print the program banner to stderr.
Definition: cmdutils.c:815
static void show_format_entry_string(const char *key, const char *value)
Definition: avprobe.c:351
static void probe_group_enter(const char *name, int type)
Definition: avprobe.c:360
#define OPT_AUDIO
Definition: cmdutils.h:147
static const char *const binary_unit_prefixes[]
Definition: avprobe.c:55
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:769
int num
numerator
Definition: rational.h:44
int index
stream index in AVFormatContext
Definition: avformat.h:700
int size
Definition: avcodec.h:974
static void probe_array_header(const char *name)
Definition: avprobe.c:402
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
Definition: avcodec.h:1429
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1254
static const char * input_filename
Definition: avprobe.c:52
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
Definition: alldevices.c:41
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
Definition: utils.c:1822
#define FF_ARRAY_ELEMS(a)
int level
Definition: avprobe.c:96
static void json_print_integer(const char *key, int64_t value)
Definition: avprobe.c:250
int profile
profile
Definition: avcodec.h:2622
AVCodec.
Definition: avcodec.h:2796
int64_t nb_elems
Definition: avprobe.c:91
void(* print_array_header)(const char *name)
Definition: avprobe.c:100
int64_t index
Definition: avprobe.c:90
static void json_print_array_footer(const char *name)
Definition: avprobe.c:226
static void probe_int(const char *key, int64_t value)
Definition: avprobe.c:432
#define log2(x)
Definition: libm.h:111
PrintElement * prefix
Definition: avprobe.c:95
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1175
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
#define AVFMT_SHOW_IDS
Show format stream IDs numbers.
Definition: avformat.h:411
Format I/O context.
Definition: avformat.h:922
Public dictionary API.
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
Definition: cmdutils.c:89
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Definition: cmdutils.c:82
uint8_t
static void ini_escape_print(const char *s)
Definition: avprobe.c:134
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions...
Definition: cmdutils.c:433
static char * ts_value_string(char *buf, int buf_size, int64_t ts)
Definition: avprobe.c:505
AVOptions.
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK.
Definition: avformat.h:539
#define HAS_ARG
Definition: cmdutils.h:142
static int opt_format(void *optctx, const char *opt, const char *arg)
Definition: avprobe.c:790
static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
Definition: avprobe.c:834
int id
Format-specific stream ID.
Definition: avformat.h:706
static const char *const decimal_unit_prefixes[]
Definition: avprobe.c:56
static void json_escape_print(const char *s)
Definition: avprobe.c:258
const char * name
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
Definition: cmdutils.c:63
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:990
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:69
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:38
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
Definition: cmdutils.c:333
uint32_t tag
Definition: movenc.c:844
int avformat_network_init(void)
Do global initialization of network components.
Definition: utils.c:2950
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:114
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
Definition: cmdutils.c:423
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
Definition: cmdutils.c:135
static void old_print_object_header(const char *name)
Definition: avprobe.c:297
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:991
static void show_usage(void)
Definition: avprobe.c:783
const char * name
Definition: pixdesc.h:70
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1019
AVDictionary * format_opts
Definition: cmdutils.c:59
static void probe_dict(AVDictionary *dict, const char *name)
Definition: avprobe.c:444
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Definition: dump.c:395
Main libavdevice API header.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
Definition: utils.c:1710
static void probe_str(const char *key, const char *value)
Definition: avprobe.c:438
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
Definition: aviobuf.c:107
static void json_print_object_footer(const char *name)
Definition: avprobe.c:243
static void ini_print_object_header(const char *name)
Definition: avprobe.c:166
static void json_print_array_header(const char *name)
Definition: avprobe.c:217
static const OptionDef real_options[]
Definition: avprobe.c:882
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1130
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:2043
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition: avcodec.h:1339
static int do_show_format
Definition: avprobe.c:37
#define AVERROR(e)
Definition: error.h:43
static AVDictionary * fmt_entries_to_show
Definition: avprobe.c:38
static int probe_buf_write(void *opaque, uint8_t *buf, int buf_size)
Definition: avprobe.c:906
static void show_format_entry_integer(const char *key, int64_t value)
Definition: avprobe.c:342
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: aviobuf.c:800
static char * tag_string(char *buf, int buf_size, int tag)
Definition: avprobe.c:523
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
Definition: dict.c:170
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:168
const char * name
Name of the codec implementation.
Definition: avcodec.h:2803
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:780
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:979
static int nb_fmt_entries_to_show
Definition: avprobe.c:39
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:718
static void show_packets(AVFormatContext *fmt_ctx)
Definition: avprobe.c:555
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:978
void(* print_header)(void)
Definition: avprobe.c:97
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:162
int bit_rate
the average bitrate
Definition: avcodec.h:1114
int void avio_flush(AVIOContext *s)
Definition: aviobuf.c:180
static int use_value_sexagesimal_format
Definition: avprobe.c:46
char filename[1024]
input or output filename
Definition: avformat.h:998
const char * media_type_string(enum AVMediaType media_type)
Get a string describing a media type.
Definition: cmdutils.c:1684
static void avprobe_cleanup(int ret)
Definition: avprobe.c:63
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
Definition: log.c:200
#define AVP_BUFFSIZE
Definition: avprobe.c:912
void show_help_default(const char *opt, const char *arg)
Per-avtool specific help handler.
Definition: avprobe.c:864
Definition: avprobe.c:84
int width
picture width / height.
Definition: avcodec.h:1224
void(* print_string)(const char *key, const char *value)
Definition: avprobe.c:106
static void probe_object_header(const char *name)
Definition: avprobe.c:417
int level
level
Definition: avcodec.h:2705
static char buffer[20]
Definition: seek-test.c:31
Definition: avprobe.c:83
static const char unit_byte_str[]
Definition: avprobe.c:60
AVDictionary * metadata
Definition: avformat.h:771
const int program_birth_year
program birth year, defined by the program for show_banner()
Definition: avprobe.c:35
void(* print_footer)(void)
Definition: avprobe.c:98
static void opt_input_file(void *optctx, const char *arg)
Definition: avprobe.c:851
static int opt_pretty(void *optctx, const char *opt, const char *arg)
Definition: avprobe.c:873
static char * value_string(char *buf, int buf_size, double val, const char *unit)
Definition: avprobe.c:456
static const OptionDef * options
Definition: avprobe.c:49
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
Definition: cmdutils.c:94
const char * long_name
Descriptive name for the format, meant to be more human-readable than name.
Definition: avformat.h:532
Stream structure.
Definition: avformat.h:699
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:1958
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:2962
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
Definition: avcodec.h:2808
NULL
Definition: eval.c:55
PrintElementType
Definition: avprobe.c:82
Libavcodec external API header.
enum AVMediaType codec_type
Definition: avcodec.h:1058
static const char unit_second_str[]
Definition: avprobe.c:58
enum AVCodecID codec_id
Definition: avcodec.h:1067
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:240
char * av_strdup(const char *s)
Duplicate the string s.
Definition: mem.c:213
int sample_rate
samples per second
Definition: avcodec.h:1791
AVIOContext * pb
I/O context.
Definition: avformat.h:964
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:144
main external API structure.
Definition: avcodec.h:1050
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: utils.c:1780
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
static void show_format(AVFormatContext *fmt_ctx)
Definition: avprobe.c:668
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1082
static int use_byte_value_binary_prefix
Definition: avprobe.c:45
static void json_print_string(const char *key, const char *value)
Definition: avprobe.c:282
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:68
Replacements for frequently missing libm functions.
static void old_print_string(const char *key, const char *value)
Definition: avprobe.c:331
static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
Definition: avprobe.c:697
static const char unit_bit_per_second_str[]
Definition: avprobe.c:61
int index
Definition: gxfenc.c:72
void(* print_integer)(const char *key, int64_t value)
Definition: avprobe.c:105
rational number numerator/denominator
Definition: rational.h:43
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:265
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: utils.c:982
static void ini_print_string(const char *key, const char *value)
Definition: avprobe.c:196
static void json_print_footer(void)
Definition: avprobe.c:212
static void ini_print_header(void)
Definition: avprobe.c:125
static void json_print_object_header(const char *name)
Definition: avprobe.c:233
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:989
int main(int argc, char **argv)
Definition: avprobe.c:914
static int probe_file(const char *filename)
Definition: avprobe.c:758
static AVIOContext * probe_out
Definition: avprobe.c:109
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
Definition: avformat.h:1007
static void probe_array_footer(const char *name)
Definition: avprobe.c:410
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:756
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:172
#define OPT_BOOL
Definition: cmdutils.h:143
static int opt_output_format(void *optctx, const char *opt, const char *arg)
Definition: avprobe.c:800
const char program_name[]
program name, defined by the program for show_version().
Definition: avprobe.c:34
Main libavformat public API header.
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
Definition: cmdutils.c:758
static int do_show_streams
Definition: avprobe.c:41
static void old_print_object_footer(const char *name)
Definition: avprobe.c:314
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
Definition: mem.c:117
static AVInputFormat * iformat
Definition: avprobe.c:53
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2052
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
Definition: avformat.h:749
static void probe_group_leave(void)
Definition: avprobe.c:382
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:47
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:758
char * key
Definition: dict.h:75
int den
denominator
Definition: rational.h:45
struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:934
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2499
void(* print_array_footer)(const char *name)
Definition: avprobe.c:101
static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt)
Definition: avprobe.c:529
#define AVP_INDENT()
Definition: avprobe.c:111
static void ini_print_footer(void)
Definition: avprobe.c:129
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:56
char * value
Definition: dict.h:76
static void json_print_header(void)
Definition: avprobe.c:208
static const char unit_hertz_str[]
Definition: avprobe.c:59
static int show_value_unit
Definition: avprobe.c:43
int channels
number of audio channels
Definition: avcodec.h:1792
PrintElementType type
Definition: avprobe.c:89
static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
Definition: avprobe.c:566
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
Definition: cmdutils.c:164
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:972
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1024
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1017
static void ini_print_array_header(const char *name)
Definition: avprobe.c:160
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:525
#define AV_DICT_IGNORE_SUFFIX
Definition: dict.h:62
static void close_input_file(AVFormatContext **ctx_ptr)
Definition: avprobe.c:744
static char * rational_string(char *buf, int buf_size, const char *sep, const AVRational *rat)
Definition: avprobe.c:516
static int do_show_packets
Definition: avprobe.c:40
int stream_index
Definition: avcodec.h:975
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:741
static int use_value_prefix
Definition: avprobe.c:44
static void probe_object_footer(const char *name)
Definition: avprobe.c:425
This structure stores compressed data.
Definition: avcodec.h:950
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:51
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:966
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:228
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2