Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,11 +42,17 @@ def process_and_generate_video(audio_file, images):
|
|
| 42 |
image_duration = audio_duration / len(images)
|
| 43 |
|
| 44 |
for img_path in images:
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
debug_log.append(f"Created {len(image_clips)} image clips.")
|
| 52 |
|
|
@@ -73,7 +79,8 @@ def gradio_interface():
|
|
| 73 |
with gr.Row():
|
| 74 |
with gr.Column():
|
| 75 |
mp3_input = gr.Audio(type="filepath", label="Upload MP3")
|
| 76 |
-
|
|
|
|
| 77 |
generate_button = gr.Button("Generate Video")
|
| 78 |
|
| 79 |
output_video = gr.Video(label="Generated Video")
|
|
|
|
| 42 |
image_duration = audio_duration / len(images)
|
| 43 |
|
| 44 |
for img_path in images:
|
| 45 |
+
try:
|
| 46 |
+
debug_log.append(f"Processing image: {img_path}")
|
| 47 |
+
img = Image.open(img_path)
|
| 48 |
+
resized_img = resize_image_with_aspect_ratio(img, target_size=(1280, 720))
|
| 49 |
+
img_clip = mp.ImageClip(np.array(resized_img)).set_duration(image_duration).set_fps(24)
|
| 50 |
+
image_clips.append(img_clip)
|
| 51 |
+
except Exception as img_error:
|
| 52 |
+
debug_log.append(f"Error processing image {img_path}: {str(img_error)}")
|
| 53 |
+
|
| 54 |
+
if not image_clips:
|
| 55 |
+
raise ValueError("No valid images provided for video generation.")
|
| 56 |
|
| 57 |
debug_log.append(f"Created {len(image_clips)} image clips.")
|
| 58 |
|
|
|
|
| 79 |
with gr.Row():
|
| 80 |
with gr.Column():
|
| 81 |
mp3_input = gr.Audio(type="filepath", label="Upload MP3")
|
| 82 |
+
# Allow additional formats like .jpeg
|
| 83 |
+
image_input = gr.File(type="filepath", file_types=[".jpg", ".png", ".jpeg"], label="Upload Images", file_count="multiple")
|
| 84 |
generate_button = gr.Button("Generate Video")
|
| 85 |
|
| 86 |
output_video = gr.Video(label="Generated Video")
|