oystercatcher
Posts: 8
Joined: Wed Nov 16, 2011 10:32 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Jul 31, 2013 5:11 am

I found this thread today and have it working with the jwplayer

My main problem early on was a failure to install git but I asked
on another thread and was told to try aptitude update
which solved that problem
other than the 3+ hour compile of ffmpeg I think this tutorial was
very good. I admit I was confused for awhile with jwplayer and
what to do with it but continuing through the thread cleared things up.

Thanks very much and the best part is that it has been running
for more than an hour with no problems. fingers crossed x

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 8:02 am

seasider4374 wrote:Anyone able to help with a couple of queries?

1) How to I install the patched Raspivid file to enable unlimited streaming?
2) Any pointers on the HTML code needed to get StrobeMediaPlayback working instead of JWPlayer would be greatly appreciated...

Thanks,

Seasider4374
I use this and it is unlimited:

25 FRAMS PER SECOND
raspivid -t -0 -w 1280 -h 720 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
raspivid -t -0 -w 1920 -h 1080 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666


30 FRAMS PER SECOND
raspivid -t -0 -w 1280 -h 720 -fps 30 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
raspivid -t -0 -w 1920 -h 1080 -fps 30 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666

so the -t parameter is set to zero instead of -1 or 9999999999 :)

seasider4374
Posts: 10
Joined: Sat Jun 29, 2013 8:28 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 8:08 am

Very much looking forward forward to the updated how-to Rayui!
Marcelp1, thanks - I'll try those later.

In the meantime can anyone help me view the stream from outside my LAN?

I've a static IP setup, and Lighttpd as my webserver, and I've forwarded ports 8079 to 80, and 1935 to 1935 as a post further up this thread.

When at a remote PC and viewing my.outside.ip.address from a browser I can see the lighttpd holding page so access to the Pi is there, however when entering my.outside.ip.address/WebcamStream.html I get the JWPlayer loading but it continues to buffer and eventually gives an "Error loading stream. Could not connect to server" message.

The same thing occurs whether I use Chrome or Firefox. Safai loads the lighttpd page, but can't find the WebcamStream.

Can anyone help?

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 8:47 am

seasider4374 wrote:Very much looking forward forward to the updated how-to Rayui!
Marcelp1, thanks - I'll try those later.

In the meantime can anyone help me view the stream from outside my LAN?

I've a static IP setup, and Lighttpd as my webserver, and I've forwarded ports 8079 to 80, and 1935 to 1935 as a post further up this thread.

When at a remote PC and viewing my.outside.ip.address from a browser I can see the lighttpd holding page so access to the Pi is there, however when entering my.outside.ip.address/WebcamStream.html I get the JWPlayer loading but it continues to buffer and eventually gives an "Error loading stream. Could not connect to server" message.

The same thing occurs whether I use Chrome or Firefox. Safai loads the lighttpd page, but can't find the WebcamStream.

Can anyone help?
So if I understand that you have opened up 8079 on outside to go to your RPi port 80?
If so, you need to type http://my.outside.ip.address:8079/WebcamStream.html

I would say it is a problem in port forwarding.
Does it work locally so http://my.alocal.ip.address/WebcamStream.html

What ADSL modem/router have you got?

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Background Job

Thu Aug 01, 2013 9:19 am

I have been using:

Code: Select all

raspivid -t -0 -w 1280 -h 720 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
to stream from RPi Camera at 720p but the bit rate was only about 448.6kbits/s, but my upload speed is 2169kbps as per modem stats.

So I have changed the bit rate to 2000000 and that streams at 1670.7kbits/s

Code: Select all

raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
now I want to be able to specify width, hight, fps and the bit rate as well when I restart or just play around with it. But when I close my PuTTY terminal the streaming stops.

Looking at the article "How to manage background and foreground job"
http://linuxg.net/how-to-manage-backgro ... processes/

I have tried "&" at the end of the command:
raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666 &

or just after raspivid:
raspivid & -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666

