-
Notifications
You must be signed in to change notification settings - Fork 464
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
Append file m3u8 #307
Comments
These playlists are similar enough that I think you could just combine the text contents, but strip out the first three tags from the second one to avoid duplicating them. Here is some code to do that; it doesn't assume the number of tags to skip is 3. import m3u8
# Read in the playlists
# playlist_1_text = ...
# playlist_2_text = ...
# Split them into lines
playlist_1_lines = playlist_1_text.splitlines()
playlist_2_lines = playlist_2_text.splitlines()
# Take the lines from playlist 1, then add in any non-duplicates from playlist 2
line_set = set(playlist_1_lines)
combined_lines = playlist_1_lines + [x for x in playlist_2_lines if x not in line_set]
playlist_combined_text = '\n'.join(combined_lines)
# Parse the combined lines to put the media tags back at the top
combined_playlist = m3u8.loads(playlist_combined_text)
combined_playlist_text = combined_playlist.dumps()
print(combined_playlist_text) |
Thank you @bbayles @Trungdo253 does the bbayle's snippet solve your problem? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
file 1.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="1",NAME="none",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="chunklist_5_audio_LQjVYCeD_llhls.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="1"
chunklist_2_video_LQjVYCeD_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="1"
chunklist_1_video_LQjVYCeD_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="1"
chunklist_0_video_LQjVYCeD_llhls.m3u8
file 2.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="5",NAME="none",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="chunklist_5_audio_lHv4VsCh_llhls.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=3628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="5"
chunklist_2_video_lHv4VsCh_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="5"
chunklist_1_video_lHv4VsCh_llhls.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1628000,RESOLUTION=1280x720,FRAME-RATE=30.0,CODECS="avc1.42c01f,mp4a.40.2",AUDIO="5"
chunklist_0_video_lHv4VsCh_llhls.m3u8
i want append mutiple m3u8 to one file m3u8
thank you very much!
sory my english so bad
The text was updated successfully, but these errors were encountered: