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)."°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:
pi@RPi ~ $ 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.