Raspberry IP Camera in PHP/Bootstrap

  • [font="Helvetica Neue, Helvetica, Arial, sans-serif"]Hi All, just wanted to share a little project of mine, I have built a PHP/Bootstrap web interface for the Raspberry Pi Camera module.[/font]
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]I was looking for a mobile friendly solution which I could easily deploy with a web gui, hence my little project.[/font]
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]If anyone is interested, I have built an image from a foundation Raspbian Jessie minimal image with the web gui and camera module enabled, you can find the image on my github page at the follow url: [/font]http://ronnyvdbr.github.io/RaspberryIPCamera
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]Would love to hear from some test drivers how it works, and if there are any remaining problems which I should fix.[/font]

  • Why your using mjpeg_streamer? Isnt it not really a raw-video streamer?

    Maybe this is better usefull for you: https://github.com/waveform80/pistreaming
    Its really fast and has one of the lowest streaming latency i know.

    And:
    - Im missing a Hint that your install Script installs nginx, and it doesnt check if apache2 is already installed.
    - For the Pi-Camera only 256MB RAM is required
    - Its horrible that you enable www-data User to use sudo for direct >this cmds<! Thats a security hole! Please fix that with e.g. "sudo webscript" and use obfuscated commands


    PS: Please remove google-analytics

  • Hi, thanks for the suggestion, I was already looking into the Python Picamera library's to see how this works.
    At this point i'm using uv4l driver from linux-projects, coupled with mjpg-streamer. I believe with the solution u are suggesting I can discard both of these right?
    Am going out from the assumption that python picam directly accesses the mmal libraries, hence no need for a userspace driver.

    1. In the Raspbain Jessie Minimal image no apache is installed by default... what do u mean by a hint? A warning for people that might have apache installed to avoid interference?
    2. 256 Mb indeed, did I set it to something else?
    3. Was not aware of sudoers issue, looking into this.

    P.S. indeed i'm pulling statistics via google analytics, why is it a problem pls?

    Einmal editiert, zuletzt von ronnyvdbr (17. Februar 2016 um 12:02)


  • 1. In the Raspbain Jessie Minimal image no apache is installed by default... what do u mean by a hint? A warning for people that might have apache installed to avoid interference?

    Yes ;) Or a check in your script, with support for both. Not all will use your Image and maybe they already have installed apache2...

    2. 256 Mb indeed, did I set it to something else?

    My RaspiCam works great with 128MB for the GPU. Your Script sets 256MB - why?

    indeed i'm pulling statistics via google analytics, why is it a problem pls?

    I hate google :D I dont like NSA-like-People and i guess many other users too

  • Zitat

    [font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"]Yes [/font]undefined[font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"] Or a check in your script, with support for both. Not all will use your Image and maybe they already have installed apache2...[/font]

    Ok, check is inserted in the script avoiding nginx install if apache is present.

    Zitat

    [font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"]My RaspiCam works great with 128MB for the GPU. Your Script sets 256MB - why?[/font]

    I guessed at some point that it would be beneficial to give it more memory, but I must admit however I don't have a reference that indicates that more memory will make it run better, so you could call it a hunch.

    Zitat

    [font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"]I hate google [/font]undefined[font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"] I dont like NSA-like-People and i guess many other users too[/font]

    Lol, i'll check if I can insert an exception for you in the code.


    Going further on the obfuscation, is there any ref you can hand out to get started on this?
    I know there is the whole owasp thing, but don't want to crank that into my head just for the purpose of this IP Camera project, isn't there anything simpler to do this safely?
    I reason that all commands executed with shell_exec(); from php will be running under www-data context.
    if I allow this www-data user to run certain sudo commands defined in /etc/sudoers.d, these commands will be elevated to root permissions with sudo, I understand that.

    For example, if I specify below in the sudoers.d folder, then I assume that I can abuse the sed command to modify any file on my server, indeed a big security hole.
    www-data ALL = (root) NOPASSWD: /bin/sed

    A possible solution is to make a shell script which I can call with shell_exec(); from php, the shell script should take some parameters and execute the sed command with these parameters.
    What is written in the shell script is obfuscated so it can't be reverse engineered and hence difficult to abuse ... or am I misunderstanding the whole setup here?

    Einmal editiert, zuletzt von ronnyvdbr (17. Februar 2016 um 13:39)

  • Zitat

    [font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"]Maybe this is better usefull for you: [/font]https://github.com/waveform80/pistreaming
    [font="Source Sans Pro, Tahoma, Helvetica Neue, Arial, sans-serif"]Its really fast and has one of the lowest streaming latency i know.[/font]

    I just have read up on your solution.
    If I understand correctly, you are capturing raw unencoded yuv data from the Pi's camera module and transcode that with ffmpeg to MPEG1 format to serve it up via python websockets to some javascript player.
    It sounds so complex, can u tell me where U see the benefit over just using mjpeg?
    The UV4L2 drivers which I'm using are connecting all the building blocks together to perform GPU assisted encoding to MJPEG, serving that via the network is the work of the mjpeg-server, which is written in C, pretty darn fast if u ask me.
    Maybe I fail to see the benefit.

  • Cool, just a couple of things. Why are you using mjpeg-streamer given that UV4L already provides a faster MJPEG streaming server. Another thing is if it would be possible to use UV4L get the stream in H264 directly, as UV4L allows up to Full HD H264 encoded in hardware with <~200 latency.


  • Cool, just a couple of things. Why are you using mjpeg-streamer given that UV4L already provides a faster MJPEG streaming server. Another thing is if it would be possible to use UV4L get the stream in H264 directly, as UV4L allows up to Full HD H264 encoded in hardware with <~200 latency.


    Well, I'm mainly developing this solution to be compatible with the nas which I have.
    I'm running a synology nas with surveillance station software.
    For some reason I don't know, the uv4l included mjpeg server doesn't work with this surveillance software, hence the separate implementation which does work together with this software.
    H264 is on my list to implement next, but I still have to figure out how to display that stream on my Web page.
    Linux projects has a Web rtc component which seems to be able to do it, still need to figure it out though.

  • Strange, I once embed the URL for raw MJPEG stream and worked fine - the raw URL is mentioned in their example #11:
    http://www.linux-projects.org/modules/sectio…id=16#example11
    it can optionally be encrypted HTTPS instead of unsecure HTTP.

    With webrtc it is usually a matter of javascript code running in the browser to show the stream without plugins, it should be possible to use UV4L as backend in this case and provide your custom pages to the users.

  • Yes, I would like to use it instead of my own solution since it's from the same software developer and probably is more tuned to work with it's own uv4l driver.
    Unfortunately it doesn't work in my synology surveillance station.

    Upon adding the camera it verifies ok, but no image is displayed.

    SurveillanceStationError1.PNG?dl=0

    Once added, it is shown as disabled.

    SurveillanceStationError2.PNG?dl=0

    And the notification center gives me the message that it's disconnected.

    SurveillanceStationError3.PNG?dl=0

    I don't have the same problem with the other mjpeg-server which I'm currently using.


    Going from the configuration files which I have on my synology nas in surveillance station, a lot of parameters can be changed and the pre-defined camera's also seem to use some kind of api.

    looking into what's wrong for this does look to me like searching for a needle in a haystack.

    example:

    [D-Link*DCS-2121]
    api = dlinknipca
    resolutions_mjpeg = 160x120,256x192,320x240,512x384,640x480,1024x768,1280x1024
    resolutions_mpeg4 = 160x120,256x192,320x240,512x384,640x480,1024x768
    fps_mjpeg_[160x120,320x240,640x480] = 1-3,5,10,15,30
    fps_mjpeg_[256x192,512x384,1024x768,1280x1024] = 1-3,5,10
    fps_mpeg4_[160x120,320x240,640x480] = 1-3,5,10,15,30
    fps_mpeg4_[256x192,512x384,1024x768] = 1-3,5,10
    default_fps_mjpeg_[160x120,256x192,320x240,512x384,640x480] = 10
    default_fps_mjpeg_[1024x768,1280x1024] = 5
    default_fps_mpeg4_[160x120,256x192,320x240,512x384,640x480] = 10
    default_fps_mpeg4_[1024x768] = 5
    default_image_quality = 5
    mjpeg = http
    mpeg4 = rtsp
    motion = mjpeg,mpeg4
    motion_param = sensitivity
    audio_format = PCM
    alarm_input = 1
    alarm_output = 1
    activate_time = 80
    camera_parameters = yes
    ntp_server = Surveillance Station,ntp1.dlink.com,ntp.dlink.com.tw,disable
    video_mirror = yes
    video_flip = yes
    default_username = admin
    rtsp_protocol = auto,udp,tcp

    Einmal editiert, zuletzt von ronnyvdbr (17. Februar 2016 um 22:01)

  • I cannot test Synology at the moment. But, as a first guess, it may be a problem with resolutions. Unless specified otherwise, the default resolution with UV4L and the raspicam is 1920x1080 for mjpeg. I'd try a smaller res e.g. 640x480 and see if it works...

    from the uv4l-server manual. there's also --chuncked-transfer-encoding, which is on by def. and seems to affect the mjpeg streaming.

    Einmal editiert, zuletzt von MartinDart (18. Februar 2016 um 00:52)


  • I cannot test Synology at the moment. But, as a first guess, it may be a problem with resolutions. Unless specified otherwise, the default resolution with UV4L and the raspicam is 1920x1080 for mjpeg. I'd try a smaller res e.g. 640x480 and see if it works...

    from the uv4l-server manual. there's also --chuncked-transfer-encoding, which is on by def. and seems to affect the mjpeg streaming.


    Wonderful, changing the chuncked-transfer-encoding parameter to false apparently did the trick. Thanks for the suggestion, apparently I am now able to view the camera on my synology station without any hassle.

    This puts my little Web interface project in another prerequisite perspective.
    Am going to test this and if working better switch to this native server.
    Automatisch zusammengefügt:


    Wonderful, changing the chuncked-transfer-encoding parameter to false apparently did the trick. Thanks for the suggestion, apparently I am now able to view the camera on my synology station without any hassle.

    This puts my little Web interface project in another prerequisite perspective.
    Am going to test this and if working better switch to this native server.


    The only problem mjpeg streaming is the required bandwidth.
    If u have multiple of these devices in high resolution/fps mode, it quickly saturates my network.

    The server apparently also supports H264 encoding, but when trying to add that as a camera, I am unsuccessful.
    According to the synology surveillance manual, H264 is only supported via RTSP over tcp udp or http.
    Linux projects uv4l server doesn't support RTSP signalling unfortunately ...
    For this purpose I still need to use a separate solution, https://github.com/mpromonet/h264_v4l2_rtspserver
    Michel Promoneth's RTSP server to capture the H264 stream from the UV4L driver and serve that to my nas over RTSP.

    Do u happen to know other solutions that are capable of serving up RTSP which are not based on the lib555 media lib?

    Einmal editiert, zuletzt von ronnyvdbr (18. Februar 2016 um 10:21)

  • UV4L supports H264 over http or https fine (i.e. I can get decode the H264 stream from my https UV4l-based server (with user/password authentication on) with VLC). With regard to "pure" RTSP, I am not aware of any alternatives..

  • [font="Helvetica Neue, Helvetica, Arial, sans-serif"]Hi, please note that I just uploaded beta 4 on direct download at: [/font]http://ronnyvdbr.github.io/RaspberryIPCamera/

    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]Another few bugs are now fixed, and the download is now presented as a net-installer which is small in download size. (only 32 mb)[/font]
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]Using the net-installer, it will take around 15 mins to build the raspberry camera, the process is completely unattended.[/font]
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]Just download the net installer, unzip and write to SD card with win32diskimager, after that, boot your pi and wait.[/font]
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]On completion, the web interface is available on port 80 of your pi, [/font]http://my-pi-ip-address/
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]username admin[/font]
    [font="Helvetica Neue, Helvetica, Arial, sans-serif"]password raspberry[/font]

  • Hi all, version 1.6 is now ready for download at http://ronnyvdbr.github.io/RaspberryIPCamera/
    The whole setup is now changed, making the Raspbian Jessie Minimal OS read only, to contribute to stability, and prevent wearing off the sd card. Making changes is possible if you remount the root read-write.
    The system had a security update, closing some unprotected parts of the uv4l server which shouldn't be accessible.
    Some restyling has been done on the web interface, making it a bit more friendly to look at.
    As always, reports about bugs or any other feedback is welcome

Jetzt mitmachen!

Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!