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

HLS: Error playing content with AES-128 encrypted initialization segment #5441

Closed
bounmed opened this issue Jan 26, 2019 · 9 comments
Closed
Assignees
Labels

Comments

@bounmed
Copy link

bounmed commented Jan 26, 2019

Can't play some X265 videos.
the video info are :

ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L3.1
Codec ID                                 : hev1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 29mn 42s
Bit rate                                 : 662 Kbps
Width                                    : 1 280 pixels
Height                                   : 544 pixels
Display aspect ratio                     : 2.35:1
Frame rate mode                          : Variable
Frame rate                               : 23.976 fps
Minimum frame rate                       : 23.810 fps
Maximum frame rate                       : 16 000.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.040
Stream size                              : 141 MiB (82%)
Language                                 : English

i got this error in adb log


01-26 13:45:34.612  1385  1572 W audio_hw_generic: Not supplying enough data to HAL, expected position 26665703 , only wrote 26508744
01-26 13:45:38.140  1385  4428 W audio_hw_generic: Not supplying enough data to HAL, expected position 26508757 , only wrote 26508744
01-26 13:45:38.200 25185 25214 I ReactNativeJS: http://192.168.1.36/hls/content/S01E14/,S01E14.mp4,lang/fre/Francais.srt,.urlset/master.m3u8
01-26 13:45:38.210  2936  3611 I ActivityManager: START u0 {dat=http://192.168.1.36/... cmp=com.bounmed/com.herudi.exovideo.PlayerActivity (has extras)} from uid 10054
01-26 13:45:38.365 25185 25185 E audioCapabilities:: AudioCapabilities[maxChannelCount=8, supportedEncodings=[2]]
01-26 13:45:38.368 25185 25185 I DefaultRenderersFactory: Loaded LibvpxVideoRenderer.
01-26 13:45:38.371 25185 25185 I DefaultRenderersFactory: Loaded FfmpegAudioRenderer.
01-26 13:45:38.372 25185 25185 I ExoPlayerImpl: Init d9d3797 [ExoPlayerLib/2.9.4] [generic_x86, sdk_google_atv_x86, unknown, 27]
01-26 13:45:38.375 25185 25185 D EventLogger: state [0.01, true, I]
01-26 13:45:38.377 25185 25185 D EventLogger: state [0.01, true, B]
01-26 13:45:38.407  1392  1449 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 3690496
01-26 13:45:38.508 25185 25206 D EGL_emulation: eglMakeCurrent: 0xaaf85480: ver 2 0 (tinfo 0xaaf83300)
01-26 13:45:38.571  1392  1449 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 3690496
01-26 13:45:38.600  2936  2971 I ActivityManager: Displayed com.bounmed/com.herudi.exovideo.PlayerActivity: +357ms
01-26 13:45:38.603 25185 25206 D EGL_emulation: eglMakeCurrent: 0xaaf85480: ver 2 0 (tinfo 0xaaf83300)
01-26 13:45:38.716 25185 25206 D EGL_emulation: eglMakeCurrent: 0xaaf85480: ver 2 0 (tinfo 0xaaf83300)
01-26 13:45:38.777  1392  1449 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 3690496
01-26 13:45:38.947 25185 25206 D EGL_emulation: eglMakeCurrent: 0xaaf85480: ver 2 0 (tinfo 0xaaf83300)
01-26 13:45:39.013 25185 26798 D readFromDataSource:: 10
01-26 13:45:39.026 25185 26798 D readFromDataSource:: 1
01-26 13:45:39.088 25185 26798 I chatty  : uid=10054(com.bounmed) Loader:HlsSampl identical 412 lines
01-26 13:45:39.088 25185 26798 D readFromDataSource:: 1
01-26 13:45:39.088 25185 25206 D EGL_emulation: eglMakeCurrent: 0xaaf85480: ver 2 0 (tinfo 0xaaf83300)
01-26 13:45:39.088 25185 26798 D readFromDataSource:: 1
01-26 13:45:39.197 25185 26798 I chatty  : uid=10054(com.bounmed) Loader:HlsSampl identical 758 lines
01-26 13:45:39.197 25185 26798 D readFromDataSource:: 1
01-26 13:45:39.197 25185 26798 D readFromDataSource:: -1
01-26 13:45:39.205 25185 25185 D EventLogger: sourceInfo [periodCount=1, windowCount=1
01-26 13:45:39.205 25185 25185 D EventLogger:   period [1783.00]
01-26 13:45:39.205 25185 26798 D readFromDataSource:: -1
01-26 13:45:39.206 25185 25185 D EventLogger:   window [1783.00, true, false]
01-26 13:45:39.206 25185 25185 D EventLogger: ]
01-26 13:45:39.217 25185 25185 D EventLogger: loading [true]
01-26 13:45:39.219 25185 26798 D readFromDataSource:: -1
01-26 13:45:39.229 25185 26798 D readFromDataSource:: -1
01-26 13:45:39.240 25185 25190 I zygote  : Do partial code cache collection, code=986KB, data=564KB
01-26 13:45:39.241 25185 25190 I zygote  : After code cache collection, code=986KB, data=564KB
01-26 13:45:39.241 25185 25190 I zygote  : Increasing code cache capacity to 3MB
01-26 13:45:39.309 25185 25185 E EventLogger: internalError [0.94, loadError]
01-26 13:45:39.309 25185 25185 E EventLogger: java.io.EOFException
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:267)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:103)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:111)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.maybeLoadInitData(HlsMediaChunk.java:214)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:192)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
01-26 13:45:39.309 25185 25185 E EventLogger: 	at java.lang.Thread.run(Thread.java:764)
01-26 13:45:39.400 25185 26798 D readFromDataSource:: 1176
01-26 13:45:39.400 25185 26798 D readFromDataSource:: -1
01-26 13:45:39.425 25185 25185 E EventLogger: internalError [1.04, loadError]
01-26 13:45:39.425 25185 25185 E EventLogger: java.io.EOFException
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:267)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:103)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:111)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.maybeLoadInitData(HlsMediaChunk.java:214)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:192)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
01-26 13:45:39.425 25185 25185 E EventLogger: 	at java.lang.Thread.run(Thread.java:764)
01-26 13:45:40.505 25185 26798 D readFromDataSource:: 1176
01-26 13:45:40.505 25185 26798 D readFromDataSource:: -1
01-26 13:45:40.507 25185 25185 E EventLogger: internalError [2.14, loadError]
01-26 13:45:40.507 25185 25185 E EventLogger: java.io.EOFException
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:267)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:103)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:111)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.maybeLoadInitData(HlsMediaChunk.java:214)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:192)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
01-26 13:45:40.507 25185 25185 E EventLogger: 	at java.lang.Thread.run(Thread.java:764)
01-26 13:45:41.724  1385  1572 W audio_hw_generic: Not supplying enough data to HAL, expected position 26823062 , only wrote 26666723
01-26 13:45:42.619 25185 26798 D readFromDataSource:: 1176
01-26 13:45:42.619 25185 26798 D readFromDataSource:: -1
01-26 13:45:42.625 25185 25185 E EventLogger: internalError [4.26, loadError]
01-26 13:45:42.625 25185 25185 E EventLogger: java.io.EOFException
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:267)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:103)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:111)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.maybeLoadInitData(HlsMediaChunk.java:214)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:192)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
01-26 13:45:42.625 25185 25185 E EventLogger: 	at java.lang.Thread.run(Thread.java:764)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: Source error.
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: java.io.EOFException
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:267)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:103)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:111)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.maybeLoadInitData(HlsMediaChunk.java:214)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:192)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
01-26 13:45:42.634 25185 26795 E ExoPlayerImplInternal: 	at java.lang.Thread.run(Thread.java:764)
01-26 13:45:42.640 25185 25185 E EventLogger: playerFailed [4.27]
01-26 13:45:42.640 25185 25185 E EventLogger: com.google.android.exoplayer2.ExoPlaybackException: java.io.EOFException
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:354)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at android.os.Handler.dispatchMessage(Handler.java:102)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at android.os.Looper.loop(Looper.java:164)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at android.os.HandlerThread.run(HandlerThread.java:65)
01-26 13:45:42.640 25185 25185 E EventLogger: Caused by: java.io.EOFException
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:267)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:103)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.DefaultExtractorInput.skipFully(DefaultExtractorInput.java:111)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:427)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.maybeLoadInitData(HlsMediaChunk.java:214)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:192)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
01-26 13:45:42.640 25185 25185 E EventLogger: 	at java.lang.Thread.run(Thread.java:764)

