Merge pull request #255 from mayurk2:use_edts_offset_if_it_is_for_entire_file
PiperOrigin-RevId: 513213229 (cherry picked from commit 17499cefcc1b27d90ecdf136bd3b2e4856ddcaf1)
This commit is contained in:
parent
ddd5e9bc19
commit
dbf737de08
@ -970,6 +970,26 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
return version == 1 ? tfdt.readUnsignedLongToLong() : tfdt.readUnsignedInt();
|
return version == 1 ? tfdt.readUnsignedLongToLong() : tfdt.readUnsignedInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isEdtsListDurationForEntireMediaTimeline(Track track) {
|
||||||
|
// Currently we only support a single edit that moves the entire media timeline (indicated by
|
||||||
|
// duration == 0 or (editListDurationUs + editListMediaTimeUs) >= track duration.
|
||||||
|
// Other uses of edit lists are uncommon and unsupported.
|
||||||
|
if (track.editListDurations == null
|
||||||
|
|| track.editListDurations.length != 1
|
||||||
|
|| track.editListMediaTimes == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (track.editListDurations[0] == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
long editListEndMediaTimeUs =
|
||||||
|
Util.scaleLargeTimestamp(
|
||||||
|
track.editListDurations[0] + track.editListMediaTimes[0],
|
||||||
|
C.MICROS_PER_SECOND,
|
||||||
|
track.movieTimescale);
|
||||||
|
return editListEndMediaTimeUs >= track.durationUs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a trun atom (defined in 14496-12).
|
* Parses a trun atom (defined in 14496-12).
|
||||||
*
|
*
|
||||||
@ -1017,11 +1037,8 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
// ensure that the first frame's presentation timestamp is zero.
|
// ensure that the first frame's presentation timestamp is zero.
|
||||||
long edtsOffset = 0;
|
long edtsOffset = 0;
|
||||||
|
|
||||||
// Currently we only support a single edit that moves the entire media timeline (indicated by
|
// Currently we only support a single edit that moves the entire media timeline.
|
||||||
// duration == 0). Other uses of edit lists are uncommon and unsupported.
|
if (isEdtsListDurationForEntireMediaTimeline(track)) {
|
||||||
if (track.editListDurations != null
|
|
||||||
&& track.editListDurations.length == 1
|
|
||||||
&& track.editListDurations[0] == 0) {
|
|
||||||
edtsOffset = castNonNull(track.editListMediaTimes)[0];
|
edtsOffset = castNonNull(track.editListMediaTimes)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user