add video rendering in Screen
parent
7bf1b33974
commit
6cd17ac61f
|
@ -10,8 +10,8 @@ using namespace std;
|
|||
int main() {
|
||||
Shooter game;
|
||||
|
||||
//game.create(1280, 720, ShooterConsts::PROJECT_NAME, true);
|
||||
game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::None);
|
||||
game.create(1280, 720, ShooterConsts::PROJECT_NAME, true);
|
||||
//game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR);
|
||||
|
||||
//game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false);
|
||||
//game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
|
||||
|
|
|
@ -51,22 +51,31 @@ void Screen::display() {
|
|||
|
||||
void Screen::startRender() {
|
||||
stopRender();
|
||||
|
||||
Log::log("Screen::startRender(): start recording the screen");
|
||||
_renderVideo = true;
|
||||
}
|
||||
|
||||
void Screen::stopRender() {
|
||||
if(_renderVideo) {
|
||||
Log::log("Screen::stopRender(): stop recording the screen");
|
||||
Log::log("Screen::stopRender(): start saving .png sequence");
|
||||
std::string c = "rm film/png/*.png";
|
||||
popen(c.c_str(), "w");
|
||||
int i = 0;
|
||||
for(; i < _renderSequence.size(); i++) {
|
||||
_renderSequence[i].copyToImage().saveToFile("film/png/" + std::to_string(i) + ".png");
|
||||
Log::log("Screen::stopRender(): saving .png sequence (" + std::to_string(static_cast<int>(100*i/_renderSequence.size())) + "%)");
|
||||
}
|
||||
_renderSequence.clear();
|
||||
|
||||
Log::log("Screen::stopRender(): start rendering final video");
|
||||
// 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";
|
||||
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 + "_" + std::to_string(rand()) + ".mp4";
|
||||
popen(c.c_str(), "w");
|
||||
_scene++;
|
||||
_renderVideo = false;
|
||||
Log::log("Screen::stopRender(): finish rendering final video");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue