]> git.sesse.net Git - ffmpeg/blob - libavformat/dump.c
Merge commit '01621202aad7e27b2a05c71d9ad7a19dfcbe17ec'
[ffmpeg] / libavformat / dump.c
1 /*
2  * Various pretty-printing functions for use within FFmpeg
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
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
22 #include <stdio.h>
23 #include <stdint.h>
24
25 #include "libavutil/channel_layout.h"
26 #include "libavutil/display.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/log.h"
29 #include "libavutil/mastering_display_metadata.h"
30 #include "libavutil/mathematics.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/avstring.h"
33 #include "libavutil/replaygain.h"
34 #include "libavutil/stereo3d.h"
35
36 #include "avformat.h"
37
38 #define HEXDUMP_PRINT(...)                                                    \
39     do {                                                                      \
40         if (!f)                                                               \
41             av_log(avcl, level, __VA_ARGS__);                                 \
42         else                                                                  \
43             fprintf(f, __VA_ARGS__);                                          \
44     } while (0)
45
46 static void hex_dump_internal(void *avcl, FILE *f, int level,
47                               const uint8_t *buf, int size)
48 {
49     int len, i, j, c;
50
51     for (i = 0; i < size; i += 16) {
52         len = size - i;
53         if (len > 16)
54             len = 16;
55         HEXDUMP_PRINT("%08x ", i);
56         for (j = 0; j < 16; j++) {
57             if (j < len)
58                 HEXDUMP_PRINT(" %02x", buf[i + j]);
59             else
60                 HEXDUMP_PRINT("   ");
61         }
62         HEXDUMP_PRINT(" ");
63         for (j = 0; j < len; j++) {
64             c = buf[i + j];
65             if (c < ' ' || c > '~')
66                 c = '.';
67             HEXDUMP_PRINT("%c", c);
68         }
69         HEXDUMP_PRINT("\n");
70     }
71 }
72
73 void av_hex_dump(FILE *f, const uint8_t *buf, int size)
74 {
75     hex_dump_internal(NULL, f, 0, buf, size);
76 }
77
78 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
79 {
80     hex_dump_internal(avcl, NULL, level, buf, size);
81 }
82
83 static void pkt_dump_internal(void *avcl, FILE *f, int level, const AVPacket *pkt,
84                               int dump_payload, AVRational time_base)
85 {
86     HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
87     HEXDUMP_PRINT("  keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
88     HEXDUMP_PRINT("  duration=%0.3f\n", pkt->duration * av_q2d(time_base));
89     /* DTS is _always_ valid after av_read_frame() */
90     HEXDUMP_PRINT("  dts=");
91     if (pkt->dts == AV_NOPTS_VALUE)
92         HEXDUMP_PRINT("N/A");
93     else
94         HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
95     /* PTS may not be known if B-frames are present. */
96     HEXDUMP_PRINT("  pts=");
97     if (pkt->pts == AV_NOPTS_VALUE)
98         HEXDUMP_PRINT("N/A");
99     else
100         HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
101     HEXDUMP_PRINT("\n");
102     HEXDUMP_PRINT("  size=%d\n", pkt->size);
103     if (dump_payload)
104         hex_dump_internal(avcl, f, level, pkt->data, pkt->size);
105 }
106
107 void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st)
108 {
109     pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
110 }
111
112 void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
113                       const AVStream *st)
114 {
115     pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
116 }
117
118
119 static void print_fps(double d, const char *postfix)
120 {
121     uint64_t v = lrintf(d * 100);
122     if (!v)
123         av_log(NULL, AV_LOG_INFO, "%1.4f %s", d, postfix);
124     else if (v % 100)
125         av_log(NULL, AV_LOG_INFO, "%3.2f %s", d, postfix);
126     else if (v % (100 * 1000))
127         av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
128     else
129         av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
130 }
131
132 static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
133 {
134     if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) {
135         AVDictionaryEntry *tag = NULL;
136
137         av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
138         while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX)))
139             if (strcmp("language", tag->key)) {
140                 const char *p = tag->value;
141                 av_log(ctx, AV_LOG_INFO,
142                        "%s  %-16s: ", indent, tag->key);
143                 while (*p) {
144                     char tmp[256];
145                     size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
146                     av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1));
147                     av_log(ctx, AV_LOG_INFO, "%s", tmp);
148                     p += len;
149                     if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");
150                     if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s  %-16s: ", indent, "");
151                     if (*p) p++;
152                 }
153                 av_log(ctx, AV_LOG_INFO, "\n");
154             }
155     }
156 }
157
158 /* param change side data*/
159 static void dump_paramchange(void *ctx, AVPacketSideData *sd)
160 {
161     int size = sd->size;
162     const uint8_t *data = sd->data;
163     uint32_t flags, channels, sample_rate, width, height;
164     uint64_t layout;
165
166     if (!data || sd->size < 4)
167         goto fail;
168
169     flags = AV_RL32(data);
170     data += 4;
171     size -= 4;
172
173     if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
174         if (size < 4)
175             goto fail;
176         channels = AV_RL32(data);
177         data += 4;
178         size -= 4;
179         av_log(ctx, AV_LOG_INFO, "channel count %"PRIu32", ", channels);
180     }
181     if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
182         if (size < 8)
183             goto fail;
184         layout = AV_RL64(data);
185         data += 8;
186         size -= 8;
187         av_log(ctx, AV_LOG_INFO,
188                "channel layout: %s, ", av_get_channel_name(layout));
189     }
190     if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
191         if (size < 4)
192             goto fail;
193         sample_rate = AV_RL32(data);
194         data += 4;
195         size -= 4;
196         av_log(ctx, AV_LOG_INFO, "sample_rate %"PRIu32", ", sample_rate);
197     }
198     if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
199         if (size < 8)
200             goto fail;
201         width = AV_RL32(data);
202         data += 4;
203         size -= 4;
204         height = AV_RL32(data);
205         data += 4;
206         size -= 4;
207         av_log(ctx, AV_LOG_INFO, "width %"PRIu32" height %"PRIu32, width, height);
208     }
209
210     return;
211 fail:
212     av_log(ctx, AV_LOG_INFO, "unknown param");
213 }
214
215 /* replaygain side data*/
216 static void print_gain(void *ctx, const char *str, int32_t gain)
217 {
218     av_log(ctx, AV_LOG_INFO, "%s - ", str);
219     if (gain == INT32_MIN)
220         av_log(ctx, AV_LOG_INFO, "unknown");
221     else
222         av_log(ctx, AV_LOG_INFO, "%f", gain / 100000.0f);
223     av_log(ctx, AV_LOG_INFO, ", ");
224 }
225
226 static void print_peak(void *ctx, const char *str, uint32_t peak)
227 {
228     av_log(ctx, AV_LOG_INFO, "%s - ", str);
229     if (!peak)
230         av_log(ctx, AV_LOG_INFO, "unknown");
231     else
232         av_log(ctx, AV_LOG_INFO, "%f", (float) peak / UINT32_MAX);
233     av_log(ctx, AV_LOG_INFO, ", ");
234 }
235
236 static void dump_replaygain(void *ctx, AVPacketSideData *sd)
237 {
238     AVReplayGain *rg;
239
240     if (sd->size < sizeof(*rg)) {
241         av_log(ctx, AV_LOG_INFO, "invalid data");
242         return;
243     }
244     rg = (AVReplayGain*)sd->data;
245
246     print_gain(ctx, "track gain", rg->track_gain);
247     print_peak(ctx, "track peak", rg->track_peak);
248     print_gain(ctx, "album gain", rg->album_gain);
249     print_peak(ctx, "album peak", rg->album_peak);
250 }
251
252 static void dump_stereo3d(void *ctx, AVPacketSideData *sd)
253 {
254     AVStereo3D *stereo;
255
256     if (sd->size < sizeof(*stereo)) {
257         av_log(ctx, AV_LOG_INFO, "invalid data");
258         return;
259     }
260
261     stereo = (AVStereo3D *)sd->data;
262
263     switch (stereo->type) {
264     case AV_STEREO3D_2D:
265         av_log(ctx, AV_LOG_INFO, "2D");
266         break;
267     case AV_STEREO3D_SIDEBYSIDE:
268         av_log(ctx, AV_LOG_INFO, "side by side");
269         break;
270     case AV_STEREO3D_TOPBOTTOM:
271         av_log(ctx, AV_LOG_INFO, "top and bottom");
272         break;
273     case AV_STEREO3D_FRAMESEQUENCE:
274         av_log(ctx, AV_LOG_INFO, "frame alternate");
275         break;
276     case AV_STEREO3D_CHECKERBOARD:
277         av_log(ctx, AV_LOG_INFO, "checkerboard");
278         break;
279     case AV_STEREO3D_LINES:
280         av_log(ctx, AV_LOG_INFO, "interleaved lines");
281         break;
282     case AV_STEREO3D_COLUMNS:
283         av_log(ctx, AV_LOG_INFO, "interleaved columns");
284         break;
285     case AV_STEREO3D_SIDEBYSIDE_QUINCUNX:
286         av_log(ctx, AV_LOG_INFO, "side by side (quincunx subsampling)");
287         break;
288     default:
289         av_log(ctx, AV_LOG_WARNING, "unknown");
290         break;
291     }
292
293     if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
294         av_log(ctx, AV_LOG_INFO, " (inverted)");
295 }
296
297 static void dump_audioservicetype(void *ctx, AVPacketSideData *sd)
298 {
299     enum AVAudioServiceType *ast = (enum AVAudioServiceType *)sd->data;
300
301     if (sd->size < sizeof(*ast)) {
302         av_log(ctx, AV_LOG_INFO, "invalid data");
303         return;
304     }
305
306     switch (*ast) {
307     case AV_AUDIO_SERVICE_TYPE_MAIN:
308         av_log(ctx, AV_LOG_INFO, "main");
309         break;
310     case AV_AUDIO_SERVICE_TYPE_EFFECTS:
311         av_log(ctx, AV_LOG_INFO, "effects");
312         break;
313     case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED:
314         av_log(ctx, AV_LOG_INFO, "visually impaired");
315         break;
316     case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:
317         av_log(ctx, AV_LOG_INFO, "hearing impaired");
318         break;
319     case AV_AUDIO_SERVICE_TYPE_DIALOGUE:
320         av_log(ctx, AV_LOG_INFO, "dialogue");
321         break;
322     case AV_AUDIO_SERVICE_TYPE_COMMENTARY:
323         av_log(ctx, AV_LOG_INFO, "comentary");
324         break;
325     case AV_AUDIO_SERVICE_TYPE_EMERGENCY:
326         av_log(ctx, AV_LOG_INFO, "emergency");
327         break;
328     case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:
329         av_log(ctx, AV_LOG_INFO, "voice over");
330         break;
331     case AV_AUDIO_SERVICE_TYPE_KARAOKE:
332         av_log(ctx, AV_LOG_INFO, "karaoke");
333         break;
334     default:
335         av_log(ctx, AV_LOG_WARNING, "unknown");
336         break;
337     }
338 }
339
340 static void dump_cpb(void *ctx, AVPacketSideData *sd)
341 {
342     AVCPBProperties *cpb = (AVCPBProperties *)sd->data;
343
344     if (sd->size < sizeof(*cpb)) {
345         av_log(ctx, AV_LOG_INFO, "invalid data");
346         return;
347     }
348
349     av_log(ctx, AV_LOG_INFO,
350            "bitrate max/min/avg: %d/%d/%d buffer size: %d vbv_delay: %"PRId64,
351            cpb->max_bitrate, cpb->min_bitrate, cpb->avg_bitrate,
352            cpb->buffer_size,
353            cpb->vbv_delay);
354 }
355
356 static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) {
357     AVMasteringDisplayMetadata* metadata = (AVMasteringDisplayMetadata*)sd->data;
358     av_log(ctx, AV_LOG_INFO, "Mastering Display Metadata, "
359            "has_primaries:%d has_luminance:%d "
360            "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
361            "min_luminance=%f, max_luminance=%f\n",
362            metadata->has_primaries, metadata->has_luminance,
363            av_q2d(metadata->display_primaries[0][0]),
364            av_q2d(metadata->display_primaries[0][1]),
365            av_q2d(metadata->display_primaries[1][0]),
366            av_q2d(metadata->display_primaries[1][1]),
367            av_q2d(metadata->display_primaries[2][0]),
368            av_q2d(metadata->display_primaries[2][1]),
369            av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]),
370            av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
371 }
372
373 static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
374 {
375     int i;
376
377     if (st->nb_side_data)
378         av_log(ctx, AV_LOG_INFO, "%sSide data:\n", indent);
379
380     for (i = 0; i < st->nb_side_data; i++) {
381         AVPacketSideData sd = st->side_data[i];
382         av_log(ctx, AV_LOG_INFO, "%s  ", indent);
383
384         switch (sd.type) {
385         case AV_PKT_DATA_PALETTE:
386             av_log(ctx, AV_LOG_INFO, "palette");
387             break;
388         case AV_PKT_DATA_NEW_EXTRADATA:
389             av_log(ctx, AV_LOG_INFO, "new extradata");
390             break;
391         case AV_PKT_DATA_PARAM_CHANGE:
392             av_log(ctx, AV_LOG_INFO, "paramchange: ");
393             dump_paramchange(ctx, &sd);
394             break;
395         case AV_PKT_DATA_H263_MB_INFO:
396             av_log(ctx, AV_LOG_INFO, "h263 macroblock info");
397             break;
398         case AV_PKT_DATA_REPLAYGAIN:
399             av_log(ctx, AV_LOG_INFO, "replaygain: ");
400             dump_replaygain(ctx, &sd);
401             break;
402         case AV_PKT_DATA_DISPLAYMATRIX:
403             av_log(ctx, AV_LOG_INFO, "displaymatrix: rotation of %.2f degrees",
404                    av_display_rotation_get((int32_t *)sd.data));
405             break;
406         case AV_PKT_DATA_STEREO3D:
407             av_log(ctx, AV_LOG_INFO, "stereo3d: ");
408             dump_stereo3d(ctx, &sd);
409             break;
410         case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
411             av_log(ctx, AV_LOG_INFO, "audio service type: ");
412             dump_audioservicetype(ctx, &sd);
413             break;
414         case AV_PKT_DATA_QUALITY_STATS:
415             av_log(ctx, AV_LOG_INFO, "quality factor: %d, pict_type: %c", AV_RL32(sd.data), av_get_picture_type_char(sd.data[4]));
416             break;
417         case AV_PKT_DATA_CPB_PROPERTIES:
418             av_log(ctx, AV_LOG_INFO, "cpb: ");
419             dump_cpb(ctx, &sd);
420             break;
421         case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
422             dump_mastering_display_metadata(ctx, &sd);
423             break;
424         default:
425             av_log(ctx, AV_LOG_WARNING,
426                    "unknown side data type %d (%d bytes)", sd.type, sd.size);
427             break;
428         }
429
430         av_log(ctx, AV_LOG_INFO, "\n");
431     }
432 }
433
434 /* "user interface" functions */
435 static void dump_stream_format(AVFormatContext *ic, int i,
436                                int index, int is_output)
437 {
438     char buf[256];
439     int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
440     AVStream *st = ic->streams[i];
441     AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
442     char *separator = ic->dump_separator;
443     AVCodecContext *avctx;
444     int ret;
445
446     avctx = avcodec_alloc_context3(NULL);
447     if (!avctx)
448         return;
449
450     ret = avcodec_parameters_to_context(avctx, st->codecpar);
451     if (ret < 0) {
452         avcodec_free_context(&avctx);
453         return;
454     }
455
456     if (separator)
457         av_opt_set(avctx, "dump_separator", separator, 0);
458     avcodec_string(buf, sizeof(buf), avctx, is_output);
459     avcodec_free_context(&avctx);
460
461     av_log(NULL, AV_LOG_INFO, "    Stream #%d:%d", index, i);
462
463     /* the pid is an important information, so we display it */
464     /* XXX: add a generic system */
465     if (flags & AVFMT_SHOW_IDS)
466         av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
467     if (lang)
468         av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
469     av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames,
470            st->time_base.num, st->time_base.den);
471     av_log(NULL, AV_LOG_INFO, ": %s", buf);
472
473     if (st->sample_aspect_ratio.num &&
474         av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
475         AVRational display_aspect_ratio;
476         av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
477                   st->codecpar->width  * (int64_t)st->sample_aspect_ratio.num,
478                   st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
479                   1024 * 1024);
480         av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d",
481                st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
482                display_aspect_ratio.num, display_aspect_ratio.den);
483     }
484
485     if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
486         int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
487         int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
488         int tbn = st->time_base.den && st->time_base.num;
489
490         if (fps || tbr || tbn)
491             av_log(NULL, AV_LOG_INFO, "%s", separator);
492
493         if (fps)
494             print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps");
495         if (tbr)
496             print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr");
497         if (tbn)
498             print_fps(1 / av_q2d(st->time_base), "tbn");
499     }
500
501     if (st->disposition & AV_DISPOSITION_DEFAULT)
502         av_log(NULL, AV_LOG_INFO, " (default)");
503     if (st->disposition & AV_DISPOSITION_DUB)
504         av_log(NULL, AV_LOG_INFO, " (dub)");
505     if (st->disposition & AV_DISPOSITION_ORIGINAL)
506         av_log(NULL, AV_LOG_INFO, " (original)");
507     if (st->disposition & AV_DISPOSITION_COMMENT)
508         av_log(NULL, AV_LOG_INFO, " (comment)");
509     if (st->disposition & AV_DISPOSITION_LYRICS)
510         av_log(NULL, AV_LOG_INFO, " (lyrics)");
511     if (st->disposition & AV_DISPOSITION_KARAOKE)
512         av_log(NULL, AV_LOG_INFO, " (karaoke)");
513     if (st->disposition & AV_DISPOSITION_FORCED)
514         av_log(NULL, AV_LOG_INFO, " (forced)");
515     if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
516         av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
517     if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
518         av_log(NULL, AV_LOG_INFO, " (visual impaired)");
519     if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
520         av_log(NULL, AV_LOG_INFO, " (clean effects)");
521     av_log(NULL, AV_LOG_INFO, "\n");
522
523     dump_metadata(NULL, st->metadata, "    ");
524
525     dump_sidedata(NULL, st, "    ");
526 }
527
528 void av_dump_format(AVFormatContext *ic, int index,
529                     const char *url, int is_output)
530 {
531     int i;
532     uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
533     if (ic->nb_streams && !printed)
534         return;
535
536     av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
537            is_output ? "Output" : "Input",
538            index,
539            is_output ? ic->oformat->name : ic->iformat->name,
540            is_output ? "to" : "from", url);
541     dump_metadata(NULL, ic->metadata, "  ");
542
543     if (!is_output) {
544         av_log(NULL, AV_LOG_INFO, "  Duration: ");
545         if (ic->duration != AV_NOPTS_VALUE) {
546             int hours, mins, secs, us;
547             int64_t duration = ic->duration + (ic->duration <= INT64_MAX - 5000 ? 5000 : 0);
548             secs  = duration / AV_TIME_BASE;
549             us    = duration % AV_TIME_BASE;
550             mins  = secs / 60;
551             secs %= 60;
552             hours = mins / 60;
553             mins %= 60;
554             av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
555                    (100 * us) / AV_TIME_BASE);
556         } else {
557             av_log(NULL, AV_LOG_INFO, "N/A");
558         }
559         if (ic->start_time != AV_NOPTS_VALUE) {
560             int secs, us;
561             av_log(NULL, AV_LOG_INFO, ", start: ");
562             secs = llabs(ic->start_time / AV_TIME_BASE);
563             us   = llabs(ic->start_time % AV_TIME_BASE);
564             av_log(NULL, AV_LOG_INFO, "%s%d.%06d",
565                    ic->start_time >= 0 ? "" : "-",
566                    secs,
567                    (int) av_rescale(us, 1000000, AV_TIME_BASE));
568         }
569         av_log(NULL, AV_LOG_INFO, ", bitrate: ");
570         if (ic->bit_rate)
571             av_log(NULL, AV_LOG_INFO, "%"PRId64" kb/s", (int64_t)ic->bit_rate / 1000);
572         else
573             av_log(NULL, AV_LOG_INFO, "N/A");
574         av_log(NULL, AV_LOG_INFO, "\n");
575     }
576
577     for (i = 0; i < ic->nb_chapters; i++) {
578         AVChapter *ch = ic->chapters[i];
579         av_log(NULL, AV_LOG_INFO, "    Chapter #%d:%d: ", index, i);
580         av_log(NULL, AV_LOG_INFO,
581                "start %f, ", ch->start * av_q2d(ch->time_base));
582         av_log(NULL, AV_LOG_INFO,
583                "end %f\n", ch->end * av_q2d(ch->time_base));
584
585         dump_metadata(NULL, ch->metadata, "    ");
586     }
587
588     if (ic->nb_programs) {
589         int j, k, total = 0;
590         for (j = 0; j < ic->nb_programs; j++) {
591             AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
592                                                   "name", NULL, 0);
593             av_log(NULL, AV_LOG_INFO, "  Program %d %s\n", ic->programs[j]->id,
594                    name ? name->value : "");
595             dump_metadata(NULL, ic->programs[j]->metadata, "    ");
596             for (k = 0; k < ic->programs[j]->nb_stream_indexes; k++) {
597                 dump_stream_format(ic, ic->programs[j]->stream_index[k],
598                                    index, is_output);
599                 printed[ic->programs[j]->stream_index[k]] = 1;
600             }
601             total += ic->programs[j]->nb_stream_indexes;
602         }
603         if (total < ic->nb_streams)
604             av_log(NULL, AV_LOG_INFO, "  No Program\n");
605     }
606
607     for (i = 0; i < ic->nb_streams; i++)
608         if (!printed[i])
609             dump_stream_format(ic, i, index, is_output);
610
611     av_free(printed);
612 }