Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1178,33 +1178,64 @@ class VideoGeneratorUI:
|
|
| 1178 |
print(f"Error displaying image: {e}")
|
| 1179 |
|
| 1180 |
def show_video_settings(self, prompt: str, selected_images: List[str]):
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
)
|
| 1200 |
-
|
| 1201 |
-
generate_button = st.form_submit_button(
|
| 1202 |
-
label="🎬 Generate Video",
|
| 1203 |
-
type="primary"
|
| 1204 |
-
)
|
| 1205 |
|
| 1206 |
-
|
| 1207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1208 |
|
| 1209 |
def generate_video(self, prompt: str, style: str, duration: int, selected_images: List[str]):
|
| 1210 |
"""Handle video generation with improved error handling"""
|
|
|
|
| 1178 |
print(f"Error displaying image: {e}")
|
| 1179 |
|
| 1180 |
def show_video_settings(self, prompt: str, selected_images: List[str]):
|
| 1181 |
+
"""Show video generation settings and controls"""
|
| 1182 |
+
st.subheader("Video Settings")
|
| 1183 |
+
|
| 1184 |
+
col1, col2 = st.columns(2)
|
| 1185 |
+
with col1:
|
| 1186 |
+
style = st.selectbox(
|
| 1187 |
+
"Choose style",
|
| 1188 |
+
options=["Professional", "Creative", "Educational"],
|
| 1189 |
+
index=0
|
| 1190 |
+
)
|
| 1191 |
+
with col2:
|
| 1192 |
+
duration = st.slider(
|
| 1193 |
+
"Video duration (seconds)",
|
| 1194 |
+
min_value=30,
|
| 1195 |
+
max_value=180,
|
| 1196 |
+
value=60,
|
| 1197 |
+
step=30
|
| 1198 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1199 |
|
| 1200 |
+
if st.button("🎬 Generate Video", type="primary"):
|
| 1201 |
+
if not selected_images:
|
| 1202 |
+
st.error("Please select at least one image before generating the video.")
|
| 1203 |
+
return
|
| 1204 |
+
|
| 1205 |
+
try:
|
| 1206 |
+
output_dir = "temp_videos"
|
| 1207 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 1208 |
+
output_path = os.path.join(output_dir, f"vaultgenix_video_{int(time.time())}.mp4")
|
| 1209 |
+
|
| 1210 |
+
video_path = self.generator.create_video(
|
| 1211 |
+
prompt,
|
| 1212 |
+
style,
|
| 1213 |
+
duration,
|
| 1214 |
+
output_path,
|
| 1215 |
+
selected_images
|
| 1216 |
+
)
|
| 1217 |
+
|
| 1218 |
+
if os.path.exists(video_path):
|
| 1219 |
+
st.success("✨ Video generated successfully!")
|
| 1220 |
+
|
| 1221 |
+
# Display video
|
| 1222 |
+
with open(video_path, 'rb') as video_file:
|
| 1223 |
+
video_bytes = video_file.read()
|
| 1224 |
+
st.video(video_bytes)
|
| 1225 |
+
|
| 1226 |
+
# Download button
|
| 1227 |
+
st.download_button(
|
| 1228 |
+
label="⬇️ Download Video",
|
| 1229 |
+
data=video_bytes,
|
| 1230 |
+
file_name=os.path.basename(video_path),
|
| 1231 |
+
mime="video/mp4"
|
| 1232 |
+
)
|
| 1233 |
+
else:
|
| 1234 |
+
st.error("Video generation failed. Please try again.")
|
| 1235 |
+
|
| 1236 |
+
except Exception as e:
|
| 1237 |
+
st.error(f"Error generating video: {str(e)}")
|
| 1238 |
+
print(f"Video generation error: {str(e)}") # For debugging
|
| 1239 |
|
| 1240 |
def generate_video(self, prompt: str, style: str, duration: int, selected_images: List[str]):
|
| 1241 |
"""Handle video generation with improved error handling"""
|