-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutil.cpp
More file actions
34 lines (30 loc) · 830 Bytes
/
Copy pathutil.cpp
File metadata and controls
34 lines (30 loc) · 830 Bytes
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
#include "util.h"
#include <iomanip>
#include <sstream>
extern "C" {
#include "libavutil/dict.h"
}
void ms_to_readable(const int ms, int& h, int& m, int& s, int& mms) {
mms = ms % 1000;
int rest = (ms - mms) / 1000;
s = rest % 60;
rest = (rest - s) / 60;
m = rest % 60;
h = (rest - m) / 60;
}
std::string ms_to_readable(const int ms) {
int h, min, s, _ms;
ms_to_readable(ms, h, min, s, _ms);
std::stringstream tmp;
tmp << std::setfill('0');
tmp << h << ":" << std::setw(2) << min << ":" << std::setw(2) << s << "." << std::setw(3) << _ms;
return tmp.str();
}
metadata_t av_dict_to_metadata(AVDictionary* dict) {
metadata_t metadata;
AVDictionaryEntry *tag = NULL;
while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
metadata[tag->key] = tag->value;
}
return metadata;
}