billw2 / pikrellcam

Raspberry Pi motion vector detection program with OSD web interface.
GNU General Public License v3.0
261 stars 70 forks source link

add MJPEG TCP streaming server #7

Closed codomania closed 8 years ago

codomania commented 8 years ago

Hi, I was looking for a possible light weighted IP netcam for my home project and wrote a simple v4l2 based MJPEG streaming (https://github.com/codomania/raspberry-pi-netcam) which was working okay for me but then ran across your project on raspberry forum and liked it. One of my requirement was to stream the camera directly to my phone apps (instead of browser). I have extended pikrellcam to stream MJPEG from port 8081. With these changes I was able to stream the video just fine on my andriod and iphone device. I was wondering if you are interested in this commit. I can cleanup if needed. I am mainly using webbrowser interface to see the motion recording and other stuff but while I am away from home then I use Andriod tinycam app (free version) to view the live stream.

Thanks Brijesh

billw2 commented 8 years ago

Hi, I took a look at the commit and it looks good. I'm definitely interested in merging it, but you have caught me as I'm just now packing up for a short trip and it may be a day or two before I can get to it.

Thanks, Bill

codomania commented 8 years ago

Hi Bill,

no rush to merge it, since you are interested in the commit hence i will go ahead and cleanup a bit and add options in installer etc. You can take a look once you are back from vacation and then we can discuss about pulling the commit.

Thanks Brijesh

billw2 commented 8 years ago

On Mon, 21 Dec 2015 08:09:40 -0800 Brijesh Singh notifications@github.com wrote:

Hi Bill,

no rush to merge it, since you are interested in the commit hence i will go ahead and cleanup a bit and add options in installer etc. You can take a look once you are back from vacation and then we can discuss about pulling the commit.

Thanks Brijesh

Whenever you are ready, go ahead and let me know and I can get it merged.

Bill

codomania commented 8 years ago

Hi Bill, Code is ready for merge. I have cleaned it up and now instead of client directly opening the socket i have introduced a php script which opens the socket and performs the read. This will also enable use to use webserver features like authentication, timeout etc. So for I have tested the code in my setup and it seems to be working fine. I can stream the live MJPEG using tinycam monitor free version app on Andriod device. Let me know if you have any questions.

Thanks Brijesh

Yves911 commented 8 years ago

@codomania : hi, thanks for the patch, i am trying to use it but unfortunately i get a connection refused from the other machines on LAN. From the raspberry itself: all is fine from another machine on the same LAN it's a fail.

>>netstat -plntu
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:52235           0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:9999          0.0.0.0:*               LISTEN      13529/pikrellcam
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -   

Is there a possibility make the daemon listen on 0.0.0.0 instead of 127.0.0.1?

codomania commented 8 years ago

Sure try this commit and if it works then we can request Bill to pull this.

https://github.com/codomania/pikrellcam/commit/c01da6e7c6de53adaf0c27bebaf3af5bc824b756

On Thu, Dec 24, 2015 at 9:06 AM, Yves911 notifications@github.com wrote:

@codomania https://github.com/codomania : hi, thanks for the patch, i am trying to use it but unfortunately i get a connection refused from the other machines on LAN. From the raspberry itself: all is fine from another machine on the same LAN it's a fail.

netstat -plntu Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:52235 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:9999 0.0.0.0:* LISTEN 13529/pikrellcam tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -

Is there a possibility make the daemon listen on 0.0.0.0 instead of 127.0.0.1?

— Reply to this email directly or view it on GitHub https://github.com/billw2/pikrellcam/pull/7#issuecomment-167121932.

Confusion is always the most honest response.

Yves911 commented 8 years ago

@codomania great thanks, now i can receive data on other machines on my LAN. What i didn't figure out yet is how to configure VLC to read the stream (should i enter a URL like https://mylogin:mypassword@myrasp:9999)?

codomania commented 8 years ago

Ah i never tried with vlc but its possible that vlc maybe missing start boundary start sequence. See if this commit fixes it ?

https://github.com/codomania/pikrellcam/commit/c5371cf6f8b26b233b689c91ffa3fa42a1ff2b28

BTW, you should not be directly connecting to port 9999, instead go through mjpeg_stream.php . That explains why 127.0.0.1 was not working for you.

try url like this:

http://pi:raspberry@192.168.1.24:8080/mjpeg_stream.php

Thanks Brijesh

On Thu, Dec 24, 2015 at 10:30 AM, Yves911 notifications@github.com wrote:

@codomania https://github.com/codomania great thanks, now i can receive data on other machines on my LAN. What i didn't figure out yet is how to configure VLC to read the stream (should i enter a URL like https://mylogin:mypassword@myrasp:9999)?

— Reply to this email directly or view it on GitHub https://github.com/billw2/pikrellcam/pull/7#issuecomment-167133265.

Confusion is always the most honest response.

Yves911 commented 8 years ago

Thanks Brijesh, i confirm that http://pi:raspberry@192.168.1.24:8080/mjpeg_stream.php is working smoothly here. I will try your patch tomorrow and let you know. Merry Christmas !!

Cheers Yves

codomania commented 8 years ago

Just got chance to try out vlc playback and have fixed it. Sent a pull request to Bill. Let me know if you still have any trouble getting it work. Merry Christmas !!

-Brijesh

On Thu, Dec 24, 2015 at 1:08 PM, Yves911 notifications@github.com wrote:

Thanks Brijesh, i confirm that http://pi:raspberry@192.168.1.24:8080/mjpeg_stream.php is working smoothly here. I will try your patch tomorrow and let you know. Merry Christmas !!

Cheers Yves

— Reply to this email directly or view it on GitHub https://github.com/billw2/pikrellcam/pull/7#issuecomment-167150584.

Confusion is always the most honest response.