Issue with number based manifest
We're using Exoplayer for playing movies in MPEG-DASH standard. All of these movies are protected by Widevine. There was no problem with playing in case, that we used time based manifest. Now we need to use number based manifest and we have an issue with that. We know that our movie is consist of 1001 segments, but Exoplayer wants segment nbr. 1002.
11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.MediaCodecTrackRenderer.maybeThrowError(MediaCodecTrackRenderer.java:782) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:424) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:205) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:98) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:212) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:61) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: Caused by: com.google.android.exoplayer.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 404 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:210) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.upstream.DefaultUriDataSource.open(DefaultUriDataSource.java:136) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.chunk.ContainerMediaChunk.load(ContainerMediaChunk.java:143) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:209) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 11-26 12:43:37.839 26417-28582/cz.alza.media E/ExoPlayerImplInternal: at java.lang.Thread.run(Thread.java:841)
We tried to use mvlist manifest, which contains all links for our video segments. With this manifest everything works fine.
In case of number based manifest, the playing fails at the end of movie, because Exoplayer wants a non-existing segment (1002). We are sure that this segment is not needed, because 1001 segments are enough for our movie.
Can you please check it?
This is probably the same as https://github.com/google/ExoPlayer/issues/836, but you'd need to provide a link to a sample manifest to be sure. You can remove/alter the template so as to not publish the URLs if you prefer; although we'd need you to state how many segments you think exist in the media.
Yes, it seems that this is a same issue. Sorry, I cannot provide a link, because content is encrypted with Widevine and I cannot provide you secret data for playing due to security reasons. Thank you for your understanding. I know that movie is consist of 1001 segments (1001 for video and 1001 for audio). When I am using number-based manifest, it fails, but in case of mvlist manifest, where are 1001 segments, it works fine. I will watching https://github.com/google/ExoPlayer/issues/836 for next updates.
Can you strip out the sensitive bits of the manifest and just paste a safe version here? I'm mainly interested in what value you get if you divide the period duration by the segment duration (as a floating point operation). I'd be interested in knowing how far off it is from 1001.
See the attached manifest, please. Duration is 540000 and timescale is 90000. So, the length of one segment is 6 seconds. The length of video is 1h 40min 6s, which is 6006 seconds. So, I need 6006 / 6 segments, which is 1001 segments. Also, there is one initialization segment. And in the mvlist manifest, there are 1001 segments + 1 initial as well.
Thanks! Yes, looks like the same issue. The problem is that the length of the video according to the manifest is actually 0.036 seconds longer than you state above, so technically the manifest defines 1002 segments where the last segment is expected to have a shorter duration, in this case of ~36ms.
As in the related issue, technically the manifest is at fault here. If you update the manifest so that it reads mediaPresentationDuration="PT1H40M6.000S" then you'll likely find that playback ends correctly. That said, we should consider being more permissive in our handling of this case. We'll track that using the related issue.
NB - You should fix the manifests to be technically correct regardless.
Why manifest should have 1002 segments? There is initialization segment, so in fact there are 1002 - 1001 "classic" segments and one initialization segment.
The number of media segments is the duration divided by the segment length, rounded up to the nearest integer, which is:
ceil(6006.036/6) = ceil(1001.006) = 1002
Additionally, you may or may not include an initialization segment. But that's irrelevant to the above calculation.
Ok, thank you for explanation. I thought that initialization segment is already required.
It may well be required, depending on exactly what's included in the media chunks. It's normally best to include it. But it's inclusion doesn't have any effect on the number of media segments that the manifest defines to be present.
Thank you. Last question - you wrote me "You should fix the manifests to be technically correct regardless." I do not know in which part my manifest is not technically correct. Could you please tell me?
You should probably update the mediaPresentationDuration to be mediaPresentationDuration="PT1H40M6.000S".