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 <libavcodec/avcodec.h>
7#include <libavformat/avformat.h>
8#include <libavresample/avresample.h>
9
10struct FFmpegEncoder {
11 struct GBAAVStream d;
12 AVFormatContext* context;
13
14 unsigned audioBitrate;
15 const char* audioCodec;
16
17 unsigned videoBitrate;
18 const char* videoCodec;
19
20 const char* containerFormat;
21
22 AVCodecContext* audio;
23 enum AVSampleFormat sampleFormat;
24 int sampleRate;
25 uint16_t* audioBuffer;
26 size_t audioBufferSize;
27 uint16_t* postaudioBuffer;
28 size_t postaudioBufferSize;
29 AVFrame* audioFrame;
30 size_t currentAudioSample;
31 int64_t currentAudioFrame;
32 int64_t nextAudioPts;
33 AVAudioResampleContext* resampleContext;
34 AVStream* audioStream;
35
36 AVCodecContext* video;
37 enum AVPixelFormat pixFormat;
38 AVFrame* videoFrame;
39 int64_t currentVideoFrame;
40 AVStream* videoStream;
41};
42
43void FFmpegEncoderInit(struct FFmpegEncoder*);
44bool FFmpegEncoderSetAudio(struct FFmpegEncoder*, const char* acodec, unsigned abr);
45bool FFmpegEncoderSetVideo(struct FFmpegEncoder*, const char* vcodec, unsigned vbr);
46bool FFmpegEncoderSetContainer(struct FFmpegEncoder*, const char* container);
47bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder*);
48bool FFmpegEncoderOpen(struct FFmpegEncoder*, const char* outfile);
49void FFmpegEncoderClose(struct FFmpegEncoder*);
50
51#endif