update
Browse files- app.py +17 -13
- modal_video_processing.py +7 -5
app.py
CHANGED
|
@@ -275,7 +275,7 @@ def create_quote_video_tool(video_url: str, quote_text: str, output_path: str, a
|
|
| 275 |
"quote_text": quote_text,
|
| 276 |
"audio_url": audio_url
|
| 277 |
},
|
| 278 |
-
timeout=
|
| 279 |
)
|
| 280 |
|
| 281 |
if response.status_code == 200:
|
|
@@ -697,18 +697,12 @@ with gr.Blocks(title="AIQuoteClipGenerator - MCP Edition", theme=gr.themes.Soft(
|
|
| 697 |
output = gr.Textbox(label="Agent Status", lines=20, show_label=False)
|
| 698 |
|
| 699 |
with gr.Row():
|
| 700 |
-
gr.Markdown("### ✨ Your Quote Videos
|
| 701 |
|
| 702 |
with gr.Row():
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
elem_id="gallery",
|
| 707 |
-
columns=3,
|
| 708 |
-
rows=2,
|
| 709 |
-
height="auto",
|
| 710 |
-
object_fit="contain"
|
| 711 |
-
)
|
| 712 |
|
| 713 |
gr.Markdown("""
|
| 714 |
---
|
|
@@ -731,10 +725,20 @@ with gr.Blocks(title="AIQuoteClipGenerator - MCP Edition", theme=gr.themes.Soft(
|
|
| 731 |
**Built with:** Gradio + smolagents + OpenAI + Pexels + Modal + MCP
|
| 732 |
""")
|
| 733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
generate_btn.click(
|
| 735 |
-
|
| 736 |
inputs=[niche, style, num_variations],
|
| 737 |
-
outputs=[output,
|
| 738 |
)
|
| 739 |
|
| 740 |
if __name__ == "__main__":
|
|
|
|
| 275 |
"quote_text": quote_text,
|
| 276 |
"audio_url": audio_url
|
| 277 |
},
|
| 278 |
+
timeout=300 # Increased to 5 minutes
|
| 279 |
)
|
| 280 |
|
| 281 |
if response.status_code == 200:
|
|
|
|
| 697 |
output = gr.Textbox(label="Agent Status", lines=20, show_label=False)
|
| 698 |
|
| 699 |
with gr.Row():
|
| 700 |
+
gr.Markdown("### ✨ Your Quote Videos")
|
| 701 |
|
| 702 |
with gr.Row():
|
| 703 |
+
video1 = gr.Video(label="Video 1", visible=True)
|
| 704 |
+
video2 = gr.Video(label="Video 2", visible=False)
|
| 705 |
+
video3 = gr.Video(label="Video 3", visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 706 |
|
| 707 |
gr.Markdown("""
|
| 708 |
---
|
|
|
|
| 725 |
**Built with:** Gradio + smolagents + OpenAI + Pexels + Modal + MCP
|
| 726 |
""")
|
| 727 |
|
| 728 |
+
def process_and_display(niche, style, num_variations):
|
| 729 |
+
status, videos = mcp_agent_pipeline(niche, style, num_variations)
|
| 730 |
+
|
| 731 |
+
# Return up to 3 videos, None for unused slots
|
| 732 |
+
v1 = videos[0] if len(videos) > 0 else None
|
| 733 |
+
v2 = videos[1] if len(videos) > 1 else None
|
| 734 |
+
v3 = videos[2] if len(videos) > 2 else None
|
| 735 |
+
|
| 736 |
+
return status, v1, v2, v3
|
| 737 |
+
|
| 738 |
generate_btn.click(
|
| 739 |
+
process_and_display,
|
| 740 |
inputs=[niche, style, num_variations],
|
| 741 |
+
outputs=[output, video1, video2, video3]
|
| 742 |
)
|
| 743 |
|
| 744 |
if __name__ == "__main__":
|
modal_video_processing.py
CHANGED
|
@@ -20,9 +20,10 @@ image = modal.Image.debian_slim(python_version="3.11").pip_install(
|
|
| 20 |
|
| 21 |
@app.function(
|
| 22 |
image=image,
|
| 23 |
-
cpu=
|
| 24 |
-
memory=
|
| 25 |
-
timeout=
|
|
|
|
| 26 |
)
|
| 27 |
def process_quote_video(video_url: str, quote_text: str, audio_url: str = None) -> bytes:
|
| 28 |
"""
|
|
@@ -160,11 +161,12 @@ def process_quote_video(video_url: str, quote_text: str, audio_url: str = None)
|
|
| 160 |
output_file.name,
|
| 161 |
codec='libx264',
|
| 162 |
audio_codec='aac',
|
| 163 |
-
fps=24
|
| 164 |
preset='ultrafast',
|
| 165 |
threads=4,
|
| 166 |
verbose=False,
|
| 167 |
-
logger=None
|
|
|
|
| 168 |
)
|
| 169 |
|
| 170 |
print("✅ Video exported")
|
|
|
|
| 20 |
|
| 21 |
@app.function(
|
| 22 |
image=image,
|
| 23 |
+
cpu=2, # Reduced to 2 CPUs for faster cold start
|
| 24 |
+
memory=2048, # Reduced to 2GB
|
| 25 |
+
timeout=180, # 3 minute timeout
|
| 26 |
+
concurrency_limit=10, # Allow multiple concurrent requests
|
| 27 |
)
|
| 28 |
def process_quote_video(video_url: str, quote_text: str, audio_url: str = None) -> bytes:
|
| 29 |
"""
|
|
|
|
| 161 |
output_file.name,
|
| 162 |
codec='libx264',
|
| 163 |
audio_codec='aac',
|
| 164 |
+
fps=15, # Reduced from 24 for faster encoding
|
| 165 |
preset='ultrafast',
|
| 166 |
threads=4,
|
| 167 |
verbose=False,
|
| 168 |
+
logger=None,
|
| 169 |
+
bitrate="1000k" # Lower bitrate for faster encoding
|
| 170 |
)
|
| 171 |
|
| 172 |
print("✅ Video exported")
|