Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
-
from moviepy.editor import AudioFileClip, ImageClip
|
3 |
|
4 |
def create_video(image, audio):
|
5 |
# Load the audio file
|
6 |
audio_clip = AudioFileClip(audio)
|
7 |
|
8 |
-
# Load the image
|
9 |
image_clip = ImageClip(image).set_duration(audio_clip.duration)
|
10 |
|
11 |
-
#
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Save the video to a temporary file
|
15 |
-
output_path = "/tmp/
|
16 |
video_clip.write_videofile(output_path, fps=30)
|
17 |
|
18 |
return output_path
|
@@ -25,8 +29,8 @@ iface = gr.Interface(
|
|
25 |
gr.Audio(type="filepath", label="Upload Audio")
|
26 |
],
|
27 |
outputs=gr.Video(label="Output Video"),
|
28 |
-
title="Image + Audio to Video Converter",
|
29 |
-
description="Upload an image and an audio file to generate a video with the image and audio combined."
|
30 |
)
|
31 |
|
32 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from moviepy.editor import AudioFileClip, ImageClip, CompositeVideoClip
|
3 |
|
4 |
def create_video(image, audio):
|
5 |
# Load the audio file
|
6 |
audio_clip = AudioFileClip(audio)
|
7 |
|
8 |
+
# Load the main image and set its duration to match the audio
|
9 |
image_clip = ImageClip(image).set_duration(audio_clip.duration)
|
10 |
|
11 |
+
# Load the logo image, resize it, and position it in the top-right corner
|
12 |
+
logo = ImageClip("Logo.png").resize(height=50) # Adjust the height as needed
|
13 |
+
logo = logo.set_position(("right", "top")).set_duration(audio_clip.duration)
|
14 |
+
|
15 |
+
# Create a composite video with the main image and the logo overlay
|
16 |
+
video_clip = CompositeVideoClip([image_clip, logo]).set_audio(audio_clip)
|
17 |
|
18 |
# Save the video to a temporary file
|
19 |
+
output_path = "/tmp/output_video_with_logo.mp4"
|
20 |
video_clip.write_videofile(output_path, fps=30)
|
21 |
|
22 |
return output_path
|
|
|
29 |
gr.Audio(type="filepath", label="Upload Audio")
|
30 |
],
|
31 |
outputs=gr.Video(label="Output Video"),
|
32 |
+
title="Image + Audio to Video Converter with Logo Overlay",
|
33 |
+
description="Upload an image and an audio file to generate a video with the image and audio combined, including a logo overlay in the top-right corner."
|
34 |
)
|
35 |
|
36 |
iface.launch()
|