nginx-rtmp流媒体测试

nginx-rtmp流媒体测试

看网上说可以用 nginx 做流媒体服务器,测测试试

安装工具

sudo apt install nginx libnginx-mod-rtmp
nginx -V

启动 nginx

在 /etc/nginx/conf.d 中添加 rtmp 配置项

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;

            hls on;
            hls_fragment 5s;
            hls_path /var/www/html/live;

            dash on;
            dash_path /var/www/html/dash;
        }
    }
}

重新加载

sudo nginx -s reload

报错:

nginx: [emerg] "rtmp" directive is not allowed here in /etc/nginx/conf.d/rmtp.conf:1

找了半天原因,原来是加的位置不对。不能加到 conf.d 文件夹下。因为这里的都在 http 下,而 rtmp 是和 http 平级的。得直接加到 nginx.conf 中。

obs 模拟推流

obs 设置->流->自定义流媒体服务器(推流用)
url rtmp://localhost:1935/live
流名称 test

主窗口->来源,添加屏幕捕获

开始推流

测试播放

url与配置的应用名和文件路径匹配

ffplay rtmp://localhost:1935/live/test
ffplay http://localhost/live/test.m3u8
ffplay http://localhost/dash/test.mpd

网页video.js...完成dash和hls


Share Tweet Send
0 Comments
Loading...
You've successfully subscribed to 隔窗听雨
Great! Next, complete checkout for full access to 隔窗听雨
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.
豫ICP备19045256号-1