当前位置: 首页 > >

Ê÷Ý®ÅÉ£º´î½¨¼òÒ×ËÞÉá¼à¿Ø

发布时间:

Ç°ÑÔ

¹ºÂòÁËÊ÷Ý®ÅÉ×÷ΪLinuxÈëÃźó£¬Ëü¾ÍÒ»Ö±±»ÏÐÖÃÁË£¬Õ⼸ÌìÅöÇɸ㵽һ¿éÓ²ÅÌ£¬¾ÍÓÃËüÀ´×öÒ»¸ö¼à¿ØÍæÍæ°É¡£


¼¼Êõµã£º


ffmpeg ÀûÓÃÊ÷Ý®ÅɵÄÓ²H.264±àÂëÆ÷תÂëºóÍÆÁ÷NginxµÄrtmp°æ±¾crontab ¶¨Ê±ÈÎÎñ

³É¹ûչʾ£º






¼ÏñÎļþ£¬¿É×Ô¶¯É¾³ý



?






¿ÉÒÔÖ±²¥£¬»òÔÚÏß¹Û¿´



°²×°Óëµ÷ÊÔÉãÏñÍ·

ÕâÒ»²½ÔÚÍøÉÏÓÐÐí¶à²Î¿¼£¬Ïêϸ¿ÉÒԲο¼¡¶Ê÷Ý®ÅÉ¿ª·¢±Ê¼Ç - µÚ1²¿·Ö »ù´¡Æª¡·µÚ6Õ Ê÷Ý®ÅÉÉãÏñÍ·²Ù×÷


¿ÉÒÔÀûÓÃÒ»ÏÂÃüÁîÅÄÕÕ²âÊÔÒ»ÏÂÓÐûÓа²×°ÕýÈ·


raspistill -t 2000 -o image.jpg

±ÊÕßÔÚÕâÀï°ÑÉãÏñÍ·×°·´ÁË£¬²»¹Üû¹Øϵ±àÂëµÄʱºò·­×ªÒ»Ï¾ͺÃÁË¡£


°²×°FFmpegÓërtmp°æµÄnginx

Ò»ÏÂÄÚÈÝÒýÓÃ×ÔÓÃÊ÷Ý®ÅÉ×ö RTMP Á÷Ö±²¥·þÎñÆ÷£¬¿ÉÍÆËÍÖÁ¶·ÓãÖ±²¥



ÎÒÃÇÓà nginx ¼ÓÉÏ nginx-rtmp-module Ä£¿é×÷Ϊ RTMP ·þÎñ¶Ë¡£ÕâÀïÏÈ°²×° nginx È»ºóÔÙÒƳýËü£¬Ä¿µÄÊÇÀûÓÃÕâ¸ö¹ý³Ì°É nginx Ïà¹ØµÄÒÀÀµ°²×°ºÃ²¢É趨ºÃϵͳ»·¾³¡£Õâ¸öͨ¹ý apt °²×°µÄ nginx ²¢²»ÄÜÖ±½ÓʹÓã¬ÒòΪËû²¢²»°üº¬ÎÒÃÇÐèÒªµÄ RTMP Ä£¿é£¬ËùÒÔ½«ËüÒƳý¡£¶øºóÎÒÃÇÊÖ¹¤ÏÂÔØ nginx ºÍ nginx-rtmp-module Ä£¿éÔ´ÂëÀ´ÊÖ¹¤±àÒë°²×°£¬ÒÔ»ñµÃÎÒÃÇ×îÖÕÐèÒªµÄ·þÎñ¶Ë¡£


