# Reading video stream from IP camera

**URL:** <https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782>\
**Category:** General Usage\
**Tags:** videoio\
**Created:** [July 27, 2020, 6:10pm UTC](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782 "2020-07-27T18:10:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)\
**Post date:** [July 27, 2020, 6:10pm UTC](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782/1 "2020-07-27T18:10:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [July 28, 2020, 12:02am UTC](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782/2 "2020-07-28T00:02:38Z")

</div>

`VideoIO` supports reading from rtsp streams directly.

```julia
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")

```

---

<div class="post-metadata">

**Author:** ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)\
**Post date:** [July 28, 2020, 1:34am UTC](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782/3 "2020-07-28T01:34:53Z")

</div>

I tested this with my URL and it indeed works! Thank you so much.

I was so close. This is basically the same code as the first example in “Reading Video Files” in VideoIO.jl’s documentation:

[https://juliaio.github.io/VideoIO.jl/stable/reading/#Reading-Video-Files-1](https://juliaio.github.io/VideoIO.jl/stable/reading/#Reading-Video-Files-1)

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…

Thanks again.

---

<div class="post-metadata">

**Author:** ![mariusd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mariusd/32/23231_2.png) [@mariusd](https://discourse.julialang.org/u/mariusd)\
**Post date:** [December 23, 2022, 6:41pm UTC](https://discourse.julialang.org/t/reading-video-stream-from-ip-camera/43782/4 "2022-12-23T18:41:52Z")

</div>

Works over http as well. This is the code for esp32-cam:

```julia
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

```
