-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp4v2.cpp
70 lines (60 loc) · 1.36 KB
/
mp4v2.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
/*
* Copyright 2017 by Philip N. Garner
*
* See the file COPYING for the licence associated with this software.
*
* Author(s):
* Phil Garner, August 2017
*/
#include <iostream>
#include "mp4v2.h"
MP4::MP4()
{
mHandle = MP4_INVALID_FILE_HANDLE;
}
MP4::MP4(var iFileName)
{
mHandle = MP4_INVALID_FILE_HANDLE;
load(iFileName);
}
MP4::~MP4()
{
if (mHandle)
MP4Close(mHandle);
mHandle = MP4_INVALID_FILE_HANDLE;
}
void MP4::load(var iFileName)
{
// Reduce the log level. Default is "complain big time", but the file may
// not be an MP4 file.
MP4LogSetLevel(MP4_LOG_VERBOSE1);
// Open the file
mHandle = MP4Read(iFileName.str());
if (!MP4_IS_VALID_FILE_HANDLE(mHandle))
return;
// Copy the metadata tags
std::cout << "Getting meta" << std::endl;
MP4ItmfItemList* itemList;
itemList = MP4ItmfGetItems(mHandle);
int nItems = itemList->size;
MP4ItmfItem* item = itemList->elements;
std::cout << "Got " << nItems << " elements" << std::endl;
for (int i=0; i<nItems; i++)
{
std::cout << item[i].code << std::endl;
}
MP4ItmfItemListFree(itemList);
}
void MP4::dump()
{
std::cout << mTag << std::endl;
}
var MP4::date()
{
// Date information is in 'creation_time' tag
return mTag["creation_time"].copy();
}
var MP4::tag(var iKey)
{
return mTag[iKey];
}