我根据nginx官方手册在本地pc上构建RTMP服务器:
我的nginx设置:
sudo vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
error_log logs/error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application live {
live on;
interleave on;
hls on;
hls_path /mnt/hls;
hls_fragment 15s;
}
}
}
http {
default_type application/octet-stream;
server {
listen 80;
location /tv {
root /mnt/hls;
}
}
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
text/html html;
}
}设置rtmp url:
output="rtmp://127.0.0.1:1935/live/sample" 按下网络摄像机:
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -c:v libx264 -f flv $output使用rtmp协议拉出流:
ffplay rtmp://127.0.0.1:1935/live/sample我成功地拿到了录像。
使用hls协议拉出流:
ffplay http://127.0.0.1/live/sample
HTTP error 404 Not Found
http://127.0.0.1:80/live/sample.m3u8: Server returned 404 Not Found
#It can't get video with browser.怎么修呢?以下http段中的代码段是什么意思?
server {
listen 80;
location /tv {
root /mnt/hls;
}
}我应该在哪里mkdir /tv?
发布于 2021-01-14 21:03:40
变化
hls_path /mnt/hls;至
hls_path /mnt/hls/tv;该流将在http://127.0.0.1/tv/sample.m3u8上可用。
发布于 2021-01-15 10:03:44
在http和rtmp之间有一种关系,为hls推送url和拉url。第一组设置工作良好。
Pull url
http://127.0.0.1/tv/sample.m3u8
Push url
rtmp://127.0.0.1:1935/live/sample
location /tv {
root /mnt/hls;
}
rtmp setting
application live {
live on;
interleave on;
hls on;
hls_path /mnt/hls;
}
http setting
location /tv {
root /mnt/hls;
} 它还可以编写成下列对,其功能如下:
Pull url
http://127.0.0.1/tv/sample.m3u8
Push url
rtmp://127.0.0.1:1935/tv/sample
location /tv {
root /mnt;
}
rtmp setting
application tv {
live on;
interleave on;
hls on;
hls_path /mnt/tv;
}
http setting
location /tv {
root /mnt/hls;
} https://unix.stackexchange.com/questions/628717
复制相似问题