src/platform/ffmpeg/ffmpeg-encoder.h (view raw)
1#ifndef FFMPEG_ENCODER
2#define FFMPEG_ENCODER
3
4#include "gba-thread.h"
5
6#include <libavformat/avformat.h>
7
8struct FFmpegEncoder {
9 struct GBAAVStream d;
10 struct AVFormatContext* context;
11
12 unsigned audioBitrate;
13 const char* audioCodec;
14
15 unsigned videoBitrate;
16 const char* videoCodec;
17
18 const char* containerFormat;
19
20 struct AVCodecContext* audio;
21 enum AVSampleFormat sampleFormat;
22 int sampleRate;
23 uint16_t* audioBuffer;
24 size_t audioBufferSize;
25 uint16_t* postaudioBuffer;
26 size_t postaudioBufferSize;
27 AVFrame* audioFrame;
28 size_t currentAudioSample;
29 int64_t currentAudioFrame;
30 int64_t nextAudioPts;
31 struct AVAudioResampleContext* resampleContext;
32 struct AVBitStreamFilterContext* absf; // Needed for AAC in MP4
33 struct AVStream* audioStream;
34
35 struct AVCodecContext* video;
36 enum AVPixelFormat pixFormat;
37 struct AVFrame* videoFrame;
38 int width;
39 int height;
40 int64_t currentVideoFrame;
41 struct SwsContext* scaleContext;
42 struct AVStream* videoStream;
43};
44
45void FFmpegEncoderInit(struct FFmpegEncoder*);
46bool FFmpegEncoderSetAudio(struct FFmpegEncoder*, const char* acodec, unsigned abr);
47bool FFmpegEncoderSetVideo(struct FFmpegEncoder*, const char* vcodec, unsigned vbr);
48bool FFmpegEncoderSetContainer(struct FFmpegEncoder*, const char* container);
49void FFmpegEncoderSetDimensions(struct FFmpegEncoder*, int width, int height);
50bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder*);
51bool FFmpegEncoderOpen(struct FFmpegEncoder*, const char* outfile);
52void FFmpegEncoderClose(struct FFmpegEncoder*);
53
54#endif