User avatar
recantha2
Posts: 288
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
Contact: Website Facebook Twitter

Camera module stream in a web browser

Sun May 19, 2013 2:23 pm

Using a combination of the info from Leo White and some HTML, it's possible to embed the camera module stream inside a web-page. You basically use the VLC web browser plugin and the <OBJECT> tag. I've written it up on my blog:

http://www.recantha.co.uk/blog/?p=4165
--
Michael Horne - @recantha
Raspberry Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Camera module stream in a web browser

Sun May 19, 2013 2:43 pm

Cool, thanks. Will have a go when I get a working camera.

usmcguy
Posts: 10
Joined: Mon Mar 04, 2013 12:01 am

Re: Camera module stream in a web browser

Mon May 20, 2013 12:54 pm

This is something I'd like to pull off without having to use a VLC browser plugin. I'm curious if anyone has been able to achieve that yet.

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Camera module stream in a web browser

Mon May 20, 2013 1:09 pm

recantha2 wrote:Using a combination of the info from Leo White and some HTML, it's possible to embed the camera module stream inside a web-page. You basically use the VLC web browser plugin and the <OBJECT> tag. I've written it up on my blog:

http://www.recantha.co.uk/blog/?p=4165
Nice. Do you know if anyone has started looking at embedding controls into such a web page to start and stop the stream etc?

User avatar
recantha2
Posts: 288
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
Contact: Website Facebook Twitter

Re: Camera module stream in a web browser

Mon May 20, 2013 1:48 pm

@fbutler: On Chrome, the VLC plugin has controls (for me anyway).
@usmcguy: There's a possibility of encoding on-the-fly to MP4 which would work in the HTML5 video tag. However, when I've tried this I get about 4fps - not enough for video streaming IMHO.
--
Michael Horne - @recantha
Raspberry Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Camera module stream in a web browser

Mon May 20, 2013 2:13 pm

recantha2 wrote:@fbutler: On Chrome, the VLC plugin has controls (for me anyway).
Thanks, I was talking about further controls being developed by people to talk back to the Pi from the webpage to start and stop the raspivid program etc. This would seem to be a logical progression for functionality on such a webpage.

User avatar
recantha2
Posts: 288
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
Contact: Website Facebook Twitter

Re: Camera module stream in a web browser

Mon May 20, 2013 2:30 pm

_Oh_, right, gotcha. Well, actually I've developed a web interface to take pics and display them (and control a pan/tilt servo mechanism) so adding video is the next step.
--
Michael Horne - @recantha
Raspberry Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Camera module stream in a web browser

Mon May 20, 2013 2:40 pm

recantha2 wrote:_Oh_, right, gotcha. Well, actually I've developed a web interface to take pics and display them (and control a pan/tilt servo mechanism) so adding video is the next step.
Very cool. I'll follow your progress with interest.

usmcguy
Posts: 10
Joined: Mon Mar 04, 2013 12:01 am

Re: Camera module stream in a web browser

Tue May 21, 2013 4:09 pm

recantha2 wrote:@fbutler: On Chrome, the VLC plugin has controls (for me anyway).
@usmcguy: There's a possibility of encoding on-the-fly to MP4 which would work in the HTML5 video tag. However, when I've tried this I get about 4fps - not enough for video streaming IMHO.
What command/script did you use when you had 4fps? I'm curious. For me, I don't need a fast stream, it's for a Weather Cam I have setup. At the moment, I'm using a USB Camera.

madrian
Posts: 29
Joined: Tue Aug 28, 2012 6:48 pm

Re: Camera module stream in a web browser

Tue May 21, 2013 5:59 pm

Is there any way to record&stream at the same time?

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: Camera module stream in a web browser

Wed May 22, 2013 7:33 pm

What I would really like is the ability to view the camera stream on a mobile device using iOS/Android to set up time-lapses.

The device's browser would navigate to a site hosted on the pi where several options would let you configure intervals between images, image name, how long to take photos for, etc. I would use the streaming video to help me position the camera, either through the browser itself or a button that opens the video app within iOS for example to view the stream.

If the video is h264 then I thought this is a format that iOS could natively play, and if so perhaps stream?

Failing the streaming option I would have a button that takes and displays a photo every x seconds to help me position the camera.

The Pi would act as a wifi access point so that it could be set up remotely too.

Any idea if all this is possible?

mikec79
Posts: 18
Joined: Thu Oct 18, 2012 12:27 am

Re: Camera module stream in a web browser

Fri May 24, 2013 1:53 am

I have been playing with Andy Armstrong's psips https://github.com/AndyA/psips

It generates a HTTP Live Streaming (HLS) video that I've been able to view with Safari, QuickTime, and iOS Safari.

I've found ways to make it viewable in other browsers using js/flash players like the paid version of jw player. The following blog describes a free work around. http://justhackme.wordpress.com/2013/03 ... -in-flash/

I struggled a lot with ffmpeg and libfaac.

Below is what I had to do to get it to work.

Code: Select all

sudo apt-get install git build-essential autoconf libtool libavcodec-extra-53 nginx

Code: Select all

wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
tar -zxvf faac-1.28.tar.gz
cd faac-1.28
remove the declaration of strcasestr() in commom/mp4v2/mpeg4ip.h line 126
./configure
sudo make
sudo make install

Code: Select all

wget http://ffmpeg.org/releases/ffmpeg-1.2.1.tar.gz
tar -zxvf ffmpeg-1.2.1.tar.gz
cd ffmpeg-1.2.1
./configure --enable-libfaac --enable-nonfree
sudo make
sudo make install

Code: Select all

git clone [email protected]:AndyA/psips.git

Code: Select all

cd psips
./setup.sh && ./configure && sudo make && sudo make install
 /examples/hls.sh

silentsnake
Posts: 7
Joined: Tue May 21, 2013 7:46 pm

Re: Camera module stream in a web browser

Sat May 25, 2013 1:58 pm

I finally get this to work.

BTW you could just change libfaac to aac in hls.sh example. AAC is integrated in ffmpeg so it does not need any additional libraries. There might be differences in terms of quality, but since there is no audio stream this should not matter anyway.

But there is a pretty long delay (around 30 seconds). Can anybody confirm this? Any possibility to improve this?

mikec79
Posts: 18
Joined: Thu Oct 18, 2012 12:27 am

Re: Camera module stream in a web browser

Sat May 25, 2013 6:51 pm

I'm getting the same lag.

mikec79
Posts: 18
Joined: Thu Oct 18, 2012 12:27 am

Re: Camera module stream in a web browser

Sat May 25, 2013 9:37 pm

looks like decreasing segment_time in hls.sh helps a little

silentsnake
Posts: 7
Joined: Tue May 21, 2013 7:46 pm

Re: Camera module stream in a web browser

Sun May 26, 2013 1:35 pm

Thanks for the replies.

I think the delay is not too bad. I save the stream on a remote server first, since the capacity of the Raspberry Pi is somewhat limited and thought this might cause the delay.

Only problem I still have is that the playlist file isn't updated continually if it's stored on a mounted SMB share. So I wrote a second script, which is basically a endless loop that copys the local *.m3u8 file to the server in 1s intervals. Not very elegant but works for now.
I might investigate if it is working on nfs without that workaround.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Camera module stream in a web browser

Sun May 26, 2013 3:44 pm

I had the update issue on the m3u8 file on an NFS mount too and solved it by specifying -noac in the mount options. Perhaps something similar is available for samba as well.

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: Camera module stream in a web browser

Sun May 26, 2013 6:45 pm

This sounds great and I'm looking forward to trying it, so thanks for replying with the steps you took to make it work.

An odd one though is that I can't clone the code using "git clone [email protected]:AndyA/psips.git". It errors with the following:

Code: Select all

[email protected] ~ $ git clone [email protected]:AndyA/psips.git
Cloning into 'psips'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
[email protected] ~ $
Could be a glitch with the server so will try again later, unless anyone has any thoughts?

usmcguy
Posts: 10
Joined: Mon Mar 04, 2013 12:01 am

Re: Camera module stream in a web browser

Sun May 26, 2013 7:43 pm

Try

Code: Select all

git clone [email protected]/AndyA/psips.git

jarrah31
Posts: 125
Joined: Wed Oct 10, 2012 10:16 am

Re: Camera module stream in a web browser

Sun May 26, 2013 8:28 pm

Hi usmcguy, thanks for your help.

Unfortunately this didn't work for me either:

Code: Select all

[email protected] ~ $ git clone [email protected]/AndyA/psips.git
fatal: repository '[email protected]/AndyA/psips.git' does not exist
So I went to Andy Armstrong's site at https://github.com/AndyA/psips and tried the git clone command listed there:

Code: Select all

git clone git://github.com/AndyA/psips.git
which luckily did work. :)

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Camera module stream in a web browser

Sun May 26, 2013 10:08 pm

You need a GitHub account to use the [email protected] ssh notation because the authentication works with SSH keys. git:// URLs are for anonymous cloning.

mikec79
Posts: 18
Joined: Thu Oct 18, 2012 12:27 am

Re: Camera module stream in a web browser

Mon May 27, 2013 12:49 am

I was able to get the delay on my hls stream down to ~13 seconds. I'm trying to use the video stream in a html based robot controller. I wonder if i might be better off playing with mjpeg.

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Camera module stream in a web browser

Mon May 27, 2013 9:02 am

Can anyone tell me the cpu use while streaming to one client?

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Camera module stream in a web browser

Mon May 27, 2013 11:59 am

usmcguy wrote:This is something I'd like to pull off without having to use a VLC browser plugin. I'm curious if anyone has been able to achieve that yet.
Have a look at the semi-solution here: http://www.raspberrypi.org/phpBB3/viewt ... 43&t=45178
It will output mjpg that works with most browsers.

Return to “Camera board”