but none of the commands work :(

Are there any experts in background and foreground job over here?

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 9:30 am

try:
nohup raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666 &

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 9:42 am

B0SC0 wrote:start video on the pi.
from pc running firefox enter:
http://myipaddress:1935/myvideostream.html
just sits there churning but no video.
Is port 1935 okay to use?
this format is only needed to view it from outside of you network so over the internet

http://myipaddress:XXXX/myvideostream.html
where XXXX is the port you have opened up on your router and forwarded
to your RPi's port 80 where your web server is running.

Plus for someone else, viewing the stream over internet you need to open up port
1935 for RTMP (Real Time Messaging Protocol) to transmit the data from your RPi

So if your
http://yourRPiaddress/
works and you get the main webpage display, then your web server runs on port 80

popeye007
Posts: 8
Joined: Wed Jul 24, 2013 9:18 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 9:46 am

Hi,

I've done that.

http://pkula.blogspot.co.uk/2013/06/liv ... ry-pi.html

not come on, what should I do now that I see the strem in the browser.

The LED on the PI camera module also comes on. Some what lack I yet.

please help

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 9:59 am

popeye007 wrote:Hi,

I've done that.

http://pkula.blogspot.co.uk/2013/06/live-video-stream-from-raspberry-pi.html

not come on, what should I do now that I see the strem in the browser.

The LED on the PI camera module also comes on. Some what lack I yet.

please help
In order to be able to help you,
I need some more info and more info you supply
the more likelihood that someone will help you.

Does the setup work if you trying to access it locally
http://your-RPis-local-IP-address/nameofthefile.html
but does not work when trying to access from internet, or does it not work at all?
Last edited by marcelp1 on Thu Aug 01, 2013 11:34 am, edited 1 time in total.

popeye007
Posts: 8
Joined: Wed Jul 24, 2013 9:18 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 10:04 am

'm at the point with nginx. The nginx is reachable but what I need to enter in order to view the stream.
Or I have to create an html page with a rtmp link if so how did that out to see
or stobe media player in the directory www and how then?

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 10:54 am

Here is my setup that worked for me on 2013-05-25-wheezy-raspbian.zip image:


-------------------------------------------------------------------------------------------------------------------------------------------------------------
# to get your RPi up to date
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo apt-get update
sudo apt-get upgrade



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Install Lighttpd web server and the extras + zip to unzip JWPlayer later on
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo apt-get install lighttpd lighttpd-doc php5-common php5-cgi php5 zip


-------------------------------------------------------------------------------------------------------------------------------------------------------------
# To enable the server to handle php scripts the fastcgi-php module and other stuff I have found in forums
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo lighty-enable-mod fastcgi-php
sudo lighty-enable-mod cgi
sudo lighttpd-enable-mod fastcgi



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# create PHP info WEB PAGE
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo nano /var/www/php.php
###########################
<? phpinfo() ?>
###########################


-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Save the file /var/www/php.php and exit the nano editor
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Ctrl+O
Enter
Ctrl+X




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Back up original config file (just in case)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.bakORIGINAL





-------------------------------------------------------------------------------------------------------------------------------------------------------------
# add below to config file :) to have accesslog logging visits to your server
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo nano /etc/lighttpd/lighttpd.conf

###########################
server.modules = (
"mod_accesslog",

# Log access :)
accesslog.filename = "/var/log/lighttpd/access.log"
###########################



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Save the file /etc/lighttpd/lighttpd.conf and exit the nano editor
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Ctrl+O
Enter
Ctrl+X





-------------------------------------------------------------------------------------------------------------------------------------------------------------
MY /etc/lighttpd/lighttpd.conf LOOKS LIKE THIS:
-------------------------------------------------------------------------------------------------------------------------------------------------------------
###########################
server.modules = (
"mod_accesslog",
"mod_access",
# "mod_alias",
"mod_auth",
"mod_compress",
# "mod_fastcgi",
"mod_redirect",
# "mod_rewrite",
)

server.document-root = "/var/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
server.port = 80

# Log access :)
accesslog.filename = "/var/log/lighttpd/access.log"

## http://redmine.lighttpd.net/projects/1/wiki/Docs_ModDirlisting#dir-listingactivate
## Enable Directory listings :))) for all DIR with no INDEX file present
dir-listing.activate = "enable"


index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir = "/var/cache/lighttpd/compress/"
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

# password protected access DOES NOT WORK!
# http://www.cyberciti.biz/tips/lighttpd-setup-a-password-protected-directory-directories.html

#auth.debug = 2
#auth.backend = "plain"
#auth.backend.plain.userfile = "/etc/lighttpd/lighttpdpassword"
#auth.require = ( "/log/" =>
#(
#"method" => "basic",
#"realm" => "Password protected area",
#"require" => "valid-user"
#)
#)
###########################






-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Log rotation Yearly instead of Weekly
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo nano /etc/logrotate.d/lighttpd
###################################
yearly
###################################




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Save the file /etc/logrotate.d/lighttpd and exit the nano editor
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Ctrl+O
Enter
Ctrl+X



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Then reload the server using
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo service lighttpd force-reload




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# To check the config is OK
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo lighttpd -t -f /etc/lighttpd/lighttpd.conf




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Restart the webserver
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo /etc/init.d/lighttpd restart



now check you get the webserver working
http:// ip address of your RPi/
so something like
http://192.168.0.2/
http://192.168.0.2/index.lighttpd.html
and you should see Placeholder page
and your php info page
http:// ip address of your RPi/php.php
http://192.168.0.2/php.php



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# now reboot your system for the php to work
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo reboot




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Install the crtmpserver
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo aptitude install crtmpserver




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Back up originall crtmpserver config
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo cp /etc/crtmpserver/applications/flvplayback.lua /etc/crtmpserver/applications/flvplayback.lua.bakORIGINAL





-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Change these values in /etc/crtmpserver/applications/flvplayback.lua
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo nano /etc/crtmpserver/applications/flvplayback.lua
#######################################################
validateHandshake=false,
keyframeSeek=false,
seekGranularity=0.1
clientSideBuffer=30
#######################################################





-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Save the file /etc/crtmpserver/applications/flvplayback.lua and exit the nano editor
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Ctrl+O
Enter
Ctrl+X




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Restart crtmpserver
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo /etc/init.d/crtmpserver restart



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Now this is the log process, I had to reinstall whole image on my card, as I had ffmpeg installed before and below did not work for me, but you can try removing it
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo aptitude remove ffmpeg






-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Install git-core and ffmpeg
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo apt-get install git-core
cd /usr/src
sudo mkdir ffmpeg
sudo chown `whoami`:users ffmpeg
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure


-------------------------------------------------------------------------------------------------------------------------------------------------------------
# GO TO GET SOME TEA, it takes ages after issuing the command below cca 3-4 hours
-------------------------------------------------------------------------------------------------------------------------------------------------------------
make &
sudo make install






-------------------------------------------------------------------------------------------------------------------------------------------------------------
# While the ffmpeg is installing /compiling etc, you can register to get your JWPlayer
-------------------------------------------------------------------------------------------------------------------------------------------------------------
http://www.longtailvideo.com/jw-player/download/

or see if this works without registration
wget http://account.longtailvideo.com/static/download/jwplayer-6.5.zip
or
wget https://www.dropbox.com/s/bfgr7146u3g7kf7/jwplayer-6.5.zip
sudo unzip jwplayer-6.5.zip -d /var/www








-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Create web page for the WebCam - I choose to create specific folder called 720p (http://192.168.0.2/720p
instead of having to type http://192.168.0.2/720p.php)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo mkdir /var/www/720p
sudo nano /var/www/720p/index.php
#######################################################
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OV5647 Webcam Live 720p (1280 x 720 progressive scan)</title>

</head>

<body>

<!-- Code for WebCam START -->
<div id="video-jwplayer_wrapper" style="position: relative; display: block; width: 1280px; height: 720px;">
<object type="application/x-shockwave-flash" data="/jwplayer/jwplayer.flash.swf" width="100%" height="100%" bgcolor="#000000" id="video-jwplayer" name="video-jwplayer" tabindex="0">
<param name="allowfullscreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="seamlesstabbing" value="true">
<param name="wmode" value="opaque">
</object>
<div id="video-jwplayer_aspect" style="display: none;"></div>
<div id="video-jwplayer_jwpsrv" style="position: absolute; top: 0px; z-index: 10;"></div>
</div>

<script src="/jwplayer/jwplayer.js"></script>

<script type="text/javascript">
jwplayer('video-jwplayer').setup({
flashplayer:"/jwplayer/jwplayer.flash.swf"
, file:"rtmp://" + window.location.hostname + "/flvplayback/flv:myStream.flv"
, autoStart: true
, rtmp:{
bufferlength:0.1
}
, deliveryType: "streaming"
, width: 1280
, height: 720
, player: {
modes: {
linear: {
controls:{
stream:{
manage:false
, enabled: false
}
}
}
}
}
, shows: {
streamTimer: {
enabled: true
, tickRate: 100
}
}
});
</script>

<!-- Code for WebCam END -->

<br>
</body>
</html>



Current core temperature: <?php
$temp = intval(file_get_contents("/sys/class/thermal/thermal_zone0/temp")); // read the file as a string[file_get_contents()], and convert to an int [intval()]so we can do math functions with it
$color = "#060"; // default colour
if($temp >= 60000) { $color = "#F00"; } //set to red if over 60 degrees (is in milliDegrees)
elseif($temp >= 50000) { $color = "#FC0"; } // set to yellow if over 50 degrees
echo "<span style=\"color:".$color.";\">".($temp/1000)."&deg;C / ".(($temp/1000)+271.15)."K</span>";
?><br />

Current core frequency: <?php
$freq = intval(file_get_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"));
echo ($freq/1000)."MHz"; // covert to MHz from kHz
?><br />


Uptime: <?php
// Grab uptime output
$uptime_array = explode(" ", exec("cat /proc/uptime"));
$seconds = round($uptime_array[0], 0);
$minutes = $seconds / 60;
$hours = $minutes / 60;
$days = floor($hours / 24);
$hours = floor($hours - ($days * 24));
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
$seconds = floor($seconds - ($days * 24 * 60 * 60) - ($hours * 60 * 60) - ($minutes * 60));
$uptime_array = array($days, $hours, $minutes, $seconds);
$uptime = ($days . " days " . $hours . " hours " . $minutes . " minutes" );
echo $uptime; ?><br />


System Time: <?php
// Get the Time
$time = (exec("date +'%d %b %Y - %T %Z'"));
echo $time; ?><br />



<!-- Network-Data: --> <?php
// Get Network-Data
// $RX = (exec("ifconfig wlan0 | grep 'RX bytes'| cut -d: -f2 | cut -d' ' -f1"));
// $TX = (exec("ifconfig wlan0 | grep 'TX bytes'| cut -d: -f3 | cut -d' ' -f1"));
// echo $RX; $TX; ?><br />




<br>

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER['HTTP_USER_AGENT'];
$referred = $_SERVER['HTTP_REFERER']; // a quirky spelling mistake that stuck in php

print "<strong>IP address:</strong><br />\n";
print "$ip<br /><br />\n";
print "<strong>Host address:</strong><br />\n";
print "$hostaddress<br /><br />\n";
print "<strong>Browser info</strong>:<br />\n";
print "$browser<br /><br />\n";
print "<strong>Where you came from, if you clicked on a link to get here</strong>:<br />\n";
if ($referred == "") {
print "Page was directly requested";
}
else {
print "$referred";
}
?><br />
#######################################################


-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Save the file and exit the nano editor
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Ctrl+O
Enter
Ctrl+X



-------------------------------------------------------------------------------------------------------------------------------------------------------------
# start the streaming process 720p at bitrate of cca 448.6kbits/s
-------------------------------------------------------------------------------------------------------------------------------------------------------------
raspivid -t -0 -w 1280 -h 768 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666




-------------------------------------------------------------------------------------------------------------------------------------------------------------
# start the streaming process 720p at bitrate of cca 1671.0kbits/s
-------------------------------------------------------------------------------------------------------------------------------------------------------------
raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666





it should look like this:
[email protected] ~ $ raspivid -t -0 -w 1920 -h 1080 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
ffmpeg version N-54897-g7dc7761 Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 23 2013 14:58:53 with gcc 4.6 (Debian 4.6.3-14+rpi1)
configuration:
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 19.100 / 55. 19.100
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.102 / 3. 81.102
libswscale 2. 4.100 / 2. 4.100
libswresample 0. 17.103 / 0. 17.103
Input #0, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, flv, to 'tcp://0.0.0.0:6666':
Metadata:
streamName : myStream
encoder : Lavf55.12.102
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1920x1080, q=2-31, 25 fps, 1k tbn, 1200k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
frame=103030 fps= 25 q=-1.0 size= 840608kB time=01:08:41.16 bitrate=1671.0kbits/s





http://192.168.0.2/720p is where you can view your camera
for outside (internet), you need to open port 1935 and 80 to your RPi
if you have two or more cameras, only one can be accessed from internet :(






------------------------------------------------------------------------------------------------------------------------------------------------------------
# for some stats install Webalizer for Raspberry Pi
------------------------------------------------------------------------------------------------------------------------------------------------------------
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=22519

sudo apt-get install webalizer



------------------------------------------------------------------------------------------------------------------------------------------------------------
# back up /etc/webalizer/webalizer.conf file
------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo cp /etc/webalizer/webalizer.conf /etc/webalizer/webalizer.conf.bakORIGINAL




------------------------------------------------------------------------------------------------------------------------------------------------------------
# edit /etc/webalizer/webalizer.conf to read the correct logfile
------------------------------------------------------------------------------------------------------------------------------------------------------------
sudo nano /etc/webalizer/webalizer.conf
#######################################
/var/log/lighttpd/access.log

#LogFile /var/log/apache/access.log.1
LogFile /var/log/lighttpd/access.log
#######################################



sudo webalizer /var/log/lighttpd/access.log
or
sudo webalizer -c /etc/webalizer/webalizer.conf


http://192.168.0.2/webalizer
Last edited by marcelp1 on Thu Aug 01, 2013 12:47 pm, edited 3 times in total.

popeye007
Posts: 8
Joined: Wed Jul 24, 2013 9:18 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Thu Aug 01, 2013 11:16 am

thank you,

JWPlayer player I have 5-6 seconds delay so I also wanted the strobe media playback switch.

but as I installed the strobe media playback and what I'd have to make it so that the stream displays. nginx-rtmp module and ffmpeg are on it

wcopeland
Posts: 3
Joined: Sat Apr 06, 2013 1:14 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Fri Aug 02, 2013 4:23 am

Like others here, I just want to say MANY thanks for this tutorial! I was going insane until I found this.

seasider4374
Posts: 10
Joined: Sat Jun 29, 2013 8:28 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sat Aug 03, 2013 3:10 pm

Thanks again to marcelp1 for the suggestions - my issues with not being able to access from an outside IP were port forwarding issues. I had values in "Trigger Protocol" and "Trigger Port" as well as "Translate from" and "Translate to". As soon as the Trigger item values were deleted all worked.

Re. Time I have no issues running -t 99999999 which I believe to be around 27 hours.

Looking forward to nginx and Stream Media Playback - my end goals being able to view my stream on an iPad, Nexus 7, and hopefully RaspBMC.

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Aug 04, 2013 4:54 pm

JW Player should be working with iPad and iPhone as per their website,
I have tried on
iPhone; CPU iPhone OS 6_1_4 like Mac OS X
and
iPad; CPU OS 6_1_3 like Mac OS X
and none of them seem to work, same for Android.

Now I am not an expert, but is there anything need to be installed on those mobile devices
in order to see the stream?

And is there an alternative to Adobe Flash Player plug-in to view it in browsers that do not come in
with one installed (Epiphany, SeaMonkey, Iceweasel)?


How about Strobe Media Playback has anyone managed to get it working with lighttpd?

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Aug 04, 2013 4:57 pm

shuckle wrote:try:
nohup raspivid -t -0 -w 1280 -h 720 -fps 25 -b 2000000 -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666 &

that worked +1

Once in the background how do I bring in back to my PuTTY terminal when I log in back?

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Sun Aug 04, 2013 7:40 pm

marcelp1 wrote:

that worked +1

Once in the background how do I bring in back to my PuTTY terminal when I log in back?
You can not do that. Why would you want todo it? You can kill it and there is not much else you could do even if It was on your terminal?

wcopeland
Posts: 3
Joined: Sat Apr 06, 2013 1:14 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Aug 05, 2013 12:50 am

I am convinced that either I am supplying the wrong "src" parameter I am feeding into my StrobeMediaPlayback-based HTML file. If someone has a clue of what is going on, would you mind helping me out?

Here is the important bit (I think)...

Code: Select all

...
<script type="text/javascript">
...
var parameters = {
src: "rtmp://" + window.location.hostname + "/flvplayback/flv:myStream.flv",
...
The code is saved in "/smfp/index.html". In a browser, I just call 192.168.X.Y/smfp/ and I am good to go when the "src" parameter is set to external HTTP or RTMP links I grab from the internet.

For example this streams perfectly fine when I provide that as the "src" parameter.:

Code: Select all

rtmp://r.jdkmusicmedia.newwhirledorder.netdna-cdn.com/play/mp4:vod/jdkmusicmedia.newwhirledorder/Sherlock.mp4
So I am pretty convinced that I am missing something (very) obvious with respect to calling my stream from that "src" parameter.

Thanks!

ripping
Posts: 32
Joined: Wed Mar 14, 2012 10:55 am
Location: New Zealand

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Aug 05, 2013 6:13 pm

marcelp1 wrote:JW Player should be working with iPad and iPhone as per their website,
I have tried on
iPhone; CPU iPhone OS 6_1_4 like Mac OS X
and
iPad; CPU OS 6_1_3 like Mac OS X
and none of them seem to work, same for Android.

Now I am not an expert, but is there anything need to be installed on those mobile devices
in order to see the stream?
I'm an android user. The only browser that I've been able to see a stream on is "UC Browser HD".
And even then, it tends to stall after a minute or two.
That's on a Samsung 10.1 Note with Android 4.1.2
Firefox, Chrome, Puffin, Dolphin - none of these render the stream.

causerino
Posts: 7
Joined: Sat May 05, 2012 2:42 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Aug 05, 2013 8:04 pm

ripping wrote:
marcelp1 wrote:JW Player should be working with iPad and iPhone as per their website,
I have tried on
iPhone; CPU iPhone OS 6_1_4 like Mac OS X
and
iPad; CPU OS 6_1_3 like Mac OS X
and none of them seem to work, same for Android.

Now I am not an expert, but is there anything need to be installed on those mobile devices
in order to see the stream?
I'm an android user. The only browser that I've been able to see a stream on is "UC Browser HD".
And even then, it tends to stall after a minute or two.
That's on a Samsung 10.1 Note with Android 4.1.2
Firefox, Chrome, Puffin, Dolphin - none of these render the stream.
I have been able to use firefox, on a SGS2, but only because I installed Flash, and then enabled the desktop site version instead. Streams fine after that.

Ark
Posts: 4
Joined: Mon Aug 05, 2013 11:36 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Mon Aug 05, 2013 11:48 pm

If you want to swap from JWPlayer to strobe player, simply download the strobe player package from http://sourceforge.net/projects/smp.adobe/files/ and put the folder "for Flash Player 10.1" into the root of your web server.
I renamed the folder to "strobe".

A web page with a simple player might look like this (placed in the root of your web server):

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Strobe Media Playback</title>
    <script type="text/javascript" src="strobe/lib/swfobject.js"></script>
	<script type="text/javascript">  		
    		
    	// Create a StrobeMediaPlayback configuration 
		var parameters = {  
         				src: "rtmp://" + window.location.hostname + "/flvplayback/myStream",  
                     			autoPlay: true,  
         				controlBarAutoHide: false,  
         				playButtonOverlay: true,  
         				showVideoInfoOverlayOnStartUp: false,  
                     			optimizeBuffering : false,  
                     			initialBufferTime : 0.1,  
                     			expandedBufferTime : 0.1,  
                     			minContinuousPlayback : 0.1,  
         				poster: "strobe/images/poster.png"  
       				};  
    		
		// Embed the player SWF:    		
		swfobject.embedSWF
			( "strobe/StrobeMediaPlayback.swf"
			, "strobeMediaPlayback"
			, 640
			, 480
			, "10.1.0"
			, {}
			, parameters
			, { allowFullScreen: "true"}
			, { name: "strobeMediaPlayback" }
			);
		
    </script>  	
  </head>
  <body>
	
	<div id="strobeMediaPlayback">
      <p>Alternative content</p>
    </div>
  </body>
</html>
Enjoy!

seasider4374
Posts: 10
Joined: Sat Jun 29, 2013 8:28 am

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Tue Aug 06, 2013 9:45 pm

Thanks Ark, that worked a treat after changing the two references of your "strobe" folder to my "StrobeMediaPlayback" reference.

The lack of delay with StrobeMediaPlayback is incredible compared to JWPlayer!

I've got it working with my Nexus 7 after installing the Flash APK, and Firefox although it doesn't like fullscreen mode but that's a small niggle.

Just want to get it working on an iPad and RaspBMC and I'll be a very happy man.

Oh, and getting a daemon script working for the video and stream to start upon power up would make my Baby Monitor/Cam complete - my wife could then plug it in wherever our son is playing/sleeping and I at work, and his grandparents, can see him at anytime. Any help appreciated...

Thanks in advance

Ark
Posts: 4
Joined: Mon Aug 05, 2013 11:36 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 07, 2013 4:17 am

This is not an ideal solution since I m using a shell script called by the daemon and the stop doesn't use the pid, but it does the job ...

To start the camera and the signal processing chain (you might want to adjust resolution and bitrate) I use a this script named video.sh:

Code: Select all

#!/bin/sh

raspivid -n -vs -t 0 -fps 25 -b 5000000 -vf -hf -o - | ffmpeg -i - -vcodec copy -an -f flv -metadata streamName=myStream tcp://0.0.0.0:6666 > /dev/null 2>&1 &
Create a file in /etc/init.d/ called pi_cam (e.g.) with the following content (point DAEMON to your video.sh file):

Code: Select all

#!/bin/sh

### BEGIN INIT INFO
# Provides:          Pi Camera Steaming
# Required-Start:    $all
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the Pi Camera Streaming
# Description:       starts Pi Camera Streaming using start-stop-daemon
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/pi
DAEMON=/home/pi/video.sh
NAME=PiCam
DESC=PiCam

case "$1" in
        start)
                echo -n "Starting $DESC: "
                start-stop-daemon --start --pidfile /var/run/$NAME.pid \
                    --exec $DAEMON || true
                echo "$NAME."
                ;;

        stop)
                echo -n "Stopping $DESC: "
                killall raspivid
                echo "$NAME."
                ;;
        *)
                echo "Usage: $NAME {start|stop}" >&2
                exit 1
                ;;
esac

exit 0
To register your service, use:

Code: Select all

sudo update-rc.d pi_cam defaults
To de-register you service use:

Code: Select all

sudo update-rc.d -f pi_cam remove

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 07, 2013 1:08 pm

shuckle wrote:
marcelp1 wrote:

that worked +1

Once in the background how do I bring in back to my PuTTY terminal when I log in back?
You can not do that. Why would you want todo it? You can kill it and there is not much else you could do even if It was on your terminal?

I did not think of that. I thought that I need to bring the process back and then end it with Ctrl+C.
Well I am still learning ;)

marcelp1
Posts: 129
Joined: Mon Jun 11, 2012 8:41 pm

Re: Streaming Raspberry Pi Camera H264 into HTML over RTMP

Wed Aug 07, 2013 3:48 pm

Ark wrote:If you want to swap from JWPlayer to strobe player, simply download the strobe player package from http://sourceforge.net/projects/smp.adobe/files/ and put the folder "for Flash Player 10.1" into the root of your web server.
I renamed the folder to "strobe".

A web page with a simple player might look like this (placed in the root of your web server):

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Strobe Media Playback</title>
    <script type="text/javascript" src="strobe/lib/swfobject.js"></script>
	<script type="text/javascript">  		
    		
    	// Create a StrobeMediaPlayback configuration 
		var parameters = {  
         				src: "rtmp://" + window.location.hostname + "/flvplayback/myStream",  
                     			autoPlay: true,  
         				controlBarAutoHide: false,  
         				playButtonOverlay: true,  
         				showVideoInfoOverlayOnStartUp: false,  
                     			optimizeBuffering : false,  
                     			initialBufferTime : 0.1,  
                     			expandedBufferTime : 0.1,  
                     			minContinuousPlayback : 0.1,  
         				poster: "strobe/images/poster.png"  
       				};  
    		
		// Embed the player SWF:    		
		swfobject.embedSWF
			( "strobe/StrobeMediaPlayback.swf"
			, "strobeMediaPlayback"
			, 640
			, 480
			, "10.1.0"
			, {}
			, parameters
			, { allowFullScreen: "true"}
			, { name: "strobeMediaPlayback" }
			);
		
    </script>  	
  </head>
  <body>
	
	<div id="strobeMediaPlayback">
      <p>Alternative content</p>
    </div>
  </body>
</html>
Enjoy!
Ark, thank you for pointing me to the right direction.

I have made slight amendment to the HTML code so this page can be placed anywhere in /var/www/... folder, rather than in root of the web server and here is what I did:

wget http://garr.dl.sourceforge.net/project/smp.adobe/Strobe%20Media%20Playback%201.6%20Release%20%28source%20and%20binaries%29/StrobeMediaPlayback_1.6.328-full.zip

( I could not unzip content of "for Flash Player 10.1" folder inside the StrobeMediaPlayback_1.6.328-full.zip into the /var/www/strobe folder so it can be done as below)
sudo unzip StrobeMediaPlayback_1.6.328-full.zip "for Flash Player 10.1"/\* -d /var/www/
cd /var/www/
sudo mv "for Flash Player 10.1" strobe

sudo nano /var/www/strobe.html

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Strobe Media Playback</title>
        <script type="text/javascript" src="/strobe/lib/swfobject.js"></script>
       <script type="text/javascript">        
              
           // Create a StrobeMediaPlayback configuration
          var parameters = { 
                         src: "rtmp://" + window.location.hostname + "/flvplayback/myStream", 
                                  autoPlay: true, 
                         controlBarAutoHide: false, 
                         playButtonOverlay: true, 
                         showVideoInfoOverlayOnStartUp: false, 
                                  optimizeBuffering : false, 
                                  initialBufferTime : 0.1, 
                                  expandedBufferTime : 0.1, 
                                  minContinuousPlayback : 0.1, 
                         poster: "strobe/images/poster.png" 
                       }; 
              
          // Embed the player SWF:          
          swfobject.embedSWF
             ( "/strobe/StrobeMediaPlayback.swf"
             , "strobeMediaPlayback"
             , 1280
             , 720
             , "10.1.0"
             , {}
             , parameters
             , { allowFullScreen: "true"}
             , { name: "strobeMediaPlayback" }
             );
          
        </script>     
      </head>
      <body>
       
       <div id="strobeMediaPlayback">
          <p>Alternative content</p>
        </div>
      </body>
    </html>
Last edited by marcelp1 on Tue Aug 13, 2013 12:50 pm, edited 1 time in total.

Return to “Camera board”