Problem when i use Opencv-python with pipeline Gstreamer to accelerate stream video.mp4 file

Hello,

i try to stream video.mp4 file from opencv-python by using Gstream pipeline. but when i run the pipeline in terminal it 's work successful. my problem is when i try to read a video file by Opencv + pipeline:
-My configuration is: jetson Xavier, jetpack 4.4, Opencv-python V4.5. gst-launch-1.0.

This pipeline is work :

gst-launch-1.0 filesrc location=video.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h264parse ! omxh264dec ! nvoverlaysink -e

But when i run this follow program i have in result any stream but just message “empty frame”:

import cv2
def _gst_cap_pipeline():
return “filesrc location=video.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h264parse ! omxh264dec ! appsink sync=false”

source = cv2.VideoCapture(_gst_cap_pipeline(), cv2.CAP_GSTREAMER)

while True:
ret, frame = source.read()
if not ret:
print(‘empty frame’)
break
cv2.imshow(‘send’, frame)
if cv2.waitKey(1)&0xFF == ord(‘q’):
break

Please, anyone can help me to solve the problem !! .

For jetson issues , you may better start the topic and get help here Jetson & Embedded Systems - NVIDIA Developer Forums .

1 Like

Oki, thanks you