-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpeg.hpp
70 lines (51 loc) · 1.17 KB
/
ffmpeg.hpp
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
#ifndef FFMPEG_HPP__
#define FFMPEG_HPP__
#include <string>
#include <cstddef>
#include <cstdint>
#include <vector>
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
class FF
{
public:
FF(const std::string &path);
~FF();
void operator=(const FF&) = delete;
FF(FF &&ff);
FF& operator=(FF &&ff);
struct MediaInfo
{
enum class Format : unsigned {
None,
S16,
S32,
Float
};
unsigned channels;
unsigned rate;
Format fmt;
float duration;
std::string title, artist, album;
};
const MediaInfo &info() const;
float pos() const;
bool seek(float pos);
typedef std::vector<std::uint8_t> Buffer;
const Buffer& decode();
private:
AVFormatContext *fctx;
AVCodecContext *actx;
int aud_stream;
float last_pos;
MediaInfo media_info;
Buffer buffer;
bool planar_audio;
void resolve_codecs();
void get_media_info();
void get_metadata(AVDictionary *meta);
MediaInfo::Format fmt_conv(AVSampleFormat fmt);
};
#endif