首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何减少本地网络中的延迟,使用nginx和rtmp模块?

如何减少本地网络中的延迟,使用nginx和rtmp模块?
EN

Stack Overflow用户
提问于 2016-12-30 19:37:10
回答 1查看 4.5K关注 0票数 0
代码语言:javascript
复制
here is my config file:


#user  nobody;
worker_processes  1;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

    location /stat.xsl {

    }

    # rtmp control
    location /control {
        rtmp_control all;
    }

    location /hls {
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }
        root F:/PD/Temp;
        add_header Cache-Control no-cache;
        add_header Access-Control-Allow-Origin *;
    }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }





    }


}
rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        buflen 10s;

        application live {
            allow publish all;
            allow play all;
            live on;
            record off;
            drop_idle_publisher 5s;

            hls on;
            hls_sync 100ms;
            hls_path F:/PD/Temp/hls;
            hls_fragment 2s;
            hls_playlist_length 10m;
        }
    }
}

在使用adobe实时媒体编码器和obc作为编码器时,我尝试使用vlc和浏览器中的rtmp播放器。两者都给了我可变的延迟。那么,我在哪里可以调整以减少延迟。我只想要零延迟,我的应用程序将完全是本地(LAN)没有互联网流

EN

回答 1

Stack Overflow用户

发布于 2017-02-07 22:26:16

在这方面,有三个因素很重要:

1)播放列表的大小(以秒为单位)

如果播放列表有10秒(您的列表有10分钟),rtmp模块必须等待10秒的摄入流才能生成10秒的片段,对吗?如果rtmp帧尚未到达,则无法生成10秒的片段。

2)第二代片段的大小

当你的播放列表准备好交付时(比如说10秒),你必须有10秒的片段。因此,您有以下选择: 10 /1=1片段/10秒,10 /2=2片段/5秒,10 /3=3片段/ 3.33秒(这不是很好),但.

3) 关键帧

每个片段被一个关键帧打破,所以如果你的播放列表有10秒的话,你必须调整你的编码器,每隔1,2或5秒添加一个关键帧。如果您的播放列表有12秒,您必须调整您的编码器,以添加一个关键帧每1,2,3,4,6或12。

简历:

代码语言:javascript
复制
hls_playlist_length 6s;
hls_fragment 2s;

包含3个片段的播放列表的enconder关键帧=2。

延迟= +- 8秒。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41401787

复制
相关文章

相似问题

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