I’m working on a project where I need to read an Internet video stream. I have the URL needed to connect to the IP camera. The camera administrator tells me that I can use either HTTP or RTSP (Real Time Streaming Protocol) to access the camera. I have no familiarity with HTTP, but I know there’s a HTTP.jl package available.
Can VideoIO.jl be used to read such a video stream, maybe with the help of HTTP.jl?
VideoIO supports reading from rtsp streams directly.
using VideoIO
using Plots
function play_video(url)
strm = VideoIO.openvideo(url)
img = read(strm)
fig = plot(img)
while !eof(strm)
read!(strm, img)
plot!(fig, img)
display(fig)
end
end
play_video("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov")
It would be very nice if the docs above had another example where the frames are read from an RTSP stream instead of a file. Or maybe that’s kind of obvious for people familiar with the area…
Works over http as well. This is the code for esp32-cam:
using VideoIO
using GLMakie
url = "http://192.168.1.8:81/stream" # replace to "http://192.168.x.x:81/stream", the ip of your camera
strm = VideoIO.openvideo(url)
img = read(strm)
fig, ax, plot_obj = image(img', interpolate=false, axis=(yreversed=true, ))
display(fig)
while !eof(strm)
read!(strm, img)
plot_obj[1] = img'
sleep(0.001)
end