add MP4Encoder class and test timelapse exporting
This commit is contained in:
33
src/mp4enc.h
Normal file
33
src/mp4enc.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "image.h"
|
||||
|
||||
class MP4Encoder
|
||||
{
|
||||
struct Frame
|
||||
{
|
||||
enum class kType : uint8_t { IFrame, PFrame, Unknown };
|
||||
kType type;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
struct Header
|
||||
{
|
||||
std::vector<uint8_t> SPS_data;
|
||||
std::vector<uint8_t> PPS_data;
|
||||
uint8_t avc_profile;
|
||||
uint8_t avc_profile_compat;
|
||||
uint8_t avc_level;
|
||||
};
|
||||
class ISVCEncoder* m_encoder = nullptr;
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
int m_bitrate = 1000 << 10;
|
||||
float m_framerate = 0;
|
||||
Header m_header;
|
||||
std::vector<Frame> m_frames;
|
||||
std::vector<uint8_t> m_yuv_buffer;
|
||||
public:
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user