1.安装nginx和nginx-rtmp-module
wget http://nginx.org/download/nginx-1.4.0.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git
./configure --add-module=../nginx-rtmp-module-master
make && sudo make install
启动:
sudo /usr/local/nginx/sbin/nginx
2.修改配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
#推流配置
rtmp {
server {
listen 1935;
chunk_size 4000;
application live {
live on;
hls on;
hls_path /home/ubuntu/test;
hls_fragment 5s;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#fcgi配置
server {
listen 80;
listen [::]:80;
server_name 127.0.0.1;
location / {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
}
location ^~ /cgi-bin/entry.cgi/ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}
3.重启nginx
sudo /usr/local/nginx/sbin/nginx -s reload
4.ubuntu使用ffmpeg进行推流
播放视频
ffmpeg -re -i welcom_to_beijing.mp4 -vcodec libx264 -acodec aac -f flv rtmp://192.168.1.10:1935/live/test
获取海康的rtsp流并推给rtmp文章来源:https://www.toymoban.com/news/detail-823061.html
ffmpeg -re -rtsp_transport tcp -i "rtsp://admin:XG123456@192.168.1.68:554/h264/ch1/main/av_stream" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec copy -f flv -s 1920*1080 -q 10 "rtmp://10.10.18.186:1935/live/test"
5.window端vlc软件拉流,输入地址:rtmp://192.168.1.10:1935/live/test 即可看到ubuntu推出的视频文章来源地址https://www.toymoban.com/news/detail-823061.html
到了这里,关于ubuntu nginx+rtmp配置及简单测试的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!