implemented audio exporting

The encoder was moved to its own thread and will transcode the PCM from the
audio renderer into the chosen codec while the video frames are still
received. The implementation isn't perfect and could use some cleaning up, but
it is functional at the moment.
This commit is contained in:
itsmattkc
2019-12-23 01:45:27 +11:00
parent a8beae64ae
commit 3a7b3ffac6
19 changed files with 377 additions and 159 deletions
+11 -4
View File
@@ -11,12 +11,17 @@ extern "C" {
class FFmpegEncoder : public Encoder
{
Q_OBJECT
public:
FFmpegEncoder(const EncodingParams &params);
virtual bool Open() override;
virtual void Write(FramePtr frame) override;
virtual void Close() override;
public slots:
virtual void WriteAudio(const AudioRenderingParams& pcm_info, const QString& pcm_filename) override;
protected:
virtual bool OpenInternal() override;
virtual void WriteInternal(FramePtr frame) override;
virtual void CloseInternal() override;
private:
/**
@@ -36,7 +41,9 @@ private:
*
* @param error_code
*/
void FFmpegError(int error_code);
void FFmpegError(const char *context, int error_code);
void WriteAVFrame(AVFrame* frame, AVCodecContext *codec_ctx, AVStream *stream);
bool InitializeStream(enum AVMediaType type, AVStream** stream, AVCodecContext** codec_ctx, const QString& codec);
bool InitializeCodecContext(AVStream** stream, AVCodecContext** codec_ctx, AVCodec* codec);