flutter_vlc_player
flutter_vlc_player copied to clipboard
Unable to set live video caching to real time for HLS
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.
Hey @hlacikd Did you find any solution to this issue?
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.
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.
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.