flutter_vlc_player icon indicating copy to clipboard operation
flutter_vlc_player copied to clipboard

Unable to set live video caching to real time for HLS

Open hlacikd opened this issue 3 years ago • 4 comments

We have an HLS source with playlist.m3u8 up to 5s in past. vlc_player always caches maximum available history (5s). How can we set vlc_player to cache as less as possible, to achieve near live playback.

hlacikd avatar May 24 '22 08:05 hlacikd

Hey @hlacikd Did you find any solution to this issue?

orenagiv avatar Jun 05 '22 15:06 orenagiv

unfortunatelly not - it always caches maximum amount of seconds that HLS source can provide. If we set our HLS to have 5s cache, than VLC caches 5s, if we set our HLS server to have 10s cache, than VLC caches 10s and after it plays.

hlacikd avatar Jun 05 '22 16:06 hlacikd

Hmm… interesting 🤔

Later on today I’ll post here everything I’ve tried so far for reference, while I’m looking for a solution / alternative.

orenagiv avatar Jun 05 '22 16:06 orenagiv

Hey @hlacikd, Sorry for my late reply.

I’m still experimenting with this, and haven’t reached consistent results yet.

Need some more time.

In my case, I have an H264 raw byte-stream as the input pipe. So I’m passing it through FFMPEG using this (amazing) Flutter package: https://pub.dev/packages/ffmpeg_kit_flutter To produce an HLS output pipe.

I then use the Flutter VLC package to play the HLS output.

I’m experimenting with the HLS chunks sizes and list size, as well as various other properties as defined here: https://www.ffmpeg.org/ffmpeg-formats.html#Format-Options (Search for max_delay, chunk_size, chunk_duration, hls_time, hls_list_size).

I found some nice explanations here: https://www.wowza.com/blog/hls-latency-sucks-but-heres-how-to-fix-it And some leads here: https://stackoverflow.com/questions/43571220/reduce-latency-for-hls-streaming-ffmpeg

So far I’ve managed to reduce the latency (in my case) from ~10 seconds to ~4 seconds. But there are many properties to play with, and I’m only half way through… lots of trial and error…

P.S. It seems that the VLC package ignores the caching properties that it offers. However, it does have two properties that make a little difference:

  • dropLateFrames
  • skipFrames

See docs here: https://pub.dev/documentation/flutter_vlc_player_platform_interface/latest/flutter_vlc_player_platform_interface/VlcVideoOptions-class.html

I’ve also tried all the available video players I could find on pub.dev (e.g. video_player, flutter_playout, native_video_view, etc.). But in my case none of them were able to play a local HLS stream. Only with the flutter_vlc_player I’ve managed get it to work, but with latency.. :)

I’ll update again once I have additional info.

orenagiv avatar Jun 07 '22 21:06 orenagiv