I added this line befor the error to see the value of bytesRead the result in the log

Log.d("readFromDataSource:", Integer.toString(bytesRead));

any help please how to fix this?

@bounmed
Copy link
Author

bounmed commented Jan 26, 2019

I want to add that the url works well in quicktime player.
and i can play some x265 video like this one
https://s3.amazonaws.com/x265.org/video/Tears_400_x265.mp4
As media server i use nginx vod-module HLS

@ojw28
Copy link
Contributor

ojw28 commented Jan 26, 2019

I suspect this issue can occur if the media contains a top level atom (probably the mdat) with atom size set to 0, and if the media is also hosted on a server that does not set the Content-Length response header. Technically I think it's valid to do both of these, but I'd consider it best practice to do neither. So I'm not sure we'd consider this hugely important to fix, if it is indeed the problem.

The above is just a guess. We really need sample media that reproduces the issue to debug this properly. Please provide some if you want us to look in more detail.

@ojw28 ojw28 self-assigned this Jan 26, 2019
@bounmed
Copy link
Author

bounmed commented Jan 28, 2019

Hi Oliver i sent you by email a sample media and the way to reproduce the issue hope you find a solution.

@bounmed
Copy link
Author

bounmed commented Jan 30, 2019

Hi Oliver i sent you by email a sample media and the way to reproduce the issue hope you find a solution.

