I am using libVLC with python in my Raspberry Pi 3 B and getting RTSP stream. I also want to process every frame in stream then save processed frames as video file. I worked with OpenCV before. So I know how to process frames and how to save as video file. Bu I don't know how to get frames from VLC for process.
Code: Select all
rtsp_server = 'rtsp://[IP_OF_CAMERA]/...'
i = vlc.Instance("--vout=dummy --sout-mux-caching=<>")
player = i.media_player_new()
player.set_mrl(rtsp_server)
player = vlc.MediaPlayer(rtsp_server)
player.play()
Code: Select all
while True:
player.video_take_snapshot(0, '/home/pi/Desktop/snapshot1.png', 0, 0)
frame = cv2.imread('/home/pi/Desktop/snapshot1.png', 0)
if frame is None:
cap.release()
print("NO FRAME")
break
cap.write(frame)
cv2.imshow('Camera1', frame)
if (cv2.waitKey(10) & 0xFF) == 27: #esc key ends process
cap.release()
break
cv2.destroyAllWindows()
player.stop()
I tried to get RTSP stream with OpenCV but I couldn't. I tried to get frames from VLC with callbacks or functions but I couldn't that either.
Do you know anything how to get frame for OpenCV? Or have any idea?
Thanks