From 7bf1b339742b7ca82b8f07760a92dc1446c11fc8 Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Fri, 12 Nov 2021 03:03:21 +0700 Subject: [PATCH] add video rendering in Screen --- engine/Screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/Screen.cpp b/engine/Screen.cpp index 2f45374..1711d62 100644 --- a/engine/Screen.cpp +++ b/engine/Screen.cpp @@ -40,7 +40,7 @@ void Screen::display() { sf::Texture copyTexture; copyTexture.create(_window->getSize().x, _window->getSize().y); copyTexture.update(*_window); - // most of the time of video rendering is wasting on .png sequence saving + // most of the time of video rendering is wasting on saving .png sequence // that's why we will save all images in the end // TODO: sometimes we have a huge time delay here for no obvious reason _renderSequence.push_back(copyTexture); @@ -56,13 +56,13 @@ void Screen::startRender() { void Screen::stopRender() { if(_renderVideo) { - int i = 0; for(; i < _renderSequence.size(); i++) { _renderSequence[i].copyToImage().saveToFile("film/png/" + std::to_string(i) + ".png"); } _renderSequence.clear(); + // TODO: .png sequence looks better than a final video (poor clarity and desaturated colors) std::string c = "ffmpeg -stats -r 60 -i film/png/%d.png -vcodec libx264 -crf 1 -pix_fmt yuv420p -frames " + std::to_string(i) + " film/mp4/" + std::to_string(_scene) + "_" + _title + ".mp4"; popen(c.c_str(), "w"); _scene++;