Skip to content
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

support multiple #EXT-X-MAP tags #4164

Closed
wants to merge 3 commits into from

Conversation

TakuSemba
Copy link
Contributor

@TakuSemba TakuSemba commented Apr 22, 2018

I'm trying to play HLS + fmp4 contents, and it didn't work when the HLS playlist has multiple contents separated by #EXT-X-DISCONTINUITY.

It looks like HlsPlaylistParser.java captures the only one initialSegment the parser found at last eventually, but I think there is a situation where multiple init files exist separated by #EXT-X-DISCONTINUITY.

According to the spec, it says

The EXT-X-MAP tag specifies how to obtain the Media Initialization
Section (Section 3) required to parse the applicable Media Segments.
It applies to every Media Segment that appears after it in the
Playlist until the next EXT-X-MAP tag or until the end of the
playlist.

what shown below is what i tested for this pr.

content description

this HLS url is available and it can be reproduced, this is what I prepared.

playlist.m3u8

#EXTM3U
#EXT-X-VERSION:6
## Generated with https://github.com/google/shaka-packager version 2453c93f91-release
#EXT-X-TARGETDURATION:12
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI="video1/init.mp4"
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;base64,AAAAN3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABciD3Rlc3QgY29udGVudCBpZEjj3JWbBg==",KEYID=0x6D76F25CB17F5E16B8EAEF6BBF582D8E,KEYFORMATVERSIONS="1",KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
#EXTINF:10.000,
video1/1.m4s
#EXTINF:10.792,
video1/2.m4s
#EXTINF:9.792,
...
#EXTINF:10.000,
video1/59.m4s
#EXTINF:5.500,
video1/60.m4s
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=AES-128,URI="http://160.16.54.236:8081/nondrm/hls-two-encryption/test2.key",IV=0x0123456789ABCDEF0123456789ABCDEF
#EXT-X-MAP:URI="video2/init.mp4"
#EXTINF:3.436770,
video2/segment_0000.mp4
#EXTINF:4.004004,
video2/segment_0001.mp4
#EXTINF:3.236570,
video2/segment_0002.mp4
#EXTINF:7.340674,
...
video2/segment_0030.mp4
#EXTINF:3.303303,
video2/segment_0031.mp4
#EXT-X-ENDLIST

how I made each content.

the first content (widevine) using shaka-packager

i used test widevine test credential (https://google.github.io/shaka-packager/html/tutorials/widevine.html#widevine-test-credential)

packager \
'in=input1.mp4,stream=video,init_segment=video1/init.mp4,segment_template=video1/$Number$.m4s,playlist_name=video.m3u8' \
  --hls_master_playlist_output playlist2.m3u8 \
  --enable_widevine_encryption \
  --key_server_url https://license.uat.widevine.com/cenc/getcontentkey/widevine_test \
  --content_id 7465737420636f6e74656e74206964 \
  --signer widevine_test \
  --aes_signing_key 1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9 \
  --aes_signing_iv d58ce954203b7c9a9a9d467f59839249 \
  --protection_scheme cenc
the second content (aes-128) using ffmpeg
ffmpeg -i input2.mp4 -c:v copy -an -hls_segment_type fmp4 -segment_time 20 -hls_segment_filename video2/segment_%04d.mp4 -hls_base_url video2/ -hls_fmp4_init_filename video2/init.mp4 -hls_list_size 0 playlist2.m3u8

@TakuSemba
Copy link
Contributor Author

fixed not to use initializationSegmentIndex for simplification

@AquilesCanta
Copy link
Contributor

AquilesCanta commented Apr 25, 2018

Hi @TakuSemba, thanks for the pull request. There are a points that are not ideal about the approach used in the PR:

  • The SparseArray makes the HlsMediaPlaylist mutable.
  • In general, the sparse array is not a great idea: It needs documenting what it maps (there is no documentation on what it maps in the PR). It introduces a complex data structure on what can probably be solved with a reference.
  • Regarding the discontinuity sequence to init segment mapping. Even though it makes sense in my opinion to assume things work like that, this does not directly reflect the spec, which says that a map tag applies until the next EXT-X-MAP tag or until the end of the playlist.

I think it will be faster to push a fix (along with tests) directly for this than to address changes an sync both internal and external repos. Again, many thanks for the pull request. I will look into the DRM PR asap.

@TakuSemba
Copy link
Contributor Author

makes sense, thanks.

Thank you for opening the issue
I hope this feature will be added to ExoPlayer soon. 👍

@AquilesCanta
Copy link
Contributor

Yes, it will be available in the dev-branch in the next push.

@google google locked and limited conversation to collaborators Sep 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants