Page 1 of 1

Camera module stream in a web browser

Posted: Sun May 19, 2013 2:23 pm
by recantha2
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

Re: Camera module stream in a web browser

Posted: Sun May 19, 2013 2:43 pm
by poing
Cool, thanks. Will have a go when I get a working camera.

Re: Camera module stream in a web browser

Posted: Mon May 20, 2013 12:54 pm
by usmcguy
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.

Re: Camera module stream in a web browser

Posted: Mon May 20, 2013 1:09 pm
by fbutler
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?

Re: Camera module stream in a web browser

Posted: Mon May 20, 2013 1:48 pm
by recantha2
@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.

Re: Camera module stream in a web browser

Posted: Mon May 20, 2013 2:13 pm
by fbutler
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.

Re: Camera module stream in a web browser

Posted: Mon May 20, 2013 2:30 pm
by recantha2
_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.

Re: Camera module stream in a web browser

Posted: Mon May 20, 2013 2:40 pm
by fbutler
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.

Re: Camera module stream in a web browser

Posted: Tue May 21, 2013 4:09 pm
by usmcguy
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.

Re: Camera module stream in a web browser

Posted: Tue May 21, 2013 5:59 pm
by madrian
Is there any way to record&stream at the same time?

Re: Camera module stream in a web browser

Posted: Wed May 22, 2013 7:33 pm
by jarrah31
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?

Re: Camera module stream in a web browser

Posted: Fri May 24, 2013 1:53 am
by mikec79
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

Re: Camera module stream in a web browser

Posted: Sat May 25, 2013 1:58 pm
by silentsnake
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?

Re: Camera module stream in a web browser

Posted: Sat May 25, 2013 6:51 pm
by mikec79
I'm getting the same lag.

Re: Camera module stream in a web browser

Posted: Sat May 25, 2013 9:37 pm
by mikec79
looks like decreasing segment_time in hls.sh helps a little

Re: Camera module stream in a web browser

Posted: Sun May 26, 2013 1:35 pm
by silentsnake
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.

Re: Camera module stream in a web browser

Posted: Sun May 26, 2013 3:44 pm
by towolf
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.

Re: Camera module stream in a web browser

Posted: Sun May 26, 2013 6:45 pm
by jarrah31
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?

Re: Camera module stream in a web browser

Posted: Sun May 26, 2013 7:43 pm
by usmcguy
Try

Code: Select all

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

Re: Camera module stream in a web browser

Posted: Sun May 26, 2013 8:28 pm
by jarrah31
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. :)

Re: Camera module stream in a web browser

Posted: Sun May 26, 2013 10:08 pm
by towolf
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.

Re: Camera module stream in a web browser

Posted: Mon May 27, 2013 12:49 am
by mikec79
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.

Re: Camera module stream in a web browser

Posted: Mon May 27, 2013 9:02 am
by jacksonliam
Can anyone tell me the cpu use while streaming to one client?

Re: Camera module stream in a web browser

Posted: Mon May 27, 2013 11:59 am
by TarjeiB
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.