nginx rtmp 推流 vlc 拉流
前置
- vlc 软件
- ffmpeg
- nginx-full rtmp-moudle
效果
- 推流
- 拉流
安装nginx
// 先克隆到本地
brew tap denji/homebrew-nginx
// 在安装
brew install nginx-full --with-rtmp-module
// 修改配置
* /usr/local/etc/nginx/nginx.conf
nginx 配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /usr/local/var/www;
add_header Cache-Control no-cache;
}
}
}
rtmp {
server {
listen 1935;
application rtmplive {
live on;
max_connections 1024;
}
application hls{
live on;
hls on;
hls_path /usr/local/var/www/hls;
hls_fragment 1s;
}
}
}
启动服务
sudo brew services restart denji/nginx/nginx-full
检查服务是否启动
直接推流rtmp
ffmpeg -re -i video1.mp4 -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 rtmp://localhost:1935/rtmplive/test
直接推流hls
ffmpeg -re -i video1.mp4 -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 rtmp://localhost:1935/hls/test
MP4 to hls
ffmpeg -i video1.mp4 -hls_time 10 -hls_list_size 0 -hls_segment_filename /usr/local/var/www/hls/test_%05d.ts /usr/local/var/www/hls/test.m3u8
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/18022701