diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-15 02:30:59 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-15 02:30:59 +0200 |
commit | 3023f35077d17b7a35a6453c7ea973a6de9fe759 (patch) | |
tree | 1793ca95e04ae52245f723c2ae68e13efe628f59 /src/main.cpp | |
parent | 404d6c69d6c8c1fc9c711809c44ea085cdac6bb7 (diff) |
Autoclose after playtime, remove temporary png files
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 5f31427..78e3221 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,6 +63,8 @@ int main() { sf::Image output_image; output_image.create(flag_width, flag_height, sf::Color::Transparent); + const float playtime_sec = 2.0f; + sf::Clock timer; while (window.isOpen()) { sf::Event event; @@ -82,11 +84,15 @@ int main() { output_image.copy(image, 0, 0, sf::IntRect(flag_start_x, flag_start_y, flag_width, flag_height), false); std::lock_guard<std::mutex> lock(images_lock); pending_frames.push_back(output_image); + + if(timer.getElapsedTime().asSeconds() >= playtime_sec) + break; } running = false; work_thread.join(); - system("ffmpeg -i \"frames/%d.png\" -framerate 24 -filter_complex \"fps=24,split=2[palette_in][gif];[palette_in]palettegen[palette_out];[gif]fifo[gif_fifo]; [gif_fifo][palette_out]paletteuse\" -y frames/output.gif"); + system("ffmpeg -i \"frames/%d.png\" -framerate 24 -filter_complex \"fps=24,split=2[palette_in][gif];[palette_in]palettegen[palette_out];[gif]fifo[gif_fifo]; [gif_fifo][palette_out]paletteuse\" -y output.gif"); + system("rm -rf frames"); return 0; }
\ No newline at end of file |