-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFFMpegExtractor.h
50 lines (36 loc) · 1.17 KB
/
FFMpegExtractor.h
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
//
// Created by asalehin on 10/26/20.
//
#ifndef FAST_MIXER_FFMPEGEXTRACTOR_H
#define FAST_MIXER_FFMPEGEXTRACTOR_H
extern "C" {
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libavutil/opt.h>
}
#include <string>
#include "../structs.h"
#include "../logging_macros.h"
#include "vector"
using namespace std;
class FFMpegExtractor {
public:
std::unique_ptr<FILE, void(*)(FILE *)> fp {
nullptr,
[](FILE *f) {
fseek(f, 0, SEEK_SET);
fclose(f);
}
};
double getDuration(int fd);
int64_t decode(int fd, uint8_t* targetData, AudioProperties targetProperties);
private:
bool createAVIOContext(uint8_t *buffer, uint32_t bufferSize,
AVIOContext **avioContext);
bool createAVFormatContext(AVIOContext *avioContext, AVFormatContext **avFormatContext);
bool openAVFormatContext(AVFormatContext *avFormatContext);
bool getStreamInfo(AVFormatContext *avFormatContext);
AVStream* getBestAudioStream(AVFormatContext *avFormatContext);
void printCodecParameters(AVCodecParameters *params);
};
#endif //FAST_MIXER_FFMPEGEXTRACTOR_H