首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么不能用hls url打开小溪?

为什么不能用hls url打开小溪?
EN

Unix & Linux用户
提问于 2021-01-12 01:25:00
回答 2查看 908关注 0票数 0

我根据nginx官方手册在本地pc上构建RTMP服务器:

undefined

我的nginx设置:

代码语言:javascript
复制
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:

代码语言:javascript
复制
output="rtmp://127.0.0.1:1935/live/sample"  

按下网络摄像机:

代码语言:javascript
复制
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -c:v libx264 -f flv $output

使用rtmp协议拉出流:

代码语言:javascript
复制
ffplay rtmp://127.0.0.1:1935/live/sample

我成功地拿到了录像。

使用hls协议拉出流:

代码语言:javascript
复制
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段中的代码段是什么意思?

代码语言:javascript
复制
    server { 
        listen 80; 
        location /tv { 
            root /mnt/hls; 
        } 
    }

我应该在哪里mkdir /tv

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2021-01-14 21:03:40

变化

代码语言:javascript
复制
hls_path /mnt/hls;

代码语言:javascript
复制
hls_path /mnt/hls/tv;

该流将在http://127.0.0.1/tv/sample.m3u8上可用。

票数 1
EN

Unix & Linux用户

发布于 2021-01-15 10:03:44

在http和rtmp之间有一种关系,为hls推送url和拉url。第一组设置工作良好。

代码语言:javascript
复制
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; 
        } 

它还可以编写成下列对,其功能如下:

代码语言:javascript
复制
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; 
        } 
票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/628717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档