-
Notifications
You must be signed in to change notification settings - Fork 0
/
avformat.cpp
65 lines (56 loc) · 1.08 KB
/
avformat.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
/*
* Copyright 2016 by Philip N. Garner
*
* See the file COPYING for the licence associated with this software.
*
* Author(s):
* Phil Garner, May 2016
*/
#include <iostream>
#include "avformat.h"
extern "C" {
# include <libavutil/dict.h>
}
AVFormat::AVFormat()
{
mContext = 0;
}
AVFormat::AVFormat(var iFileName)
{
mContext = 0;
load(iFileName);
}
AVFormat::~AVFormat()
{
if (mContext)
avformat_close_input(&mContext);
mContext = 0;
}
void AVFormat::load(var iFileName)
{
int ret = avformat_open_input(&mContext, iFileName.str(), 0, 0);
if (ret)
{
mContext = 0;
return;
}
// Copy the metadata tags
AVDictionaryEntry *tag = 0;
while ((tag = av_dict_get(
mContext->metadata, "", tag, AV_DICT_IGNORE_SUFFIX
)))
mTag[tag->key] = tag->value;
}
void AVFormat::dump()
{
std::cout << mTag << std::endl;
}
var AVFormat::date()
{
// Date information is in 'creation_time' tag
return mTag["creation_time"].copy();
}
var AVFormat::tag(var iKey)
{
return mTag[iKey];
}