jschwab21 commited on
Commit
32577b9
·
verified ·
1 Parent(s): 470c06d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -1,17 +1,22 @@
1
  import gradio as gr
 
2
 
3
  def display_video(video_file):
4
  if video_file is None:
5
  return None, "No video uploaded."
 
 
6
  try:
7
- # Directly return the path to the uploaded video file for displaying
8
- return video_file, None
 
 
9
  except Exception as e:
10
  return None, f"An error occurred: {str(e)}"
11
 
12
  with gr.Blocks() as demo:
13
  with gr.Column():
14
- video_file = gr.UploadButton("Upload Video File", type="binary", file_types=["video"])
15
  output_video = gr.Video()
16
  output_message = gr.Textbox(label="Output Message")
17
  submit_button = gr.Button("Display Video")
 
1
  import gradio as gr
2
+ import os
3
 
4
  def display_video(video_file):
5
  if video_file is None:
6
  return None, "No video uploaded."
7
+
8
+ # Check if the uploaded file is valid
9
  try:
10
+ if os.path.getsize(video_file.name) > 0: # Simple check to confirm it's a real file with content
11
+ return video_file, None
12
+ else:
13
+ return None, "Uploaded file is empty."
14
  except Exception as e:
15
  return None, f"An error occurred: {str(e)}"
16
 
17
  with gr.Blocks() as demo:
18
  with gr.Column():
19
+ video_file = gr.File(label="Upload Video File", type="file", file_types=["mp4", "avi", "mov"])
20
  output_video = gr.Video()
21
  output_message = gr.Textbox(label="Output Message")
22
  submit_button = gr.Button("Display Video")