-
Notifications
You must be signed in to change notification settings - Fork 0
Optimize playlist handling #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@copilot I would like to further optimize this branch. When the client gets the .m3u8 playlist, it will then request a segment, from this point, I want to precache any remaining segments in the playlist. When the client pulls the next .m3u8 playlist, find the next track that needs cached and proceed. when the client requests a cached segment, we can use it, then drop it. Playlists, and cached segments should be stored against the current channel_id. |
* Initial plan * Implement segment precaching for playlist optimization Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Address code review feedback for segment precaching - Fix regex to handle whitespace/control characters after .aac - Move segment extraction before playlist modification - Remove noisy trace log of all segments - Optimize to only search from last requested segment to end - Add total cache size to logging output Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Add segment count to cache logging Include number of cached segments in addition to total size in log messages Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
|
plugin-SiriusXM/Plugins/SiriusXM/Bin/sxm.pl Lines 991 to 1015 in 2f656b5
Uses a default of dropping 3 segments to force start further behind live (ffmpeg defaults to 3 segments behind live)
|
* Initial plan * Add configurable segment drop for playlist buffering Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Fix code review issues: typo and numeric comparison Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Use string comparison for consistency with other preferences Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Improve comment clarity for segment drop logic Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Change order on settings page --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
|
@copilot There seems to be an issue with pre-caching. I was set to drop 6 segments, so caching of 8 segments seems about right, however as you can see from the log, it does not iterate through all 8 segments and cache them, it is only keeping one or two in the cache, and 6 or so un-cached. Only caching a couple segments at a time is good, such that it does not block client requests, but it should eventually finish getting uncached tracks 10.01.2026 15:42:47.733] INFO <siriusxm.proxy>: Starting precache of 8 segments for channel thepulse, current cache: 1 segments (0.30 MB) |
…59) * Initial plan * Fix segment pre-caching to cache multiple segments per iteration Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Refactor segment caching to use named constant and simplified loop Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Change log level --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
|
@copilot I want to pre-cache the m3u8 files too. But we need to do a little tracking and scheduling as to when to get it. When processing a new m3u8 file,
Make sure we use the functions in place to get the files from SiriusXM, as they already have proper handling of authentication. |
… timeout, optimizations, HLS compliance, and optional caching control (#60) * Initial plan * Implement m3u8 playlist pre-caching with scheduled updates Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Skip scheduling on first playlist load to avoid bulk segment caching delays Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Add idle timeout to stop refresh and clear cache for inactive channels Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * First load was already stored, use that instead. Fix Copilot Syntax Errors Remove noisy logging * Fix playlist scheduling and background refresh issues Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Fix segment caching to be non-blocking and improve scheduling Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Change logging to output line number Tweak scheduling durations * Change loop and min/max delays * Remove the one second, there is a 30s FFmpeg buffer by default. This lets us get 2 new tracks occasionally. * Optimize EXTINF parsing, add adaptive backoff, and defer segment caching Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Fix scheduling to work on first load while still deferring segment caching Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Tweak playlist delays * Disable all caching when segment_drop is 0 Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Tweak web page to allow 0 setting, and change some strings * Trim playlists and use EXT-X-TARGETDURATION for segment duration Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Always trim playlist from beginning, only drop end segments on first load Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Update all playlist parsing to follow Apple HLS specification Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Optimize playlist handling and fix first-load caching behavior Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Change to medium playlist * Remove playlist middle trimming, keep only segment_drop functionality Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
|
@copilot SiriusXM has two different servers for distributing m3u8 playlists and segments LIVE_PRIMARY_HLS is the default. LIVE_SECONDAY_HLS is the backup. If we have problems getting data from the primary, we need to seamlessly fail over to the secondary server. Create a method to track which server is currently being used and then a mechanism to switch if one server continues to have problems. |
…points (#61) * Initial plan * Implement HLS server failover mechanism Add seamless failover between LIVE_PRIMARY_HLS and LIVE_SECONDARY_HLS servers: - Track current active server and consecutive failure counts per server - Automatically switch to backup server after 3 consecutive failures - Record success/failure for all playlist and segment requests - Switch back to primary after 5-minute cooldown period when secondary is stable - Update all URL construction to use current active server - Add comprehensive logging for server switches and failures Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Simplify HLS failover and fix playlist selection Based on feedback, simplified the failover implementation: - Removed cooldown period logic (no time-based recovery) - Changed to per-channel failover tracking (not global) - Reset to primary server when starting new playback session - Stay on current server for duration of stream Fixed playlist URL selection: - Parse playlist array for both primary and secondary entries - Select appropriate playlist based on channel's current server - Remove incorrect URL substitution logic - URLs come pre-formed from SiriusXM API Implementation now: - Tracks which server each channel is using (primary/secondary) - Switches to backup after 3 consecutive failures - Switches back to primary on opposite server failures - Automatically resets to primary when playback restarts Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com> * Minor logging changes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
No description provided.