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.

622 lines
21KB

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