How to decode rtsp video stream of h265 in opencv python
I will use opencv python in Ubuntu 20.04. My ffmpeg can decode the h265 video stream. How do I decode the h265 video stream in python code to play it
OpenCV does not implement codecs by itself, but uses some other library as a backend, e.g. FFmpeg. I'm checking if FFmpeg build distributed with OpenCV has HEVC decoder enabled.
The FFmpeg version that is distributed with OpenCV-Python supports hevc. It's in list of supported codecs. Could you provide more information about the stream? We are looking on FFmpeg update for the next release as option.
The FFmpeg version that is distributed with OpenCV-Python supports hevc. It's in list of supported codecs. Could you provide more information about the stream? We are looking on FFmpeg update for the next release as option.
I use the rtsp h265 code stream of the webcam, the codec: MPEG-H part2/HEVC (h265) (hevc), and the resolution: 1280 * 720.I want to implement this decoding on the arm board
The FFmpeg version that is distributed with OpenCV-Python supports hevc. It's in list of supported codecs. Could you provide more information about the stream? We are looking on FFmpeg update for the next release as option.
I use the rtsp h265 code stream of the webcam, the codec: MPEG-H part2/HEVC (h265) (hevc), and the resolution: 1280 * 720.I want to implement this decoding on the arm board
I don't believe you'll need to specify anything for h265 in python when using opencv - but rather will have to set it up in your camera for the appropriate stream. If using gstreamer or other tools, I believe you have to specify the codec.
In python, you can do the following:
def capture_h265_stream():
image_filename = 'test_file'
camera_username = 'test_user'
camera_password = 'test_pw'
camera_ip = '192.168.0.50'
cap = cv2.VideoCapture(f'rtsp://{camera_username}:{camera_password}@{camera_ip}/streamX')
while cap.isOpened():
ret, frame = cap.read()
if frame is not None:
cv2.imwrite(f"{image_filename}.png", frame)
break
cap.release()
return frame