安装模块
请移步 https://cloud.tencent.com/developer/article/2133918
配置文档 https://github.com/arut/nginx-rtmp-module/wiki/Directives
代码语言:javascript复制vi /etc/nginx/nginx.conf
load_module modules/ngx_rtmp_module.so;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application rtmp-live {
live on;
}
}
}
http {
...
}
推流测试
ffmpeg 命令行推流
代码语言:javascript复制ffmpeg -re -stream_loop -1 -i ./55427366_48_0.flv -c copy -f flv rtmp://127.0.0.1:1935/live/stream
OBS推流
拉流测试
VLC
容易失败,失败就多试几次
hls.js
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
</head>
<body>
<video id="video" controls autoplay></video>
<script>
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource('https://pull-hls-f96.douyincdn.com/stage/stream-399947309713982122_or4.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
}
</script>
</body>
</html>