Merge pull request #255 from mayurk2:use_edts_offset_if_it_is_for_entire_file
PiperOrigin-RevId: 513213229
This commit is contained in:
commit
17499cefcc
@ -970,6 +970,26 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
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).
|
||||
*
|
||||
@ -1017,11 +1037,8 @@ public class FragmentedMp4Extractor implements Extractor {
|
||||
// ensure that the first frame's presentation timestamp is zero.
|
||||
long edtsOffset = 0;
|
||||
|
||||
// Currently we only support a single edit that moves the entire media timeline (indicated by
|
||||
// duration == 0). Other uses of edit lists are uncommon and unsupported.
|
||||
if (track.editListDurations != null
|
||||
&& track.editListDurations.length == 1
|
||||
&& track.editListDurations[0] == 0) {
|
||||
// Currently we only support a single edit that moves the entire media timeline.
|
||||
if (isEdtsListDurationForEntireMediaTimeline(track)) {
|
||||
edtsOffset = castNonNull(track.editListMediaTimes)[0];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user