linux就该这么学pdf免费下载
阿里云服务器的安装方法
sudo yum install git gcc make pcre-devel openssl-devel
下载nginx扩展
git clone git://github.com/arut/nginx-rtmp-module.git
下载nginx
wget http://nginx.org/download/nginx-1.12.0.tar.gz
tar xzf nginx-1.12.0.tar.gz
cd nginx-1.12.0
安装 nginx 和 nginx-rtmp
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module make make install
启动nginx
sudo /usr/local/nginx/sbin/nginx
在nginx配置下写入以下的内容
vi /usr/local/nginx/conf/nginx.conf
内容如下
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
# sample handlers
#location /on_play {
# if ($arg_pageUrl ~* localhost) {
# return 201;
# }
# return 202;
#}
#location /on_publish {
# return 201;
#}
#location /vod {
# alias /var/myvideos;
#}
# rtmp stat
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# you can move stat.xsl to a different location
root /usr/build/nginx-rtmp-module;
}
# rtmp control
location /control {
rtmp_control all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
rtmp {
server {
listen 1935;
ping 30s;
notify_method get;
application myapp {
live on;
# sample play/publish handlers
#on_play http://localhost:8080/on_play;
#on_publish http://localhost:8080/on_publish;
# sample recorder
#recorder rec1 {
# record all;
# record_interval 30s;
# record_path /tmp;
# record_unique on;
#}
# sample HLS
#hls on;
#hls_path /tmp/hls;
#hls_sync 100ms;
}
# Video on demand
#application vod {
# play /var/Videos;
#}
# Video on demand over HTTP
#application vod_http {
# play http://localhost:8080/vod/;
#}
}
}
重启停止nginx:
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
在服务器上运行
ffmpeg -re -i /var/Videos/test.mp4 -c copy -f flv rtmp://localhost/myapp/mystream
```
Streaming and encoding audio (AAC) and video (H264), need `libx264` and `libfaac`
ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libfaac -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream
Streaming and encoding audio (MP3) and video (H264), need `libx264` and `libmp3lame`
ffmpeg -re -i /var/Videos/test.mp4 -c:v libx264 -c:a libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream
Streaming and encoding audio (Nellymoser) and video (Sorenson H263)
ffmpeg -re -i /var/Videos/test.mp4 -c:v flv -c:a nellymoser -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream
Publishing video from webcam (Linux)
ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -an -f flv
rtmp://localhost/myapp/mystream
Publishing video from webcam (MacOS)
ffmpeg -f avfoundation -framerate 30 -i "0" -c:v libx264 -an -f flv rtmp://localhost/myapp/mystream
Playing with ffplay
ffplay rtmp://localhost/myapp/mystream
```
Publishing and playing with flash
See test/rtmp-publisher
directory for test flash applets and html.
参考文档:https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp
转载请注明:谷谷点程序 » centos安装rtmp服务器的方法