ffmpeg forward stream有3秒延迟

时间:2016-01-28 10:04:16

标签: nginx ffmpeg

我使用模块nginx-rtmp-module的nginx作为实时服务器。

这是示例配置。

    application src {
        live on;
        exec /usr/bin/ffmpeg -re -i rtmp://localhost/src/$name -acodec  copy -vcodec copy -f flv rtmp://localhost/hls/$name
    }
    application hls {
        live on;
        hls on;
        hls_path /tmp/hls;
        hls_fragment 2s;
        hls_playlist_length 8s;

我使用ffmpeg前向流,src频道与hls频道之间的延迟时间约为3秒。

延迟的原因似乎是ffmpeg本身。

使用ffmpeg正向流时,有没有减少延迟的方法?

有什么想法吗?谢谢。

1 个答案:

答案 0 :(得分:2)

HLS格式功能。不可能将滞后减少到零。这是因为服务器创建了一个播放列表,该播放列表由客户端读取并读取视频/音频数据。因此,至少有一个文件要重现。

使用hls_fragmenthls_playlist_length来减少或使用RTMP(FLV)数据格式。 在这里阅读 https://github.com/arut/nginx-rtmp-module/issues/378