Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -504,88 +504,42 @@ class VideoGeneratorUI:
|
|
| 504 |
|
| 505 |
def setup_ui(self):
|
| 506 |
st.title("Enhanced Video Generator")
|
| 507 |
-
st.write("Create professional videos with AI-generated content")
|
| 508 |
|
| 509 |
with st.form("video_generator_form"):
|
| 510 |
-
|
| 511 |
-
prompt = st.text_area(
|
| 512 |
-
"Enter your video topic/prompt",
|
| 513 |
-
height=100,
|
| 514 |
-
help="Describe what you want your video to be about"
|
| 515 |
-
)
|
| 516 |
-
|
| 517 |
col1, col2 = st.columns(2)
|
| 518 |
-
with col1:
|
| 519 |
-
style = st.selectbox(
|
| 520 |
-
"Choose style",
|
| 521 |
-
options=list(self.generator.themes.keys())
|
| 522 |
-
)
|
| 523 |
|
|
|
|
|
|
|
| 524 |
with col2:
|
| 525 |
-
duration = st.slider(
|
| 526 |
-
"Video duration (seconds)",
|
| 527 |
-
min_value=10,
|
| 528 |
-
max_value=300,
|
| 529 |
-
value=60,
|
| 530 |
-
step=10
|
| 531 |
-
)
|
| 532 |
-
|
| 533 |
-
advanced_options = st.expander("Advanced Options")
|
| 534 |
-
with advanced_options:
|
| 535 |
-
use_premium_voice = st.checkbox(
|
| 536 |
-
"Use premium voice-over",
|
| 537 |
-
value=False,
|
| 538 |
-
help="Requires ElevenLabs API key"
|
| 539 |
-
)
|
| 540 |
-
|
| 541 |
-
include_music = st.checkbox(
|
| 542 |
-
"Include background music",
|
| 543 |
-
value=True
|
| 544 |
-
)
|
| 545 |
-
|
| 546 |
-
fps = st.slider(
|
| 547 |
-
"Frames per second",
|
| 548 |
-
min_value=24,
|
| 549 |
-
max_value=60,
|
| 550 |
-
value=30
|
| 551 |
-
)
|
| 552 |
|
| 553 |
submit_button = st.form_submit_button("Generate Video")
|
| 554 |
|
| 555 |
-
if submit_button:
|
| 556 |
-
if not prompt:
|
| 557 |
-
st.error("Please enter a prompt for your video.")
|
| 558 |
-
return
|
| 559 |
-
|
| 560 |
try:
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
# Generate video
|
| 568 |
-
video_path = self.generator.create_video(
|
| 569 |
-
prompt,
|
| 570 |
-
style,
|
| 571 |
-
duration,
|
| 572 |
-
output_path
|
| 573 |
-
)
|
| 574 |
-
|
| 575 |
-
# Show success message and download button
|
| 576 |
st.success("Video generated successfully!")
|
| 577 |
|
| 578 |
-
with open(video_path, 'rb') as
|
| 579 |
-
st.
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
|
| 586 |
except Exception as e:
|
| 587 |
st.error(f"Failed to generate video: {str(e)}")
|
| 588 |
-
st.error("Please try again with different settings or contact support.")
|
| 589 |
|
| 590 |
if __name__ == "__main__":
|
| 591 |
ui = VideoGeneratorUI()
|
|
|
|
| 504 |
|
| 505 |
def setup_ui(self):
|
| 506 |
st.title("Enhanced Video Generator")
|
|
|
|
| 507 |
|
| 508 |
with st.form("video_generator_form"):
|
| 509 |
+
prompt = st.text_area("Enter your video topic/prompt", height=100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
col1, col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
|
| 512 |
+
with col1:
|
| 513 |
+
style = st.selectbox("Choose style", options=list(self.generator.themes.keys()))
|
| 514 |
with col2:
|
| 515 |
+
duration = st.slider("Video duration (seconds)", 10, 300, 60, 10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 516 |
|
| 517 |
submit_button = st.form_submit_button("Generate Video")
|
| 518 |
|
| 519 |
+
if submit_button and prompt:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
try:
|
| 521 |
+
output_path = os.path.join(os.getcwd(), f"generated_video_{int(time.time())}.mp4")
|
| 522 |
+
|
| 523 |
+
video_path = self.generator.create_video(prompt, style, duration, output_path)
|
| 524 |
+
|
| 525 |
+
if os.path.exists(video_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
st.success("Video generated successfully!")
|
| 527 |
|
| 528 |
+
with open(video_path, 'rb') as video_file:
|
| 529 |
+
st.video(video_file) # Display video
|
| 530 |
+
video_bytes = video_file.read()
|
| 531 |
+
|
| 532 |
+
st.download_button(
|
| 533 |
+
"Download Video",
|
| 534 |
+
video_bytes,
|
| 535 |
+
file_name=os.path.basename(video_path),
|
| 536 |
+
mime="video/mp4"
|
| 537 |
+
)
|
| 538 |
+
else:
|
| 539 |
+
st.error("Video file not found")
|
| 540 |
|
| 541 |
except Exception as e:
|
| 542 |
st.error(f"Failed to generate video: {str(e)}")
|
|
|
|
| 543 |
|
| 544 |
if __name__ == "__main__":
|
| 545 |
ui = VideoGeneratorUI()
|