Spaces:
Sleeping
Sleeping
File size: 1,094 Bytes
dcb53fc 32577b9 0268b89 e86173d 470c06d 32577b9 17c0909 e86173d 32577b9 17c0909 470c06d 5c42ea2 73d2101 5d5059e 1503650 470c06d b86b5dd e86173d 470c06d b86b5dd dcb53fc 470c06d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import os
def save_and_display_video(video_file):
if video_file is None:
return None, "No video uploaded."
try:
if len(video_file) > 0:
# Save the binary content to a file
file_path = 'uploaded_video.mp4' # Assuming .mp4 for simplicity
with open(file_path, 'wb') as f:
f.write(video_file)
return file_path, "Video uploaded and displayed successfully."
else:
return None, "Uploaded file is empty."
except Exception as e:
return None, f"An error occurred: {str(e)}"
with gr.Blocks() as demo:
with gr.Column():
video_file = gr.UploadButton(label="Upload Video File", file_types=["mp4", "avi", "mov"], interactive=True)
output_video = gr.Video()
output_message = gr.Textbox(label="Output Message")
submit_button = gr.Button("Display Video")
submit_button.click(
fn=save_and_display_video,
inputs=video_file,
outputs=[output_video, output_message]
)
demo.launch()
|