Hi Admin, i used the Jetson Xavier AGX, opencv-4.5.2 and i has installed gstreamer. I want to capture the youtube video from opencv. I used the youtube-dl to generate the youtube video URI and then feed it in the gstreamer pipeline videoSoure = "souphttpsrc is-live=true location=http_youtube_uri ! qtdemux name=demuxer demuxer. ! queue ! avdec_h264 ! autovideosink" but it seem not work on jetson Xavier.
On x86-64 machine the above gst command work well “gst-launch-1.0 souphttpsrc is-live=true location=”$(youtube-dl --format “best[ext=mp4][protocol=https]” --get-url Madeira | Cinematic FPV - YouTube)" ! qtdemux name=demuxer demuxer. ! queue ! avdec_h264 ! autovideosink"
I also reference into this topic Cant use opencv with backend gstreamer to capture live video youtube on JetsonNX and modified the gstream pipeline as: videoSource = "souphttpsrc is-live=true location=" + http_youtube + " ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink" but still get error
You may use plugin uridecodebin that will manage various formats and codecs.
If the video codec is supported by nvv4l2decoder (such as H264, H265,…), that latter plugin would output into NVMM memory, so you would use nvvidconv for converting into BGRx and output into system memory, and finally use videoconvert for providing BGR frames to opencv:
import cv2
uri="<your_uri>"
gst_pipeline = "uridecodebin uri=%s ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1" % (uri)
cap = cv2.VideoCapture(gst_pipeline, cv2.CAP_GSTREAMER)
if not cap.isOpened():
print('Failed to open source')
exit(-1)
while True:
ret, frame = cap.read()
if not ret:
print('Failed to read from source')
break
cv2.imshow('Test URI', frame)
cv2.waitKey(1)
cap.release()
[quote=“DaneLLL, post:4, topic:217172”]
! h264parse
[/quote]Preformatted text
Hi Daniel, Thank you for answer. i tried 3 above commands with gst-launch-1.0 in AGX but seem it’s not in work. However, the answer of Honey_Patouceul would be the solution. Now I 'm able to capture the youtube URI video.
But for some video with high resolution or video with long duration, the FPS look bad