sreepathi-ravikumar commited on
Commit
21b11ab
·
verified ·
1 Parent(s): 508b017

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -17,18 +17,18 @@ def home():
17
  def generate_video():
18
  try:
19
  data = request.get_json()
20
- duration = int(data.get("duration", 5))
21
 
22
- if duration <= 0 or duration > 60:
23
- return jsonify({"error": "Duration must be between 1 and 60 seconds"}), 400
24
  image_folder = "/tmp/images"
25
- prompts = ["sunset beach", "mountain landscape", "city skyline"]
26
- asyncio.run(main(prompts))
27
  image_files = sorted(glob.glob(os.path.join(image_folder, "*.jpg")))
28
  if not image_files:
29
  raise ValueError("No images found in folder!")
30
 
31
- clips = [ImageClip(m).set_duration(duration) for m in image_files]
32
  video = concatenate_videoclips(clips, method="compose")
33
  video_path = f"/tmp/video_{uuid.uuid4().hex}.mp4"
34
  video.write_videofile(video_path, fps=24)
 
17
  def generate_video():
18
  try:
19
  data = request.get_json()
20
+ prompts = data.get("duration", '').strip()
21
 
22
+ if prompts == '':
23
+ return jsonify({"error": "prompts be must"}), 400
24
  image_folder = "/tmp/images"
25
+ line=prompts.splitlines()
26
+ asyncio.run(main(lines))
27
  image_files = sorted(glob.glob(os.path.join(image_folder, "*.jpg")))
28
  if not image_files:
29
  raise ValueError("No images found in folder!")
30
 
31
+ clips = [ImageClip(m).set_duration(1) for m in image_files]
32
  video = concatenate_videoclips(clips, method="compose")
33
  video_path = f"/tmp/video_{uuid.uuid4().hex}.mp4"
34
  video.write_videofile(video_path, fps=24)