-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathmp4info.cpp
625 lines (562 loc) · 19.9 KB
/
mp4info.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is MPEG4IP.
*
* The Initial Developer of the Original Code is Cisco Systems Inc.
* Portions created by Cisco Systems Inc. are
* Copyright (C) Cisco Systems Inc. 2001-2002. All Rights Reserved.
*
* Portions created by Ximpo Group Ltd. are
* Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved.
*
* Contributor(s):
* Dave Mackie [email protected]
* Bill May [email protected]
* Alix Marchandise-Franquet [email protected]
* Ximpo Group Ltd. [email protected]
*/
#include "src/impl.h"
namespace mp4v2 { namespace impl {
///////////////////////////////////////////////////////////////////////////////
static char* PrintAudioInfo(
MP4FileHandle mp4File,
MP4TrackId trackId)
{
static const char* mpeg4AudioNames[] = {
"MPEG-4 AAC main",
"MPEG-4 AAC LC",
"MPEG-4 AAC SSR",
"MPEG-4 AAC LTP",
"MPEG-4 AAC HE",
"MPEG-4 AAC Scalable",
"MPEG-4 TwinVQ",
"MPEG-4 CELP",
"MPEG-4 HVXC",
NULL, NULL,
"MPEG-4 TTSI",
"MPEG-4 Main Synthetic",
"MPEG-4 Wavetable Syn",
"MPEG-4 General MIDI",
"MPEG-4 Algo Syn and Audio FX",
"MPEG-4 ER AAC LC",
NULL,
"MPEG-4 ER AAC LTP",
"MPEG-4 ER AAC Scalable",
"MPEG-4 ER TwinVQ",
"MPEG-4 ER BSAC",
"MPEG-4 ER ACC LD",
"MPEG-4 ER CELP",
"MPEG-4 ER HVXC",
"MPEG-4 ER HILN",
"MPEG-4 ER Parametric",
"MPEG-4 SSC",
"MPEG-4 PS",
"MPEG-4 MPEG Surround",
NULL,
"MPEG-4 Layer-1",
"MPEG-4 Layer-2",
"MPEG-4 Layer-3",
"MPEG-4 DST",
"MPEG-4 Audio Lossless",
"MPEG-4 SLS",
"MPEG-4 SLS non-core",
};
static const uint8_t mpegAudioTypes[] = {
MP4_MPEG2_AAC_MAIN_AUDIO_TYPE, // 0x66
MP4_MPEG2_AAC_LC_AUDIO_TYPE, // 0x67
MP4_MPEG2_AAC_SSR_AUDIO_TYPE, // 0x68
MP4_MPEG2_AUDIO_TYPE, // 0x69
MP4_MPEG1_AUDIO_TYPE, // 0x6B
// private types
MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE,
MP4_VORBIS_AUDIO_TYPE,
MP4_ALAW_AUDIO_TYPE,
MP4_ULAW_AUDIO_TYPE,
MP4_G723_AUDIO_TYPE,
MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE,
};
static const char* mpegAudioNames[] = {
"MPEG-2 AAC Main",
"MPEG-2 AAC LC",
"MPEG-2 AAC SSR",
"MPEG-2 Audio (13818-3)",
"MPEG-1 Audio (11172-3)",
// private types
"PCM16 (little endian)",
"Vorbis",
"G.711 aLaw",
"G.711 uLaw",
"G.723.1",
"PCM16 (big endian)",
};
uint8_t numMpegAudioTypes =
sizeof(mpegAudioTypes) / sizeof(uint8_t);
const char* typeName = "Unknown";
bool foundType = false;
uint8_t type = 0;
const char *media_data_name = NULL;
media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);
if (media_data_name == NULL) {
typeName = "Unknown - no media data name";
} else if (strcasecmp(media_data_name, "samr") == 0) {
typeName = "AMR";
foundType = true;
} else if (strcasecmp(media_data_name, "sawb") == 0) {
typeName = "AMR-WB";
foundType = true;
} else if (strcasecmp(media_data_name, "mp4a") == 0) {
type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId);
switch (type) {
case MP4_INVALID_AUDIO_TYPE:
typeName = "AAC from .mov";
foundType = true;
break;
case MP4_MPEG4_AUDIO_TYPE: {
type = MP4GetTrackAudioMpeg4Type(mp4File, trackId);
if (type == MP4_MPEG4_INVALID_AUDIO_TYPE ||
type > NUM_ELEMENTS_IN_ARRAY(mpeg4AudioNames) ||
mpeg4AudioNames[type - 1] == NULL) {
typeName = "MPEG-4 Unknown Profile";
} else {
typeName = mpeg4AudioNames[type - 1];
foundType = true;
}
break;
}
// fall through
default:
for (uint8_t i = 0; i < numMpegAudioTypes; i++) {
if (type == mpegAudioTypes[i]) {
typeName = mpegAudioNames[i];
foundType = true;
break;
}
}
}
} else {
typeName = media_data_name;
foundType = true;
}
uint32_t timeScale =
MP4GetTrackTimeScale(mp4File, trackId);
MP4Duration trackDuration =
MP4GetTrackDuration(mp4File, trackId);
double msDuration =
double(MP4ConvertFromTrackDuration(mp4File, trackId,
trackDuration, MP4_MSECS_TIME_SCALE));
uint32_t avgBitRate =
MP4GetTrackBitRate(mp4File, trackId);
char *sInfo = (char*)MP4Malloc(256);
// type duration avgBitrate samplingFrequency
if (foundType)
snprintf(sInfo, 256,
"%u\taudio\t%s%s, %.3f secs, %u kbps, %u Hz\n",
trackId,
MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "",
typeName,
msDuration / 1000.0,
(avgBitRate + 500) / 1000,
timeScale);
else
snprintf(sInfo, 256,
"%u\taudio\t%s%s(%u), %.3f secs, %u kbps, %u Hz\n",
trackId,
MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "enca - " : "",
typeName,
type,
msDuration / 1000.0,
(avgBitRate + 500) / 1000,
timeScale);
return sInfo;
}
static const struct {
uint8_t profile;
const char *name;
} VisualProfileToName[] = {
{ MPEG4_SP_L1, "MPEG-4 Simple @ L1"},
{ MPEG4_SP_L2, "MPEG-4 Simple @ L2" },
{ MPEG4_SP_L3, "MPEG-4 Simple @ L3" },
{ MPEG4_SP_L0, "MPEG-4 Simple @ L0" },
{ MPEG4_SSP_L1, "MPEG-4 Simple Scalable @ L1"},
{ MPEG4_SSP_L2, "MPEG-4 Simple Scalable @ L2" },
{ MPEG4_CP_L1, "MPEG-4 Core @ L1"},
{ MPEG4_CP_L2, "MPEG-4 Core @ L2"},
{ MPEG4_MP_L2, "MPEG-4 Main @ L2"},
{ MPEG4_MP_L3, "MPEG-4 Main @ L3"},
{ MPEG4_MP_L4, "MPEG-4 Main @ L4"},
{ MPEG4_NBP_L2, "MPEG-4 N-bit @ L2"},
{ MPEG4_STP_L1, "MPEG-4 Scalable Texture @ L1"},
{ MPEG4_SFAP_L1, "MPEG-4 Simple Face Anim @ L1"},
{ MPEG4_SFAP_L2, "MPEG-4 Simple Face Anim @ L2"},
{ MPEG4_SFBAP_L1, "MPEG-4 Simple FBA @ L1"},
{ MPEG4_SFBAP_L2, "MPEG-4 Simple FBA @ L2"},
{ MPEG4_BATP_L1, "MPEG-4 Basic Anim Text @ L1"},
{ MPEG4_BATP_L2, "MPEG-4 Basic Anim Text @ L2"},
{ MPEG4_HP_L1, "MPEG-4 Hybrid @ L1"},
{ MPEG4_HP_L2, "MPEG-4 Hybrid @ L2"},
{ MPEG4_ARTSP_L1, "MPEG-4 Adv RT Simple @ L1"},
{ MPEG4_ARTSP_L2, "MPEG-4 Adv RT Simple @ L2"},
{ MPEG4_ARTSP_L3, "MPEG-4 Adv RT Simple @ L3"},
{ MPEG4_ARTSP_L4, "MPEG-4 Adv RT Simple @ L4"},
{ MPEG4_CSP_L1, "MPEG-4 Core Scalable @ L1"},
{ MPEG4_CSP_L2, "MPEG-4 Core Scalable @ L2"},
{ MPEG4_CSP_L3, "MPEG-4 Core Scalable @ L3"},
{ MPEG4_ACEP_L1, "MPEG-4 Adv Coding Efficieny @ L1"},
{ MPEG4_ACEP_L2, "MPEG-4 Adv Coding Efficieny @ L2"},
{ MPEG4_ACEP_L3, "MPEG-4 Adv Coding Efficieny @ L3"},
{ MPEG4_ACEP_L4, "MPEG-4 Adv Coding Efficieny @ L4"},
{ MPEG4_ACP_L1, "MPEG-4 Adv Core Profile @ L1"},
{ MPEG4_ACP_L2, "MPEG-4 Adv Core Profile @ L2"},
{ MPEG4_AST_L1, "MPEG-4 Adv Scalable Texture @ L1"},
{ MPEG4_AST_L2, "MPEG-4 Adv Scalable Texture @ L2"},
{ MPEG4_AST_L3, "MPEG-4 Adv Scalable Texture @ L3"},
{ MPEG4_S_STUDIO_P_L1, "MPEG-4 Simple Studio @ L1"},
{ MPEG4_S_STUDIO_P_L2, "MPEG-4 Simple Studio @ L2"},
{ MPEG4_S_STUDIO_P_L3, "MPEG-4 Simple Studio @ L3"},
{ MPEG4_S_STUDIO_P_L4, "MPEG-4 Simple Studio @ L4"},
{ MPEG4_C_STUDIO_P_L1, "MPEG-4 Core Studio @ L1"},
{ MPEG4_C_STUDIO_P_L2, "MPEG-4 Core Studio @ L2"},
{ MPEG4_C_STUDIO_P_L3, "MPEG-4 Core Studio @ L3"},
{ MPEG4_C_STUDIO_P_L4, "MPEG-4 Core Studio @ L4"},
{ MPEG4_ASP_L0, "MPEG-4 Adv Simple@L0"},
{ MPEG4_ASP_L1, "MPEG-4 Adv Simple@L1"},
{ MPEG4_ASP_L2, "MPEG-4 Adv Simple@L2"},
{ MPEG4_ASP_L3, "MPEG-4 Adv Simple@L3"},
{ MPEG4_ASP_L4, "MPEG-4 Adv Simple@L4"},
{ MPEG4_ASP_L5, "MPEG-4 Adv Simple@L5"},
{ MPEG4_ASP_L3B, "MPEG-4 Adv Simple@L3b"},
{ MPEG4_FGSP_L0, "MPEG-4 FGS @ L0" },
{ MPEG4_FGSP_L1, "MPEG-4 FGS @ L1" },
{ MPEG4_FGSP_L2, "MPEG-4 FGS @ L2" },
{ MPEG4_FGSP_L3, "MPEG-4 FGS @ L3" },
{ MPEG4_FGSP_L4, "MPEG-4 FGS @ L4" },
{ MPEG4_FGSP_L5, "MPEG-4 FGS @ L5" }
};
static const char *Mpeg4VisualProfileName (uint8_t visual_profile)
{
size_t size = sizeof(VisualProfileToName) / sizeof(*VisualProfileToName);
for (size_t ix = 0; ix < size; ix++) {
if (visual_profile == VisualProfileToName[ix].profile) {
return (VisualProfileToName[ix].name);
}
}
return (NULL);
}
static char* PrintVideoInfo(
MP4FileHandle mp4File,
MP4TrackId trackId)
{
static const uint8_t mpegVideoTypes[] = {
MP4_MPEG2_SIMPLE_VIDEO_TYPE, // 0x60
MP4_MPEG2_MAIN_VIDEO_TYPE, // 0x61
MP4_MPEG2_SNR_VIDEO_TYPE, // 0x62
MP4_MPEG2_SPATIAL_VIDEO_TYPE, // 0x63
MP4_MPEG2_HIGH_VIDEO_TYPE, // 0x64
MP4_MPEG2_442_VIDEO_TYPE, // 0x65
MP4_MPEG1_VIDEO_TYPE, // 0x6A
MP4_JPEG_VIDEO_TYPE, // 0x6C
MP4_YUV12_VIDEO_TYPE,
MP4_H263_VIDEO_TYPE,
MP4_H261_VIDEO_TYPE,
};
static const char* mpegVideoNames[] = {
"MPEG-2 Simple",
"MPEG-2 Main",
"MPEG-2 SNR",
"MPEG-2 Spatial",
"MPEG-2 High",
"MPEG-2 4:2:2",
"MPEG-1",
"JPEG",
"YUV12",
"H.263",
"H.261",
};
uint8_t numMpegVideoTypes =
sizeof(mpegVideoTypes) / sizeof(uint8_t);
bool foundTypeName = false;
const char* typeName = "Unknown";
const char *media_data_name = NULL;
char originalFormat[8];
char oformatbuffer[32];
originalFormat[0] = 0;
*oformatbuffer = 0;
uint8_t type = 0;
media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);
// encv 264b
if (media_data_name != NULL && strcasecmp(media_data_name, "encv") == 0) {
if (MP4GetTrackMediaDataOriginalFormat(mp4File,
trackId,
originalFormat,
sizeof(originalFormat)) == false)
media_data_name = NULL;
}
char typebuffer[80];
if (media_data_name == NULL) {
typeName = "Unknown - no media data name";
foundTypeName = true;
} else if ((strcasecmp(media_data_name, "avc1") == 0) ||
(strcasecmp(originalFormat, "264b") == 0)) {
// avc
uint8_t profile, level;
char profileb[20], levelb[20];
if (MP4GetTrackH264ProfileLevel(mp4File, trackId,
&profile, &level)) {
if (profile == 66) {
strcpy(profileb, "Baseline");
} else if (profile == 77) {
strcpy(profileb, "Main");
} else if (profile == 88) {
strcpy(profileb, "Extended");
} else if (profile == 100) {
strcpy(profileb, "High");
} else if (profile == 110) {
strcpy(profileb, "High 10");
} else if (profile == 122) {
strcpy(profileb, "High 4:2:2");
} else if (profile == 144) {
strcpy(profileb, "High 4:4:4");
} else {
snprintf(profileb, 20, "Unknown Profile %x", profile);
}
switch (level) {
case 10:
case 20:
case 30:
case 40:
case 50:
snprintf(levelb, 20, "%u", level / 10);
break;
case 11:
case 12:
case 13:
case 21:
case 22:
case 31:
case 32:
case 41:
case 42:
case 51:
snprintf(levelb, 20, "%u.%u", level / 10, level % 10);
break;
default:
snprintf(levelb, 20, "unknown level %x", level);
break;
}
if (originalFormat != NULL && originalFormat[0] != '\0')
snprintf(oformatbuffer, 32, "(%s) ", originalFormat);
snprintf(typebuffer, sizeof(typebuffer), "H264 %s%s@%s",
oformatbuffer, profileb, levelb);
typeName = typebuffer;
} else {
typeName = "H.264 - profile/level error";
}
foundTypeName = true;
} else if (strcasecmp(media_data_name, "s263") == 0) {
// 3gp h.263
typeName = "H.263";
foundTypeName = true;
} else if ((strcasecmp(media_data_name, "mp4v") == 0) ||
(strcasecmp(media_data_name, "encv") == 0)) {
// note encv might needs it's own field eventually.
type = MP4GetTrackEsdsObjectTypeId(mp4File, trackId);
if (type == MP4_MPEG4_VIDEO_TYPE) {
type = MP4GetVideoProfileLevel(mp4File, trackId);
typeName = Mpeg4VisualProfileName(type);
if (typeName == NULL) {
typeName = "MPEG-4 Unknown Profile";
} else {
foundTypeName = true;
}
} else {
for (uint8_t i = 0; i < numMpegVideoTypes; i++) {
if (type == mpegVideoTypes[i]) {
typeName = mpegVideoNames[i];
foundTypeName = true;
break;
}
}
}
} else {
typeName = media_data_name;
foundTypeName = true; // we don't have a type value to display
}
MP4Duration trackDuration =
MP4GetTrackDuration(mp4File, trackId);
double msDuration =
double(MP4ConvertFromTrackDuration(mp4File, trackId,
trackDuration, MP4_MSECS_TIME_SCALE));
uint32_t avgBitRate =
MP4GetTrackBitRate(mp4File, trackId);
// Note not all mp4 implementations set width and height correctly
// The real answer can be buried inside the ES configuration info
uint16_t width = MP4GetTrackVideoWidth(mp4File, trackId);
uint16_t height = MP4GetTrackVideoHeight(mp4File, trackId);
double fps = MP4GetTrackVideoFrameRate(mp4File, trackId);
char *sInfo = (char*)MP4Malloc(256);
// type duration avgBitrate frameSize frameRate
if (foundTypeName) {
sprintf(sInfo,
"%u\tvideo\t%s%s, %.3f secs, %u kbps, %ux%u @ %f fps\n",
trackId,
MP4IsIsmaCrypMediaTrack(mp4File, trackId) ? "encv - " : "",
typeName,
msDuration / 1000.0,
(avgBitRate + 500) / 1000,
width,
height,
fps
);
} else {
sprintf(sInfo,
"%u\tvideo\t%s(%u), %.3f secs, %u kbps, %ux%u @ %f fps\n",
trackId,
typeName,
type,
msDuration / 1000.0,
(avgBitRate + 500) / 1000,
width,
height,
fps
);
}
return sInfo;
}
static char* PrintCntlInfo(
MP4FileHandle mp4File,
MP4TrackId trackId)
{
const char *media_data_name = MP4GetTrackMediaDataName(mp4File, trackId);
const char *typeName = "Unknown";
if (media_data_name == NULL) {
typeName = "Unknown - no media data name";
} else if (strcasecmp(media_data_name, "href") == 0) {
typeName = "ISMA Href";
} else {
typeName = media_data_name;
}
MP4Duration trackDuration =
MP4GetTrackDuration(mp4File, trackId);
double msDuration =
double(MP4ConvertFromTrackDuration(mp4File, trackId,
trackDuration, MP4_MSECS_TIME_SCALE));
char *sInfo = (char *)MP4Malloc(256);
snprintf(sInfo, 256,
"%u\tcontrol\t%s, %.3f secs\n",
trackId,
typeName,
msDuration / 1000.0);
return sInfo;
}
static char* PrintHintInfo(
MP4FileHandle mp4File,
MP4TrackId trackId)
{
MP4TrackId referenceTrackId =
MP4GetHintTrackReferenceTrackId(mp4File, trackId);
char* payloadName = NULL;
if (!MP4GetHintTrackRtpPayload(mp4File, trackId, &payloadName))
return NULL;
char *sInfo = (char*)MP4Malloc(256);
snprintf(sInfo, 256,
"%u\thint\tPayload %s for track %u\n",
trackId,
payloadName,
referenceTrackId);
free(payloadName);
return sInfo;
}
static char* PrintTrackInfo(
MP4FileHandle mp4File,
MP4TrackId trackId)
{
char* trackInfo = NULL;
const char* trackType =
MP4GetTrackType(mp4File, trackId);
if (trackType == NULL) return NULL;
if (!strcmp(trackType, MP4_AUDIO_TRACK_TYPE)) {
trackInfo = PrintAudioInfo(mp4File, trackId);
} else if (!strcmp(trackType, MP4_VIDEO_TRACK_TYPE)) {
trackInfo = PrintVideoInfo(mp4File, trackId);
} else if (!strcmp(trackType, MP4_HINT_TRACK_TYPE)) {
trackInfo = PrintHintInfo(mp4File, trackId);
} else if (strcmp(trackType, MP4_CNTL_TRACK_TYPE) == 0) {
trackInfo = PrintCntlInfo(mp4File, trackId);
} else {
trackInfo = (char*)MP4Malloc(256);
if (!strcmp(trackType, MP4_OD_TRACK_TYPE)) {
snprintf(trackInfo, 256,
"%u\tod\tObject Descriptors\n",
trackId);
} else if (!strcmp(trackType, MP4_SCENE_TRACK_TYPE)) {
snprintf(trackInfo, 256,
"%u\tscene\tBIFS\n",
trackId);
} else {
snprintf(trackInfo, 256,
"%u\t%s\n",
trackId, trackType);
}
}
return trackInfo;
}
///////////////////////////////////////////////////////////////////////////////
}} // namespace mp4v2::impl
///////////////////////////////////////////////////////////////////////////////
using namespace mp4v2::impl;
extern "C"
char* MP4Info(
MP4FileHandle mp4File,
MP4TrackId trackId )
{
char* info = NULL;
if (MP4_IS_VALID_FILE_HANDLE(mp4File)) {
try {
if (trackId == MP4_INVALID_TRACK_ID) {
uint32_t buflen = 4 * 1024;
info = (char*)MP4Calloc(buflen);
buflen -= snprintf(info, buflen,
"Track\tType\tInfo\n");
uint32_t numTracks = MP4GetNumberOfTracks(mp4File);
for (uint32_t i = 0; i < numTracks; i++) {
trackId = MP4FindTrackId(mp4File, i);
char* trackInfo = PrintTrackInfo(mp4File, trackId);
strncat(info, trackInfo, buflen);
uint32_t newlen = (uint32_t)strlen(trackInfo);
if (newlen > buflen) buflen = 0;
else buflen -= newlen;
MP4Free(trackInfo);
}
} else {
info = PrintTrackInfo(mp4File, trackId);
}
}
catch (Exception* x) {
mp4v2::impl::log.errorf(*x);
delete x;
}
}
return info;
}
extern "C"
char* MP4FileInfo(
const char* fileName,
MP4TrackId trackId )
{
MP4FileHandle mp4File = MP4Read(fileName);
if (!mp4File) {
return NULL;
}
char* info = MP4Info(mp4File, trackId);
MP4Close(mp4File);
return info; // caller should free this
}