sudo apt-get update
#°²×° nginx
sudo apt-get -y install nginx
#ÒƳý nginx
sudo apt-get -y remove nginx
sudo apt-get clean
#Çå¿Õ nginx µÄÅäÖÃÎļþ
sudo rm -rf /etc/nginx/*
#°²×°±àÒëÓõÄÄ£¿é
sudo apt-get install -y curl build-essential libpcre3 libpcre3-dev libpcre++-dev zlib1g-dev libcurl4-openssl-dev libssl-dev
#´´½¨´æ·ÅÍøÒ³µÄĿ¼¸ø nginx ʹÓÃ
sudo mkdir -p /var/www
#´´½¨±àÒëÓõÄĿ¼
mkdir -p ~/nginx_src
cd ~/nginx_src
#ÏÂÔØ nginx Ô´Âë°ü
wget http://nginx.org/download/nginx-1.11.8.tar.gz
#ÏÂÔØ nginx-rtmp-module Ô´Âë°ü
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar -zxvf nginx-1.11.8.tar.gz
unzip master.zip
cd nginx-1.11.8
#É趨±àÒë²ÎÊý
./configure --prefix=/var/www --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_ssl_module --without-http_proxy_module --add-module=/home/pi/nginx_src/nginx-rtmp-module-master
#¿ªÊ¼±àÒë°²×°
make
sudo make install

±È½ÏÂþ³¤µÄµÈ´ýÖ®ºó£¬±àÒë°²×°½áÊø¡£Õâʱ¿ÉÒÔ²âÊÔ nginx ÊÇ·ñ°²×°ºÃ¡£


nginx -v

Õý³£µÄ?£¬??ʾ nginx µÄ°æ±¾¡£


ÅäÖÃ nginx¡£


/etc/nginx/nginx.conf

ÔÚĩβÌí¼ÓÈçÏÂÅäÖãº


rtmp {
server {
listen 1935;
#chunk_size 4096;
application live {
live on;
record off;
}
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
}
}

Ö*ô nginx ·þÎñ¡£


sudo service nginx start

ûÓдíÎóÌáʾ¾Í±íʾ³É¹¦ÁË¡£
µ½ÕâÀï nginx ºÍ RTMP Ä£¿é¶¼×¼±¸ºÃÁË¡£?


?



°²×°FFmpeg


sudo apt-get install ffmpeg

?ÍÆÁ÷µ½±¾µØ£¬È»ºó±£´æ

ÎÒÃÇÀûÓÃÇ¿´óµÄffmpeg½«ÉãÏñÍ·µÄÅÄÉãÊý¾Ýת»¯ÎªÁ÷ýÌ壬ȻºóÍÆÁ÷¸ø×Ô¼º¡£Èç¹ûÏëÍÆÁ÷µ½ÆäËüµØ·½µÄ»°£¬¸´ÖÆÒ»·ÝÁ÷ÍÆÁô¸øÆäËüµØ·½Ò²ÊÇ¿ÉÒԵġ£¼ÇµÃ°ÑÕâ¸ö½Å±¾¼ÓÈërc.local¿ª»úÆô¶¯²¢¶ªµôÊä³ö¡£


ffmpeg -ss 0 -i /dev/video0 -vf vflip -c:v h264_omx -an -r 8 -f flv rtmp://127.0.0.1:1935/live/test
#-ss ¿ªÊ¼Ê±¼ä£¬ÓÉÓÚÊÇÖ±²¥£¬ÆäʵÕâ¸ö²ÎÊýÓ¦¸ÃûÓÐÓÃ
#-i ÊÇÊÓƵԴ ÕâÀïÖ¸ÉãÏñÍ·
#-vf vflip ·­×ª¹ýÂËÆ÷£¬°Ñ×°µ¹Á˵ÄÉãÏñÍ·µÄ»­ÃæÕý¹ýÀ´
#-c:v ¶ÔÓÚµÚÒ»¸öÊÓƵÁ÷ h264_omx ÕâÊÇÊ÷Ý®ÅɵÄÓ²¼þ±àÂëÆ÷
#-an ¾²Òô£¬·´Õý±¾À´¾ÍûÓÐÉùÒô
#-r ¿ØÖÆÖ¡ÂÊ£¬¼õСÎļþ´óСÓë´¦ÀíѹÁ¦
#-f Ç¿ÖÆ°ü×°¸ñʽ£¬ÕâÀï°ü×°³Éflv£¬²»ÖªµÀΪɶÎÒµÄÁ÷ýÌå²¥·ÅÆ÷Ö»ÈÏÕâ¸ö¸ñʽ
#×îºóÊÇÍÆÁ÷µØÖ·£¬ÕâÀïÍÆÁ÷?±¾»úµÄNginx

ÕâÒ»²½¹ýºó£¬Äã¿ÉÒÔÓÃÁ÷ýÌå²¥·ÅÆ÷£¨ÀýÈçpotplayerµÈµÈ£©·ÃÎÊÒ»ÏÂÊ÷Ý®ÅɵÄrtmp://127.0.0.1:1935/live/test£¬¿´¿´ÓÐûÓÐÊÓƵÁ÷£¬¼ÙÈçÒ»Çж¼Ã»ÓÐÎÊÌâµÄ»°£¬¾Í¿ÉÒÔ¿ªÊ¼´æ´¢»ñÈ¡µÄÊÓƵÁ÷ÁË¡£


cur_date="`date +%Y-%m-%d_%H:%M:%S`"
#»ñÈ¡Ò»¸öʱ¼ä×÷ΪÎļþÃû
sudo ffmpeg -i rtmp://127.0.0.1:1935/live/test -t 01:00:30 -c copy /media/pi/Repository/$cur_date.mp4 -timestamp now
#ÀûÓÃffmpeg±£´æһСʱµÄÁ÷

½ÓÏÂÀ´¾ÍÊÇÌí¼Ó¶¨Ê±ÈÎÎñ£¬ÈÃÕâ¸öShell½Å±¾Ã»Ð¡Ê±ÔËÐÐÒ»´Î£¬¹ØÓÚcrontabµÄϸ½Ú¿ÉÒÔ¿´ Õâ¸ö


crontab -e

½øÈ붨ʱÈÎÎñ±à¼­Ä£Ê½£¬¼ÓÈ루¼ÇµÃдÄã×Ô¼ºµÄ½Å±¾Â·¾¶£©?£º


0 */1 * ?* ? * ? ? /home/pi/SaveSteam.sh

