save timelapse stream to file

This commit is contained in:
2019-11-02 18:05:24 +01:00
parent 7db1739df6
commit 83ba717d5b
9 changed files with 150 additions and 23 deletions

View File

@@ -1,7 +1,8 @@
#pragma once
#include "image.h"
#include "serializer.h"
class MP4Encoder
class MP4Encoder : public Serializer::Type
{
struct Frame
{
@@ -14,7 +15,7 @@ class MP4Encoder
std::vector<uint8_t> SPS_data;
std::vector<uint8_t> PPS_data;
uint8_t avc_profile;
uint8_t avc_profile_compat;
uint8_t avc_compat;
uint8_t avc_level;
};
class ISVCEncoder* m_encoder = nullptr;
@@ -26,8 +27,13 @@ class MP4Encoder
std::vector<Frame> m_frames;
std::vector<uint8_t> m_yuv_buffer;
public:
~MP4Encoder();
bool init() noexcept;
bool init(int width, int height, int fps, int bitrate) noexcept;
bool encode(const Image& rgba) noexcept;
bool write_mp4(const std::string& filename) const noexcept;
void destroy() noexcept;
int frames_count() const noexcept { return m_frames.size(); }
virtual bool read(BinaryStreamReader& r) override;
virtual void write(BinaryStreamWriter& w) const override;
};