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