-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfileAudioEncoder.h
49 lines (44 loc) · 1.13 KB
/
fileAudioEncoder.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
#define __STDC_CONSTANT_MACROS
extern "C"
{
#include "libavfilter/avfilter.h"
#include "libavfilter/buffersrc.h"
#include "libavfilter/buffersink.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavutil/imgutils.h"
#include "libavutil/error.h"
#include "libavutil/avutil.h"
#include "libavutil/mathematics.h"
#include "libavutil/samplefmt.h"
#include "libavutil/frame.h"
#include "libavutil/opt.h"
}
#include <stdint.h>
#include <inttypes.h>
#include <vector>
#include <iostream>
class fileAudioEncoder
{
private:
AVCodec *codec;
AVCodecContext *codecContext;
AVCodecParameters *codecParameters;
AVFrame *frame;
AVPacket *packet;
AVFilterGraph *filterGraph;
AVFilterContext *filterSource, *filterSink;
AVStream *stream;
AVFormatContext *formatContext;
AVIOContext *ioContext;
AVCodecID codecID;
int finished;
void cleanUp();
int encodeFrame(AVFrame *frame);
public:
int init(const char *filePath, const std::vector<AVCodecID> *codecIDs, AVCodecParameters *parameters);
int writeHeader();
int writeEncodedPacket(AVPacket *toWrite);
int writeTrailer();
AVPacket *getEncodedPacket(AVFrame *toEncode);
};