Beginner Tutorial: How to Stream Video from Raspberry Pi Camera to Local Computer using Python (P1)

Поділитися
Вставка
  • Опубліковано 28 січ 2025

КОМЕНТАРІ • 124

  • @mmshilleh
    @mmshilleh  9 місяців тому +2

    If this video saved you time or you learned something, please Subscribe to the channel. Every subscription means I can continue making more informative and better videos for the community, thank you all!

  • @Brahim-hx1vr
    @Brahim-hx1vr 10 місяців тому +3

    hello what version of os do you use pls ?

    • @mmshilleh
      @mmshilleh  10 місяців тому

      Great question
      PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
      Hope you subscribe ;)

    • @josephcro2138
      @josephcro2138 3 місяці тому

      @@mmshilleh this doesn't work on bookworm

    • @mmshilleh
      @mmshilleh  3 місяці тому

      @@josephcro2138 i have another video my friend watch the series :)

  • @yadumohandnair6783
    @yadumohandnair6783 3 місяці тому +1

    i am facing an issue over here @2:54. i am not able see any inteface for camera (but, it does show other interfaces like SSH, I2C, Raspberry pi connect, SPI, etc), i use raspberry pi 4B.

    • @mmshilleh
      @mmshilleh  3 місяці тому

      Check out my latest camera videos this is outdated I have one on picamera2 that works better

    • @yadumohandnair6783
      @yadumohandnair6783 2 місяці тому

      I can't find that video, what is the video title??

  • @RanugaWijesingha
    @RanugaWijesingha 24 дні тому +1

    Hello can we use this method for facial recognition

    • @mmshilleh
      @mmshilleh  23 дні тому

      Yes it can. You would need to add an ML layer on top though

  • @joethehoe8839
    @joethehoe8839 10 місяців тому +1

    Great video thanks for giving information about the code being used in it, most videos dont explain what the code is actually doing but you do a great job !

    • @mmshilleh
      @mmshilleh  10 місяців тому +1

      Glad it helped! Yeah unfortunately there is a tradeoff between going into detail and people's attention spans haha, so I am very glad I am in the goldilocks zone for this one :)

  • @ikponmwosai.k.evbayiro1771
    @ikponmwosai.k.evbayiro1771 11 місяців тому +1

    Hello, I'm trying to do this same thing with a USB Camera module, is there any edits you suggest to this prcess?

    • @mmshilleh
      @mmshilleh  11 місяців тому

      Hey buddy never used that module not sure, to be honest. Goodluck mate :)

  • @İleriDurmaz
    @İleriDurmaz Місяць тому +1

    How can we stream over the ethernet cable instead of internet? Do you have any source?

    • @mmshilleh
      @mmshilleh  Місяць тому

      I have never tried that but as long as there is an active connection I dont see why that is impossible.

    • @İleriDurmaz
      @İleriDurmaz Місяць тому +1

      @@mmshilleh I think so, but I have another problem. My raspberry's operating system is Ubuntu 22.04 and I can't use the picamera library. Do you have any recommendation?

    • @mmshilleh
      @mmshilleh  Місяць тому

      @@İleriDurmaz Not at the top of my head my friend.

  • @haroldbarner6865
    @haroldbarner6865 10 місяців тому +1

    Great video! I just have one issue. When I enter the inet address into my computer, it starts a download instead of a stream. When I stop/cancel the download, it automatically restarts in a couple of minutes.

    • @mmshilleh
      @mmshilleh  10 місяців тому +1

      Very weird no idea here, that should not happen if you are using the same code... sorry fam

    • @haroldbarner6865
      @haroldbarner6865 10 місяців тому +1

      Thank you, I appreciate it. Maybe some browser/firewall settings. 🤷🏽‍♂️

  • @bahandsrandomthings
    @bahandsrandomthings 23 дні тому +1

    Hello, I am having an issue when running the python code. I used a venv to install the packages, and when I run the python code, I get the error message on line 2 that there is no module named picamera. This it the 4th video I have watched on this topic, and the only one to make it this far. I would really appreciate if someone could help me out with the problem I am having.

    • @mmshilleh
      @mmshilleh  23 дні тому

      You need to use picamera2. I have a video on that

    • @bahandsrandomthings
      @bahandsrandomthings 23 дні тому

      @@mmshilleh Thanks! I really appreciate it. I will get my project working inshaAllah.

  • @EsotericArctos
    @EsotericArctos 10 місяців тому +2

    Can this be done with the new Camera-Streamer (libcamera) instead of the legacy camera, which is going to be removed soon?

    • @mmshilleh
      @mmshilleh  10 місяців тому

      Hey sorry might get one soon, never tried that yet!

    • @MattMascolo.
      @MattMascolo. 10 місяців тому

      Got this working with libcamera.
      Used libcamera and ffmpeg to create a m3u8 stream
      then flask and hls-js to have the stream show on the webpage.
      Good luck!
      It's also possible to do with python3-tornado and websockets but that was a little complex for me.

    • @ajitgupta1530
      @ajitgupta1530 9 місяців тому

      @@MattMascolo. Hey can you please share your code of libcamera
      Thanks

    • @bungle6334
      @bungle6334 8 місяців тому

      On OS version 'bookworm', the option does appear to have been removed.

    • @MattMascolo.
      @MattMascolo. 8 місяців тому

      @@ajitgupta1530 just now seeing this, I'll boot it up and get the code this evening into a GitHub.

  • @STMONDEO1
    @STMONDEO1 6 місяців тому +1

    Hi Shilleh
    solved the problem with line5.
    The other problem i have is when i put the ip address of the pi into a web browser it says cannot connect.
    The pi and pc are on the same network.

    • @mmshilleh
      @mmshilleh  6 місяців тому

      Hmmm did you mess around with any firewall settings? Are you seeing any python logs on the Raspberry Pi side?

    • @STMONDEO1
      @STMONDEO1 6 місяців тому

      @@mmshilleh Hi i have not messed around with any firewall. How do i check python logs.

  • @LaserGrunt
    @LaserGrunt Рік тому +1

    Can you do a setup that does video and 2 way audio ?

    • @mmshilleh
      @mmshilleh  Рік тому

      Dont have that in the pipeline but I will definitely take note buddy!

  • @danielsher5439
    @danielsher5439 10 місяців тому +1

    Tried doing this with a pi zero2w, can't get it to work. Script by lutz channel works but not using flask, which I would prefer. When loading the webpage, it never actually loads.

    • @mmshilleh
      @mmshilleh  10 місяців тому

      Sorry to hear that, yeah there are so many cameras and OS's and potential issues that can go wrong here. I leave it up to the viewer to debug any edge cases to be frank

  • @vikramgogoi3621
    @vikramgogoi3621 6 місяців тому +1

    Do we need internet connection? Both devices just have on be on the same network, right?

    • @mmshilleh
      @mmshilleh  6 місяців тому +1

      They do, but you can use a tailscale to do this externally

    • @vikramgogoi3621
      @vikramgogoi3621 6 місяців тому

      @@mmshilleh Thank you

  • @AngelaLaCreatrice
    @AngelaLaCreatrice 9 місяців тому +1

    What is that software that you used to create in the Python script?

    • @mmshilleh
      @mmshilleh  9 місяців тому

      Are you referring to Flask? Flask is a framework/library in Python that allows you to host something called a web server. A web server is a basic building block of web applications.

  • @highroyds
    @highroyds 10 місяців тому +1

    Hi, Tried this on bullseye and worked perfectly, but when I tried with bookworm I couldnt get it to work at all. The pip commands dont work btw, but the script doesnt work with stating theres no module.

    • @mmshilleh
      @mmshilleh  10 місяців тому

      Sorry to hear about the trouble with Bookworm. Here are a few suggestions:
      Check Python & pip Versions: Use python3 --version and pip3 --version to ensure you're using the correct versions. Debian Bookworm might have updated defaults.
      Install/Update pip: If pip isn't working, try sudo apt-get install python3-pip to install or update pip for Python 3.
      Use a Virtual Environment: This can help manage dependencies. Create one with python3 -m venv myenv and activate it using source myenv/bin/activate.
      Install Missing Modules: Ensure all required modules are installed within the environment, e.g., pip install numpy for the numpy module.
      Permissions & $PATH: Check your permissions and ensure your $PATH includes Python and pip locations. Sometimes sudo or adjusting $PATH can resolve issues.
      If these steps don't help, consider checking Debian and Raspberry Pi documentation or community forums for specific advice on Bookworm.

    • @RossPotts
      @RossPotts 10 місяців тому

      By any chance were you using a non-branded (raspberry pi) camera? I could not get mine to work on bookworm until I got a branded camera and cable. I also fell down a rabbit hole on the raspy forums where it seems branded cables are cross-overs. It was a combo for me: camera and cable.

    • @highroyds
      @highroyds 10 місяців тому

      @@RossPotts yes, it’s an arducam 5 mb camera. I did get it to work on another app perfectly that I got from GitHub

  • @RemyAngelle
    @RemyAngelle 8 місяців тому +1

    what operating system are you using?

  • @denigajah6369
    @denigajah6369 7 місяців тому +1

    Great video. im wondering if you could tell me what os of raspberry are you using in this video? im having trouble finding turning on legacy camera option in my OS, it doesnt have any. Should i install legacy OS system? or something elses. aslo there are many error in the code which said that there is no such file or directory for the picamera, so from there i figure that it might have something to do with OS differences.
    If you could reply to this quick i would greatly appreciate it because i need it for my final university project which is due soon

    • @mmshilleh
      @mmshilleh  7 місяців тому

      PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"

  • @gyaanipakiya1889
    @gyaanipakiya1889 9 місяців тому +1

    I'm using Pixy Cam 2 as the camera, what I've to do for this?

    • @mmshilleh
      @mmshilleh  9 місяців тому

      I have another video on that, can you try it?

  • @thanhchung9133
    @thanhchung9133 7 місяців тому +1

    Can i use the webcam for this project ?

    • @mmshilleh
      @mmshilleh  7 місяців тому

      You can as long as it connects to the Pi with USB

    • @thanhchung9133
      @thanhchung9133 7 місяців тому +1

      ​@@mmshilleh Thank you so much!

  • @james1760
    @james1760 10 місяців тому +1

    Well made video, very helpful!

    • @mmshilleh
      @mmshilleh  10 місяців тому +1

      Thank you again pal! Hope you subscribe :)

  • @HoiPolloi
    @HoiPolloi 7 місяців тому +1

    Which OS version are you using?

  • @tiennguyen4025
    @tiennguyen4025 9 місяців тому +1

    Hi Sir, I am doing the exact same project at school, I notice errors when importing picamera in the python file, it was related to my RaspbianOS build being 64-bit instead of 32-bit, I just want to know if your RaspbianOS is 32-bit ?

    • @mmshilleh
      @mmshilleh  9 місяців тому

      Not sure will need to check sometime, I am on vacation :(

    • @denigajah6369
      @denigajah6369 7 місяців тому

      @@mmshilleh any news on what os u using great guy?

  • @RizGaming1
    @RizGaming1 6 місяців тому +1

    i cannot see the legacy camera enable option in interface, while libcamera-still command is showing that my camera v2 is working, can anyone guide in this regard

    • @mmshilleh
      @mmshilleh  6 місяців тому

      Perhaps you have a newer OS

    • @RizGaming1
      @RizGaming1 6 місяців тому

      @@mmshilleh yes i got it, i installed the old version now everything works fine.

    • @sukasinikesavan9505
      @sukasinikesavan9505 3 місяці тому

      Did you get it finally?

  • @swastikdey7498
    @swastikdey7498 9 місяців тому +1

    Hello, thanks for the video guide. I faced some errors, which is, when I am typing the ip address followed by port number and video feed, my local computer shows me INTERNAL SERVER Error, and the raspberry pi display also show some different type of exception.

    • @mmshilleh
      @mmshilleh  9 місяців тому

      Hard to debug that without specifics my friend

  • @STMONDEO1
    @STMONDEO1 6 місяців тому +1

    Hi please can you tell me why i get a error message on Line 5.
    about (name).
    I have checked ever bit of your code but when i try to run the program it keeps saying (ERROR) Line 5 (name)

    • @mmshilleh
      @mmshilleh  6 місяців тому

      A lot of this depends on your OS and Python Version, hard to say!

    • @STMONDEO1
      @STMONDEO1 6 місяців тому

      @@mmshilleh What version of OS are you using.

  • @dabunnisher29
    @dabunnisher29 Рік тому +2

    Great video man.

    • @mmshilleh
      @mmshilleh  Рік тому

      Hey thank alot I appreciate it :) yeah cameras are cool

  • @logeinn_3396
    @logeinn_3396 7 місяців тому +1

    do I have to use bullseye os I am using raspberry pi 4 ubuntu linux os, Thonny ide and it is not working, do you have a solution and thank you

    • @mmshilleh
      @mmshilleh  7 місяців тому

      Idk, hard to tell

  • @klauslomas
    @klauslomas 5 місяців тому +1

    Good video! At what resolution and fps do you stream? What version of Raspberry Pi are you using? Thank you

    • @mmshilleh
      @mmshilleh  5 місяців тому

      Using a Raspberry Pi 4b and tbh I have not played around with the resolution too much or FPS.
      I kept it low because it can be kind of slow :/ Hope that helps! Don't forget to subscribe that would be great!!!

  • @OverAndOverAndOver
    @OverAndOverAndOver 9 місяців тому +1

    Dawg, this is EXACTLY what I have been looking for for SO LONG!!!
    The code is mad simple and self explanatory, I really appreciate this man... I'm a bit of a newbie when it comes to coding systems like this that directly interface with IO on a non-windows based machine, is there a means of using a USB camera on this to stream from the Pi, like a Logitech WebCam or similar as the "PiCamera" in question, or does the "PiCamera" package allow this code to be so small with the ease of "camera.resolution" "camera.framerate" and "capture.continous"?

    • @mmshilleh
      @mmshilleh  9 місяців тому +1

      I have another video where I utilized a USB camera, go ahead and watch that. Hopefully, it works for you. Don't forget to subscribe that's all I ask ;)

    • @OverAndOverAndOver
      @OverAndOverAndOver 9 місяців тому +1

      @@mmshilleh Don't worry, I subscribed after this video!
      I've seen that one, and it helped me substantially! Thank you again for these!
      Do you know of any other packages except for OpenCV that have this video capture functionality? I'm trying to package all dependencies for this little test application I'm making into itself so that I don't have to install separate packages while I'm installing the application I'm crafting

    • @mmshilleh
      @mmshilleh  9 місяців тому +1

      @@OverAndOverAndOver Honestly you could probably use some native python packages to save the image but it would be more complicated and you would have to get crafty on the bytes level. Python's standard library doesn't provide built-in functionality for capturing video from cameras hence why opencv makes it super easy to do so in one line of code

  • @noumanahmedkhan8630
    @noumanahmedkhan8630 11 місяців тому +1

    Legacy camera option not available in my pi 4 why?? Please help

    • @mmshilleh
      @mmshilleh  11 місяців тому

      Check Raspberry Pi OS Version: Ensure your Raspberry Pi OS is up to date. The legacy camera support might require specific versions of the OS.

    • @noumanahmedkhan8630
      @noumanahmedkhan8630 11 місяців тому

      @@mmshilleh I have desbian bookworms that has auto detect camera feature enable but I am getting no camera.... In 32 bit os my noir camera v2 working fine but in 64 bit os no camera available please help

    • @Emrose_Green
      @Emrose_Green 10 місяців тому

      If you are using Bookworm then legacy camera support is no longer supported, but if you switch to Bullseye then it should have legacy camera support. There are some tradeoffs when doing this switch, but if you really need it then go for it, otherwise you could try using a branded camera and cable that works with the Raspberry Pi. I am using an OV5647 5MP 1080P Arducam which I have found needs legacy camera support.

    • @sukasinikesavan9505
      @sukasinikesavan9505 3 місяці тому

      Same, what to do next?

  • @STMONDEO1
    @STMONDEO1 6 місяців тому +1

    @STMONDEO1
    5 days ago
    Hi Shilleh
    Do i need to port forward this raspberry pi for me to view this camera.

    • @mmshilleh
      @mmshilleh  6 місяців тому

      if its from an external IP address you have to yes

    • @STMONDEO1
      @STMONDEO1 6 місяців тому

      @@mmshilleh Hi i have tried every thing but still no joy.
      I can view the Raspberry pi through VNC with my PC no problem. So i no they are both on the same Network.
      But for some reason i cannot view the camera over the internet.

  • @jericojermy6243
    @jericojermy6243 Місяць тому

    If both are in the same network, do we really need internet?

    • @mmshilleh
      @mmshilleh  Місяць тому

      You do or else you cant connect to the network

  • @NatureCam2024
    @NatureCam2024 10 місяців тому +1

    Great video, thanks a lot!! Could you give advice what to change when using the latest picamera2 library? Especially how to replace the capture.continuous attribute?

    • @mmshilleh
      @mmshilleh  10 місяців тому +2

      I would have to check for you buddy, I havent played with that camera in a couple weeks! Never used that library. I am gonna make a part 3 soon so hopefully I remind myself to look into this question. I will add a note ;)

    • @NatureCam2024
      @NatureCam2024 10 місяців тому

      Awesome, looking forward to part three! Maybe streaming by using the picamera2 library is interesting for the community. The picamera library seems not to be supported anymore for latest OS - at least that is my understanding as a beginner… but please correct me :)

    • @jaxjax7318
      @jaxjax7318 6 місяців тому

      @@mmshilleh @danielg1165 Cant wait to get this running on picamera2 with wide noir

  • @Jun-zq3bn
    @Jun-zq3bn 7 місяців тому +1

    followed the tutorial but i got:
    OSError: libmmal.so: cannot open shared object file: No such file or directory
    what should i do?

    • @mmshilleh
      @mmshilleh  7 місяців тому

      Make sure you update apt and redownload all of your packages
      sudo apt-get update

    • @Jun-zq3bn
      @Jun-zq3bn 7 місяців тому

      @@mmshilleh tried that but to no avail. even tried reinstalling the os. any workarounds?

    • @mmshilleh
      @mmshilleh  7 місяців тому

      ​@@Jun-zq3bn Hard to say without me having access to your OS tbh! You can always consult with me on buymeacoffee link but otherwise you will have to debug yourself. I have not seen this error before.

    • @AkshatGandhi-re3sz
      @AkshatGandhi-re3sz 4 місяці тому

      @@Jun-zq3bn bro did you got any solution??

    • @Jun-zq3bn
      @Jun-zq3bn 4 місяці тому

      @@AkshatGandhi-re3sz I solved it a while back but no longer have the source code sorry bro

  • @skd69
    @skd69 3 місяці тому +2

    Hey man I have got. A problem .My raspi pi zero 2w doesn't have any option to enable the raspi camera but if I use open cv to stream on the pi itself sometimes it works (mostly) but I am unable to get this code running

    • @mmshilleh
      @mmshilleh  3 місяці тому

      Too vague for me to help :/

    • @albunker4578
      @albunker4578 Місяць тому +1

      I ran into the same issue recently. I believe it is a change in the rasbian operating system, not with the pi zero, as I had the same issue on my pi 5. you shouldn't have an issue if you are using a raspberry pi brand camera model. I used the v3 and didn't have any issues. If you end up needing to enable legacy support then there are tutorials for it on the new OS I found them a few weeks ago but I don't have them in my history anymore

    • @johnborg305
      @johnborg305 10 днів тому

      ​@mmshilleh the newer os in raspi config there is no enable camera setting.

  • @ahmetsasa5644
    @ahmetsasa5644 Місяць тому +1

    I'd like to ask a question to you. How can i get the camera frames from wifi which is created by raspberry pi ? How can i create wifi protocol from raspberry pi? btw thanks for the video

    • @mmshilleh
      @mmshilleh  Місяць тому

      Ahmet thank you but your question is beyond the scope of a comment.

    • @ahmetsasa5644
      @ahmetsasa5644 Місяць тому

      @@mmshilleh okay than what do you suggest about that getting the live video from 2kilometers away?

  • @SojisWorld
    @SojisWorld 4 місяці тому +1

    Does this work via ethernet?

    • @mmshilleh
      @mmshilleh  4 місяці тому

      Yes it does but I think it uses a different IP Address

  • @anupr3592
    @anupr3592 10 місяців тому +1

    When is the next part coming ?

    • @mmshilleh
      @mmshilleh  10 місяців тому

      Soon my friend, soon

    • @anupr3592
      @anupr3592 10 місяців тому

      @@mmshilleh Thank you man.

  • @tristanwheeler2300
    @tristanwheeler2300 3 місяці тому +1

    raspberry pi doesnt like it when you install libraries to your main python install now

    • @mmshilleh
      @mmshilleh  3 місяці тому

      @@tristanwheeler2300 yeah you need a venv

  • @mattkojetin8198
    @mattkojetin8198 Рік тому +1

    Very nice! Thank you!

  • @mattkojetin8198
    @mattkojetin8198 Рік тому +1

    I'm going to use that idea for a parking camera.

    • @mmshilleh
      @mmshilleh  Рік тому +1

      That is a solid idea. First thought to me is I am wondering how much power it consumes

  • @matthewtscott1
    @matthewtscott1 2 місяці тому +1

    Raspberry pi OS is based on Debian Bookworm this is the latests, it hasn't been called Raspian since Debian Stretch was replaced with Debian Buster ( raspberry pi OS) in 2020....... this may not work as bookworm has a new camera pipeline

    • @mmshilleh
      @mmshilleh  2 місяці тому

      @@matthewtscott1 yes i have another tutorial on the new one. Look at my channel!!! I wish i could funnel everyone to the next video easier

  • @RemyAngelle
    @RemyAngelle 8 місяців тому +1

    is this bullseye or buster?