Hi Ultralytics Team,
I am using YOLO11 (model: yolo11n_openvino_model) for real-time object detection on M3U8 video streams using OpenCV. Here is the code I used:
import cv2
from ultralytics import YOLO
Load the YOLO model
model = YOLO(“./model/yolo11n_openvino_model”)
Open the video file
video_path = “https://atcs.banjarmasinkota.go.id/stream/FNZ59BM5VH/s.m3u8”
cap = cv2.VideoCapture(video_path)
Loop through the video frames
while cap.isOpened():
success, frame = cap.read()
if success:
results = model(frame)
annotated_frame = results[0].plot()
cv2.imshow(“YOLO Inference”, annotated_frame)
if cv2.waitKey(1) & 0xFF == ord(“q”):
break
else:
break
cap.release()
cv2.destroyAllWindows()
Problem:
I’m having trouble time skip while processing this M3U8 stream. The video processing is not smooth, with some frames appearing to be skipped, causing inconsistent and choppy object detection. This stream plays smoothly in VLC, but with OpenCV, cap.isOpened() often returns False or success becomes False suddenly, causing the loop to stop or frames to be skipped.
Question:
Are there any specific settings in OpenCV or YOLO11 (e.g., OpenCV backend parameters, buffering configuration, or model optimization) that can be recommended to address the time skip issue in M3U8 streams, so that processing becomes more stable and real-time?
Does OpenCV (cv2.VideoCapture) have any limitations in handling M3U8 streams natively, and if so, does Ultralytics have any suggestions to improve the stability of the stream delivery without using additional libraries such as FFmpeg?
Are there any techniques or best practices in the YOLO11 pipeline to ensure that frames from a real-time stream are processed sequentially without skipping, especially for HLS streams such as M3U8?
If OpenCV is not ideal for M3U8 streams, does Ultralytics have any official examples or recommendations for integrating YOLO11 with alternatives like GStreamer for real-time streams?
Environment:
Python 3.9.13
OpenCV 4.9.0.80
ultralytics 8.3.36
Windows, CUDA 12.2
The M3U8 stream plays smoothly in VLC.
I would appreciate any suggestions, code examples, or guidance on how to work around this time skip issue so that object detection on M3U8 streams can run in real-time and stably. Thanks for your help