Did you get the sample? any update about this?

@ojw28 ojw28 added bug and removed need more info labels Jan 30, 2019
@ojw28 ojw28 changed the title Error playing x265/HEVC video HLS: Error playing content with AES-128 encrypted initialization segment Jan 30, 2019
@ojw28 ojw28 assigned AquilesCanta and unassigned ojw28 Jan 30, 2019
@ojw28
Copy link
Contributor

ojw28 commented Jan 30, 2019

@AquilesCanta - This issue is because our existing code assumes initialization segments are never encrypted using AES-128, where-as the spec says they can be. It looks like building initializationSegment in HlsPlaylistParser needs to be updated to possibly set the full segment encryption variables, and that these need propagating through into HlsMediaChunk to be used when loading. Note the EXT-X-KEY may be different for the initialization segment vs the media segment being loaded.

@bounmed - If you could keep the link available for our testing, that would be great.

@bounmed
Copy link
Author

bounmed commented Jan 30, 2019

@ojw28 Thank you Oliver, i will leave the link until this issue is resolved.

@bounmed
Copy link
Author

bounmed commented Feb 4, 2019

@AquilesCanta any update about this please ?

@AquilesCanta
Copy link
Contributor

Not yet, I haven't had time to check/implement, although I did looked into it and shouldn't be complex. I'll try to get to that in a few weeks or less.

@AquilesCanta
Copy link
Contributor

I have already started working on this. Once it is available, a commit reference will appear here. Thanks for your patience!

andrewlewis pushed a commit that referenced this issue Feb 18, 2019
Defined in RFC 8216 Section 4.3.2.5.

Issue:#5441
PiperOrigin-RevId: 234114119
@ojw28 ojw28 closed this as completed Mar 6, 2019
@google google locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants