From 3023f35077d17b7a35a6453c7ea973a6de9fe759 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 15 May 2021 02:30:59 +0200 Subject: Autoclose after playtime, remove temporary png files --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') 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 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 -- cgit v1.2.3