Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
8 |
-
|
|
|
|
|
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.
|
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")
|