Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ from moviepy.editor import ColorClip
|
|
3 |
import traceback
|
4 |
import uuid
|
5 |
import os
|
|
|
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
|
@@ -18,10 +20,16 @@ def generate_video():
|
|
18 |
|
19 |
if duration <= 0 or duration > 60:
|
20 |
return jsonify({"error": "Duration must be between 1 and 60 seconds"}), 400
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
return send_file(video_path, mimetype='video/mp4')
|
27 |
|
@@ -30,4 +38,8 @@ def generate_video():
|
|
30 |
return jsonify({"error": str(e)}), 500
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
3 |
import traceback
|
4 |
import uuid
|
5 |
import os
|
6 |
+
import asyncio
|
7 |
+
from image_fetcher import main
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
|
|
|
20 |
|
21 |
if duration <= 0 or duration > 60:
|
22 |
return jsonify({"error": "Duration must be between 1 and 60 seconds"}), 400
|
23 |
+
prompts = ["sunset beach", "mountain landscape", "city skyline"]
|
24 |
+
asyncio.run(main(prompts))
|
25 |
+
image_files = sorted(glob.glob(os.path.join(image_folder, "*.jpg")))
|
26 |
+
if not image_files:
|
27 |
+
raise ValueError("No images found in folder!")
|
28 |
+
|
29 |
+
clips = [ImageClip(m).set_duration(duration) for m in image_files]
|
30 |
+
video = concatenate_videoclips(clips, method="compose")
|
31 |
+
|
32 |
+
video.write_videofile(video_path, fps=24)
|
33 |
|
34 |
return send_file(video_path, mimetype='video/mp4')
|
35 |
|
|
|
38 |
return jsonify({"error": str(e)}), 500
|
39 |
|
40 |
if __name__ == "__main__":
|
41 |
+
app.run(host="0.0.0.0", port=7860)
|
42 |
+
|
43 |
+
# Example call (remove or change in your actual app)
|
44 |
+
|
45 |
+
|