google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

Length mismatch issue with FMP4/CMAF content #7592

Closed vip644 closed 4 years ago

vip644 commented 4 years ago

Issue description:

Hi, I am trying to generate a fmp4 CMAF DRM with the CBCS protection scheme using bento4 and trying to play on android exoplayer.

Here is the command I am using to generate the dash manifest mp4dash --profiles=on-demand --mpd-name manifest.mpd --encryption-cenc-scheme=cbcs --encryption-args=“--global-option mpeg-cenc.piff-compatible:true” --encryption-key=:: --widevine-header=provider:demo.ki#content_id:#protection_scheme:cbcs --hls --mpd-name=manifest.mpd --hls-master-playlist-name=manifest.m3u8 fragmented.mp4

example command i am using mp4dash --mpd-name manifest.mpd --encryption-cenc-scheme=cbcs --encryption-args=“--global-option mpeg-cenc.piff-compatible:true” --encryption-key=8762c548e79c740f7b5d2f5f09f85929:aae2a539812edc302599f027c8689fad:00000000000000000000000000000000 --widevine-header=provider:demo.ki#content_id:8762c548e79c740f7b5d2f5f09f85929#protection_scheme:cbcs --hls --mpd-name=manifest.mpd --hls-master-playlist-name=manifest.m3u8 sintel-1024-surround.mp4 The content works on Chrome using shakaplayer.

There is already an existing closed bug on the bento4 issues page regarding the same issue https://github.com/axiomatic-systems/Bento4/issues/428 where it looks like it is an issue with exoplayer. Is there any workaround for this?

Stack-trace:

2020-07-03 16:54:54.708 3562-3603/com.vipin.exokotlin E/ExoPlayerImplInternal: Source error
      com.google.android.exoplayer2.ParserException: Length mismatch: 0, 1285
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.parseSaiz(FragmentedMp4Extractor.java:802)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.parseTraf(FragmentedMp4Extractor.java:725)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.parseMoof(FragmentedMp4Extractor.java:693)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.onMoofContainerAtomRead(FragmentedMp4Extractor.java:542)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.onContainerAtomRead(FragmentedMp4Extractor.java:456)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.processAtomEnded(FragmentedMp4Extractor.java:434)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.readAtomPayload(FragmentedMp4Extractor.java:429)
        at com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor.read(FragmentedMp4Extractor.java:315)
        at com.google.android.exoplayer2.source.chunk.ContainerMediaChunk.load(ContainerMediaChunk.java:135)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

Version of ExoPlayer: 2.11.7

Device: Google Pixel 3 Version: Android 9

ojw28 commented 4 years ago

Looks like any sampleCount for which sampleCount <= out.sampleCount would be valid according to the spec, but we currently only handle sampleCount == out.sampleCount in parseSaiz.

It's probably worth looking at parseSenc at the same time, which has a similar check. I think what's valid is different for that box though. Possibly sampleCount == out.sampleCount || sampleCount == 0.

Over to @kim-vde who's been looking at FMP4 parsing.

kim-vde commented 4 years ago

Could you provide a test content so that I can test? If you're unable to share it publicly, please send it to dev.exoplayer@gmail.com using a subject in the format "Issue #7592". Please also update this issue to indicate you’ve done this.

vip644 commented 4 years ago

I've sent you a mail regarding test content on dev.exoplayer@gmail.com with all the information related to it.

kim-vde commented 4 years ago

Can you also send the DRM license URL (as in the demo app samples)?

vip644 commented 4 years ago

Please check your mail box, I've sent the DRM license URL.

kim-vde commented 4 years ago

I don't have the length mismatch error with the fix I implemented but I have a DRM error. I seems there is something wrong with the response.

2020-07-09 09:06:57.688 29903-30149/com.google.android.exoplayer2.demo E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: Source error
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:487)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: com.google.android.exoplayer2.drm.DrmSession$DrmSessionException: java.lang.IllegalArgumentException: Failed to handle key response
        at com.google.android.exoplayer2.drm.DefaultDrmSession.onError(DefaultDrmSession.java:514)
        at com.google.android.exoplayer2.drm.DefaultDrmSession.onKeysError(DefaultDrmSession.java:509)
        at com.google.android.exoplayer2.drm.DefaultDrmSession.onKeyResponse(DefaultDrmSession.java:494)
        at com.google.android.exoplayer2.drm.DefaultDrmSession.access$100(DefaultDrmSession.java:54)
        at com.google.android.exoplayer2.drm.DefaultDrmSession$ResponseHandler.handleMessage(DefaultDrmSession.java:553)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
     Caused by: java.lang.IllegalArgumentException: Failed to handle key response
        at android.media.MediaDrm.provideKeyResponse(Native Method)
        at com.google.android.exoplayer2.drm.FrameworkMediaDrm.provideKeyResponse(FrameworkMediaDrm.java:216)
        at com.google.android.exoplayer2.drm.DefaultDrmSession.onKeyResponse(DefaultDrmSession.java:482)
        at com.google.android.exoplayer2.drm.DefaultDrmSession.access$100(DefaultDrmSession.java:54) 
        at com.google.android.exoplayer2.drm.DefaultDrmSession$ResponseHandler.handleMessage(DefaultDrmSession.java:553) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
vip644 commented 4 years ago

Wait let me check the issue with the DRM, seems there some key mismatch. If this doesn't work then I'll provide you another content url.

vip644 commented 4 years ago

I've shared another Content url with license url which is giving me length mismatch error. Please check your mailbox.

kim-vde commented 4 years ago

I can't access the manifest URL.

Caused by: com.google.android.exoplayer2.ext.cronet.CronetDataSource$OpenException: eq: Exception in CronetUrlRequest: net::ERR_CERT_AUTHORITY_INVALID, ErrorCode=11, InternalErrorCode=-202, Retryable=false
vip644 commented 4 years ago

You're getting ERR_CERT_AUTHORITY_INVALID because of the given IP Address doesn't contain any certificate over https. In this case please try to accept the self-signed certificate for the given IP Address.

kim-vde commented 4 years ago

I just pushed a fix on the dev-2 branch. Can you try it and tell me if you still have issues?

vip644 commented 4 years ago

Issue has been fixed on the dev-2 branch. Now I'm not getting any issue regarding length mismatch.

kim-vde commented 4 years ago

I'll close the issue then. Feel free to open another one if you encounter other problems.