This PR adds the support for multi-period concatenation for HLS, using #EXT-X-DISCONTINUITY between periods.
The new file m3u8_concater.py has the classes used to parse the m3u8 files and reduce multiple files of them into one concatenated file.
HLSConcater is just an API that is exposed to the PeriodConcatNode for abstraction.
MasterPlaylist is a class representing a master hls playlist, the parsing part happens in the __init__ method, creates a MediaPlaylist object for each media(video,text,audio) playlist found in this master playlist, the stream attributes for each playlist is passed to the MediaPlaylist object and stored in it.
MediaPlaylist is a class representing an hls media playlist, the playlist gets parsed in the __init__ method, the biggest part of the playlist is saved mostly unchanged in the self.content variable, but the media segment paths get updated to point to the new relative path of the media segment.
The playlist concatenation methods are the static methods in the MediaPlaylist class (concat_sub, concat_aud, concat_vid, concat_aud_only(to handle the audio-only stream cases)).
No period concatenation is performed if an inconsistent media in periods is detected(e.g. one period has video and one does not).
Things that need addressing:
1- When Shaka Player gets an HLS master playlist containing unsupported and supported audio codecs, it breaks, this happens with:
audio-only playlists with and without concatenation,
video+audio playlists that have been concatenated, but does't happen for the un-concatenated playlists with the same set of codecs, this may have to do with the discontinuities inserted between periods.
2- When Shaka Packager receives an audio-only period to package, it normally creates a stream variant(stream-inf) for each media(audio) playlist generated, but when this audio-only input has one subtitles playlist along with the audio, Shaka-Packager doesn't create the stream-inf playlists, for the current implementation, this will create an error in the HLS concater, we can escape this period as a solution if it has no stream-infs, periods with no stream-inf we can't know its bitrates and codecs and isn't playable in Shaka Player.
This PR adds the support for multi-period concatenation for HLS, using
#EXT-X-DISCONTINUITY
between periods.The new file
m3u8_concater.py
has the classes used to parse the m3u8 files and reduce multiple files of them into one concatenated file.HLSConcater
is just an API that is exposed to thePeriodConcatNode
for abstraction.MasterPlaylist
is a class representing a master hls playlist, the parsing part happens in the__init__
method, creates aMediaPlaylist
object for each media(video,text,audio) playlist found in this master playlist, the stream attributes for each playlist is passed to theMediaPlaylist
object and stored in it.MediaPlaylist
is a class representing an hls media playlist, the playlist gets parsed in the__init__
method, the biggest part of the playlist is saved mostly unchanged in theself.content
variable, but the media segment paths get updated to point to the new relative path of the media segment.The playlist concatenation methods are the static methods in the
MediaPlaylist
class (concat_sub
,concat_aud
,concat_vid
,concat_aud_only
(to handle the audio-only stream cases)).No period concatenation is performed if an inconsistent media in periods is detected(e.g. one period has video and one does not).
Things that need addressing: 1- When Shaka Player gets an HLS master playlist containing unsupported and supported audio codecs, it breaks, this happens with:
2- When Shaka Packager receives an audio-only period to package, it normally creates a stream variant(stream-inf) for each media(audio) playlist generated, but when this audio-only input has one subtitles playlist along with the audio, Shaka-Packager doesn't create the stream-inf playlists, for the current implementation, this will create an error in the HLS concater, we can escape this period as a solution if it has no stream-infs, periods with no stream-inf we can't know its bitrates and codecs and isn't playable in Shaka Player.