Spaces:
Sleeping
Sleeping
import cv2 | |
import gradio as gr | |
def video_stream(ip_url): | |
cap = cv2.VideoCapture(ip_url) | |
while True: | |
ret, frame = cap.read() | |
if not ret: | |
break | |
_, jpeg = cv2.imencode(".jpg", frame) | |
yield jpeg.tobytes() | |
def start_stream(ip_url): | |
return gr.update(value=video_stream(ip_url)) | |
# Create Gradio Interface | |
with gr.Blocks() as demo: | |
ip_input = gr.Textbox(label="Enter IP Webcam URL", value="http://100.87.48.67:8080/video") | |
video_output = gr.Video() | |
start_btn = gr.Button("Start Stream") | |
start_btn.click(start_stream, inputs=ip_input, outputs=video_output) | |
demo.launch() | |