°´ÕÕÎÒµÄÊÓƵÖÊÁ¿£¬Ò»ÖÜ´ó¸Å»áÅÄÉã1GB×óÓÒµÄÊÓƵ£¬ÕâÃ÷ÏÔÓеã¶ù´ó£¬ËùÒÔÎÒÿÌìÇåÀíÒ»´ÎÒ»ÖÜÇ°ÅÄÉãµÄÊÓƵ£¬ÏÂÃæ¼òµ¥µÄshell½Å±¾ÏàÐÅ´ó¼Ò¶¼¿´µÃ¶®£º


lastWeek=`date -d last-week +%Y-%m-%d`

for e in `sudo ls /media/pi/Repository/$lastWeek*.mp4`
do
sudo rm -f "$e"
# echo $e
done

È»ºó±à¼­¶¨Ê±ÈÎÎñ¼ÓÈ룺


0 5 * * * /home/pi/DeleteOldFlv.sh
#ÿÌìÁ賿ÎåµãÔËÐÐ

½áβ

Ò»¸ö¼òÒ׵ļà¿Øϵͳ£¬ÕâÑù¾Í²î²»¶à´î½¨ºÃÁË¡£


˳±ãÌáһϣ¬ÀûÓÃnginxµÄ×Ô¶¯Áгö¹¦ÄÜ¿ÉÒÔ°ÑijһĿ¼ÏµÄÎļþÈ«²¿ÁгöÀ´£¬¶øÏÖ´ú´ó²¿·Öä¯ÀÀÆ÷¶¼×Ô´ø²¥·ÅÆ÷£¬ÕâÑù¾Í¿ÉÒÔ²»Óò¥·ÅÆ÷À´²é¿´ÒѾ­Â¼ÖƺõÄÊÓƵÁË¡£



¸Ðл¿´µ½ÕâÀïµÄÄ㣬ϣÍû¶ÔÄãÓÐËù°ïÖú~?



友情链接: