mirror of
https://github.com/samsonjs/media.git
synced 2026-04-03 10:55:48 +00:00
Add workaround for unmatched track indices in trex and tkhd.
Both boxes should contain the same list of track indices. However, if only one track index in each list does not match, we can just assume that these belong together. Issue:#4477 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=203481258
This commit is contained in:
parent
bd952a802a
commit
1cf8b255dc
2 changed files with 17 additions and 2 deletions
|
|
@ -75,6 +75,9 @@
|
|||
`MediaCodecRenderer`, and provide an (optional) `MediaCodecSelector` that
|
||||
falls back to less preferred decoders like `MediaCodec.createDecoderByType`
|
||||
([#273](https://github.com/google/ExoPlayer/issues/273)).
|
||||
* Add workaround for track index mismatches between trex and tkhd boxes in
|
||||
fragmented MP4 files
|
||||
([#4477](https://github.com/google/ExoPlayer/issues/4477)).
|
||||
|
||||
### 2.8.2 ###
|
||||
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||
for (int i = 0; i < trackCount; i++) {
|
||||
Track track = tracks.valueAt(i);
|
||||
TrackBundle trackBundle = new TrackBundle(extractorOutput.track(i, track.type));
|
||||
trackBundle.init(track, defaultSampleValuesArray.get(track.id));
|
||||
trackBundle.init(track, getDefaultSampleValues(defaultSampleValuesArray, track.id));
|
||||
trackBundles.put(track.id, trackBundle);
|
||||
durationUs = Math.max(durationUs, track.durationUs);
|
||||
}
|
||||
|
|
@ -509,11 +509,23 @@ public final class FragmentedMp4Extractor implements Extractor {
|
|||
Assertions.checkState(trackBundles.size() == trackCount);
|
||||
for (int i = 0; i < trackCount; i++) {
|
||||
Track track = tracks.valueAt(i);
|
||||
trackBundles.get(track.id).init(track, defaultSampleValuesArray.get(track.id));
|
||||
trackBundles
|
||||
.get(track.id)
|
||||
.init(track, getDefaultSampleValues(defaultSampleValuesArray, track.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DefaultSampleValues getDefaultSampleValues(
|
||||
SparseArray<DefaultSampleValues> defaultSampleValuesArray, int trackId) {
|
||||
if (defaultSampleValuesArray.size() == 1) {
|
||||
// Ignore track id if there is only one track to cope with non-matching track indices.
|
||||
// See https://github.com/google/ExoPlayer/issues/4477.
|
||||
return defaultSampleValuesArray.valueAt(/* index= */ 0);
|
||||
}
|
||||
return Assertions.checkNotNull(defaultSampleValuesArray.get(trackId));
|
||||
}
|
||||
|
||||
private void onMoofContainerAtomRead(ContainerAtom moof) throws ParserException {
|
||||
parseMoof(moof, trackBundles, flags, extendedTypeScratch);
|
||||
// If drm init data is sideloaded, we ignore pssh boxes.
|
||||
|
|
|
|||
Loading…
Reference in a new issue