-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvideoencoder.h
86 lines (69 loc) · 1.84 KB
/
videoencoder.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef VIDEOENCODER_H
#define VIDEOENCODER_H
#define USELIBAV
#ifdef USELIBAV
extern "C"
{
#include <libavutil/avconfig.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswresample/swresample.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <libavutil/timecode.h>
}
#endif
#include <QOpenGLTexture>
class FrameTexture
{
public:
FrameTexture();
~FrameTexture();
public:
uint8_t *buf;
int bufSize;
int width;
int height;
GLenum format;
int nComponents;
bool isNonNativeEndianess;
};
class AudioFromTexture
{
public:
AudioFromTexture(int _nChannels=1, int _rate=48000, int _nSamples=0);
~AudioFromTexture();
public:
float **buf;
int nChannels;
int samplingRate;
int nSamples;
};
class VideoEncoder
{
public:
VideoEncoder(const char *filename);
void Open();
void Close();
void ExampleVideoFrame(FrameTexture *frame);
void ExampleAudioFrame(const AudioFromTexture *example);
void WriteVideoFrame(const FrameTexture *frame);
void WriteAudioFrame(const AudioFromTexture *audio);
private:
AVFormatContext *outFmt;
// corresponding variable in muxing.c
AVCodec *audioCodec; // audio_codec
AVCodec *videoCodec; // video_codec
AVStream *audioStream; // audio_st->st
AVStream *videoStream; // video_st->st
AVFrame *audioFrameIn; // audio_st->tmp_frame
AVFrame *audioFrameOut; // audio_st->frame
SwrContext *audioResampleCtx; // audio_st->swr_ctx
int64_t audioNumSamplesIn; // audio_st->next_pts
int64_t audioNumSamplesOut; // audio_st->samples_count
AVFrame *videoFrameIn; // video_st->tmp_frame
AVFrame *videoFrameOut; // video_st->frame
SwsContext *videoRescaleCtx; // video_st->sws_ctx
int64_t videoNumFrames; // video_st->samples_count
};
#endif // VIDEOENCODER_H