官方原帖
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=45368&sid=b81f6551e478f0f6e172aa40e31ee179
安装 crtmpserver服务
sudo aptitude install crtmpserver
添加 crtmpserver日志文件
sudo mkdir /var/log/crtmpserver
配置crtmpserver服务环境
sudo nano /etc/crtmpserver/applications/flvplayback.lua
修改以下几行 保存退出
validateHandshake=false,
keyframeSeek=false,
seekGranularity=0.1
clientSideBuffer=30
重启 crtmpserver 服务
sudo /etc/init.d/crtmpserver restart
安装编译 ffmpeg ,系统的ffmpeg自带的不支持H264编码的flash 流,需要下载支持的ffmpeg编译,这个部分编译时间比较长,也是重要的一个步骤。
sudo aptitude remove ffmpeg
cd /usr/src
sudo mkdir ffmpeg
sudo chown `whoami`:users ffmpeg
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure
make
sudo make install
我编译好的包 http://urlxf.qq.com/?j6feUrQ ,下载解压到 可以省很多时间
sudo make install
实现摄像头数据转实现RTMP,官方时间用-1有错误提示,下面更正了
raspivid -t 9999999 -w 960 -h 540 -fps 25 -b 500000 -o - | ffmpeg -i - -vcodec copy -an -r 25 -f flv -metadata streamName=myStream tcp://0.0.0.0:6666
树莓派安装web(nginx)服务器
http://yujianxuechuan.blog.163.com/blog/static/2174560072013511103620861/
视频输出
下载jwplayer
sudo ln -s /usr/share/nginx/www /var
cd /var/www
wget http://account.longtailvideo.com/static/download/jwplayer-6.5.zip
或者
wget https://www.dropbox.com/s/bfgr7146u3g7kf7/jwplayer-6.5.zip
解压
sudo unzip jwplayer-6.5.zip -d /var/www
sudo nano /var/www/720p/index.php
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>OV5647 Webcam Live 720p (1280 x 720 progressive scan)</title> 6 </head> 7 8 <body> 9 10 <!-- Code for WebCam START --> 11 <div id="video-jwplayer_wrapper" style="position: relative; display: block; width: 1280px; height: 720px;margin:auto "> 12 <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"> 13 <param name="allowfullscreen" value="true"> 14 <param name="allowscriptaccess" value="always"> 15 <param name="seamlesstabbing" value="true"> 16 <param name="wmode" value="opaque"> 17 </object> 18 <div id="video-jwplayer_aspect" style="display: none;"></div> 19 <div id="video-jwplayer_jwpsrv" style="position: absolute; top: 0px; z-index: 10;"></div> 20 </div> 21 <script src="/jwplayer/jwplayer.js"></script> 22 <script type="text/javascript"> 23 jwplayer('video-jwplayer').setup({ 24 flashplayer:"/jwplayer/jwplayer.flash.swf" 25 , file:"rtmp://" + window.location.hostname + "/flvplayback/flv:myStream.flv" 26 , autoStart: true 27 , rtmp:{ 28 bufferlength:0.1 29 } 30 , deliveryType: "streaming" 31 , width: 1280 32 , height: 720 33 , player: { 34 modes: { 35 linear: { 36 controls:{ 37 stream:{ 38 manage:false 39 , enabled: false 40 } 41 } 42 } 43 } 44 } 45 , shows: { 46 streamTimer: { 47 enabled: true 48 , tickRate: 100 49 } 50 } 51 }); 52 </script> 53 54 <!-- Code for WebCam END --> 55 56 <br> 57 </body> 58 </html> 59 当前CPU温度: 60 <?php 61 $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 62 $color = "#060"; // default colour 63 if($temp >= 60000) { $color = "#F00"; } //set to red if over 60 degrees (is in milliDegrees) 64 elseif($temp >= 50000) { $color = "#FC0"; } // set to yellow if over 50 degrees 65 echo "<span style=\"color:".$color.";\">".($temp/1000)."°C / ".(($temp/1000)+271.15)."K</span>"; 66 ?> 67 <br /> 68 当前CPU主频: 69 <?php 70 $freq = intval(file_get_contents("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")); 71 echo ($freq/1000)."MHz"; // covert to MHz from kHz 72 ?> 73 <br /> 74 运行时间: 75 <?php 76 // Grab uptime output 77 $uptime_array = explode(" ", exec("cat /proc/uptime")); 78 $seconds = round($uptime_array[0], 0); 79 $minutes = $seconds / 60; 80 $hours = $minutes / 60; 81 $days = floor($hours / 24); 82 $hours = floor($hours - ($days * 24)); 83 $minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60)); 84 $seconds = floor($seconds - ($days * 24 * 60 * 60) - ($hours * 60 * 60) - ($minutes * 60)); 85 $uptime_array = array($days, $hours, $minutes, $seconds); 86 $uptime = ($days . " days " . $hours . " hours " . $minutes . " minutes" ); 87 echo $uptime; ?> 88 <br /> 89 系统时间: 90 <?php 91 // Get the Time 92 $time = (exec("date +'%d %b %Y - %T %Z'")); 93 echo $time; ?> 94 <br /> 95 96 <!-- Network-Data: --> 97 获取网络数据: 98 <?php 99 // Get Network-Data 100 $RX = (exec("ifconfig wlan0 | grep 'RX bytes'| cut -d: -f2 | cut -d' ' -f1")); 101 $TX = (exec("ifconfig wlan0 | grep 'TX bytes'| cut -d: -f3 | cut -d' ' -f1")); 102 echo $RX; $TX; ?> 103 <br /> 104 <br> 105 <?php 106 $ip = $_SERVER['REMOTE_ADDR']; 107 $hostaddress = gethostbyaddr($ip); 108 $browser = $_SERVER['HTTP_USER_AGENT']; 109 $referred = $_SERVER['HTTP_REFERER']; // a quirky spelling mistake that stuck in php 110 111 print "<strong>IP地址:</strong><br />\n"; 112 print "$ip<br /><br />\n"; 113 print "<strong>主机地址:</strong><br />\n"; 114 print "$hostaddress<br /><br />\n"; 115 print "<strong>浏览器信息:</strong>:<br />\n"; 116 print "$browser<br /><br />\n"; 117 print "<strong>Where you came from, if you clicked on a link to get here</strong>:<br />\n"; 118 if ($referred == "") { 119 print "Page was directly requested"; 120 } 121 else { 122 print "$referred"; 123 } 124 ?> 125 <br />
保存退出
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