forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.cpp
More file actions
64 lines (54 loc) · 1.42 KB
/
util.cpp
File metadata and controls
64 lines (54 loc) · 1.42 KB
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
#include "util.hpp"
extern "C" {
#include <libavutil/avutil.h>
}
#include <sstream>
namespace avtranscoder
{
namespace detail
{
template <>
void add(PropertyVector& propertyVector, const std::string& key, const size_t& value)
{
std::stringstream ss;
if(value == (size_t)AV_NOPTS_VALUE)
ss << "N/A";
else
ss << value;
add(propertyVector, key, ss.str());
}
template <>
void add(PropertyVector& propertyVector, const std::string& key, const float& value)
{
std::stringstream ss;
if(value <= AV_NOPTS_VALUE || value >= -(float)AV_NOPTS_VALUE)
ss << "N/A";
else
ss << value;
add(propertyVector, key, ss.str());
}
template <>
void add(PropertyVector& propertyVector, const std::string& key, const std::string& value)
{
propertyVector.push_back(std::make_pair(key, value));
}
template <>
void add(PropertyVector& propertyVector, const std::string& key, const bool& value)
{
add(propertyVector, key, value ? "True" : "False");
}
template <>
void add(PropertyVector& propertyVector, const std::string& key, const Rational& value)
{
add(propertyVector, key, value.num / (double)value.den);
}
void fillMetadataDictionnary(AVDictionary* avdictionnary, PropertyVector& metadata)
{
AVDictionaryEntry* tag = NULL;
while((tag = av_dict_get(avdictionnary, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
metadata.push_back(std::make_pair(tag->key, tag->value));
}
}
}
}