Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
1littlecoder
commited on
Commit
•
eeaae00
1
Parent(s):
346474a
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import google.generativeai as genai
|
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
from moviepy.editor import AudioFileClip, ImageClip, CompositeVideoClip
|
|
|
|
|
6 |
|
7 |
# Configure Google Gemini API
|
8 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
@@ -92,10 +94,19 @@ def create_video(image, audio):
|
|
92 |
|
93 |
# Create a composite video with the main image and the logo overlay
|
94 |
video_clip = CompositeVideoClip([image_clip, logo]).set_audio(audio_clip)
|
|
|
|
|
95 |
|
96 |
# Save the video to a temporary file
|
97 |
output_path = "/tmp/output_video_with_logo.mp4"
|
98 |
-
video_clip.write_videofile(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
return output_path
|
101 |
except Exception as e:
|
|
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
from moviepy.editor import AudioFileClip, ImageClip, CompositeVideoClip
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
|
9 |
# Configure Google Gemini API
|
10 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
|
|
94 |
|
95 |
# Create a composite video with the main image and the logo overlay
|
96 |
video_clip = CompositeVideoClip([image_clip, logo]).set_audio(audio_clip)
|
97 |
+
|
98 |
+
|
99 |
|
100 |
# Save the video to a temporary file
|
101 |
output_path = "/tmp/output_video_with_logo.mp4"
|
102 |
+
video_clip.write_videofile(
|
103 |
+
output_path,
|
104 |
+
fps=30,
|
105 |
+
codec="libx264",
|
106 |
+
audio_codec="aac",
|
107 |
+
preset="slow",
|
108 |
+
ffmpeg_params=["-b:v", "2000k"] # Adjust bitrate if needed
|
109 |
+
)
|
110 |
|
111 |
return output_path
|
112 |
except Exception as e:
|