ffmpegstreamingvideo-streaminghttp-live-streaming

Reduce Latency For HLS Streaming FFMPEG


I used hls streaming via ffmpeg.
In start of streaming delay exists for few seconds.
when I want to have straming from a 4k video in stream during very delays exist.
What I can to do?


Solution

  • 4k video

    ...

    In start of streaming delay exists for few seconds

    Yes, of course it does. It takes time to buffer enough data for playback of the very high bitrates. Not only that but your HLS player is typically going to need a few segments before decoding even starts. As @iangetz says, you can reduce the segment length but now you're going to have even more overhead due to all the extra HTTP requests.

    Reduce Latency For HLS Streaming

    Don't use HLS. HLS, nor any other segmented streaming protocol (like DASH) is optimized for low latency. It's optimized for re-use of HTTP CDNs, for playback that can survive a network change (such as when you go from WiFi to LTE), and for client-selectable (often dynamically) quality.

    The very nature of a segmented protocol requires relatively large buffers to be chunked out and then uploaded to the server/CDN individually. This is really useful, but not a good tradeoff if you require low latency.

    If latency matters to you, you need an entirely different technology. Take a look at WebRTC. With this technology, the video streams in real time, codecs are optimized for latency over quality, and reliability is reduced in favor of latency. It also requires a significant investment in distribution infrastructure.

    I can't imagine a situation where someone who cares about 4k video thinking that a reduction in quality is going to be worth the tradeoff for low latency. You cannot have everything you want... you must choose what is actually important to you and optimize from there. If you want low latency, you're going to have to reduce your quality and spend a lot of money and time on infrastructure to support the effort. If you want high quality and reliable streams, you can keep good encoding parameters while using DASH (or HLS) for distrubtion on existing HTTP-based CDNs.