save timelapse stream to file
This commit is contained in:
@@ -1644,6 +1644,9 @@ bool Canvas::create(int width, int height)
|
||||
m_merge_rtt.create(width, height);
|
||||
m_merge_tex.create(width, height);
|
||||
m_unsaved = true;
|
||||
|
||||
timelapse_reset_encoder();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2213,7 +2216,27 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ppi_header.doc_version.minor >= 4)
|
||||
{
|
||||
BinaryStreamWriter sw;
|
||||
sw.init(BinaryStream::ByteOrder::LittleEndian);
|
||||
|
||||
Serializer::Descriptor info;
|
||||
info.class_id = "ppi_info";
|
||||
info.name = L"info header";
|
||||
info.props["has_encoder"] = std::make_shared<Serializer::Boolean>(m_encoder != nullptr);
|
||||
sw << info;
|
||||
if (m_encoder != nullptr)
|
||||
sw << *m_encoder;
|
||||
|
||||
int bytes = sw.m_data.size();
|
||||
fwrite(&bytes, sizeof(int), 1, fp);
|
||||
fwrite((char*)sw.m_data.data(), sw.m_data.size(), 1, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
bool success = false;
|
||||
if (use_tmp)
|
||||
{
|
||||
@@ -2415,6 +2438,33 @@ bool Canvas::project_open_thread(std::string file_path)
|
||||
|
||||
std::swap(tmp_layers, m_layers);
|
||||
|
||||
if (ppi_header.doc_version.minor >= 4)
|
||||
{
|
||||
int bytes = 0;
|
||||
fread(&bytes, sizeof(int), 1, fp);
|
||||
std::vector<uint8_t> data(bytes);
|
||||
fread(data.data(), bytes, 1, fp);
|
||||
BinaryStreamReader sr;
|
||||
sr.init(data.data(), data.size(), BinaryStream::ByteOrder::LittleEndian);
|
||||
Serializer::Descriptor info;
|
||||
sr >> info;
|
||||
|
||||
if (info.value<Serializer::Boolean>("has_encoder"))
|
||||
{
|
||||
m_encoder = std::make_unique<MP4Encoder>();
|
||||
sr >> *m_encoder;
|
||||
m_encoder->init();
|
||||
}
|
||||
else
|
||||
{
|
||||
timelapse_reset_encoder();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timelapse_reset_encoder();
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
LOG("project restore from %s", file_path.c_str());
|
||||
|
||||
@@ -2829,3 +2879,10 @@ void Canvas::set_camera(const CameraData& c)
|
||||
m_proj = c.m_proj;
|
||||
m_vp = c.m_vp;
|
||||
}
|
||||
|
||||
void Canvas::timelapse_reset_encoder() noexcept
|
||||
{
|
||||
m_encoder = std::make_unique<MP4Encoder>();
|
||||
int res = glm::min<int>(m_width / 2, 1024);
|
||||
m_encoder->init(res * 4, res * 2, 30, 2000 << 10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user