summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--src/main.cpp8
2 files changed, 8 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 7cbd65d..765cc48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ compile_commands.json
tests/sibs-build/
tests/compile_commands.json
frames/
+output.gif
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