shaheerawan3 commited on
Commit
39e56b1
·
verified ·
1 Parent(s): 643827c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -26
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
- """Show video generation settings and controls"""
1182
- st.subheader("Video Settings")
1183
-
1184
- with st.form(key='video_settings_form'):
1185
- col1, col2 = st.columns(2)
1186
- with col1:
1187
- style = st.selectbox(
1188
- "Choose style",
1189
- options=["Professional", "Creative", "Educational"],
1190
- index=0
1191
- )
1192
- with col2:
1193
- duration = st.slider(
1194
- "Video duration (seconds)",
1195
- min_value=30,
1196
- max_value=180,
1197
- value=60,
1198
- step=30
1199
- )
1200
-
1201
- generate_button = st.form_submit_button(
1202
- label="🎬 Generate Video",
1203
- type="primary"
1204
- )
1205
 
1206
- if generate_button:
1207
- self.generate_video(prompt, style, duration, selected_images)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"""