From d740bf9f23b3f8b242b5524eaac000eb19fcd2eb Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Wed, 6 Jan 2016 04:25:42 -0800 Subject: [PATCH] Handle edit lists with one 0 duration edit. Issue: #1102 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111497855 --- .../android/exoplayer/extractor/mp4/AtomParsers.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java index b6120f105e..5691d927d5 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java @@ -262,6 +262,17 @@ import java.util.List; // implementation handles simple discarding/delaying of samples. The extractor may place // further restrictions on what edited streams are playable. + if (track.editListDurations.length == 1 && track.editListDurations[0] == 0) { + // The current version of the spec leaves handling of an edit with zero segment_duration in + // unfragmented files open to interpretation. We handle this as a special case and include all + // samples in the edit. + for (int i = 0; i < timestamps.length; i++) { + timestamps[i] = Util.scaleLargeTimestamp(timestamps[i] - track.editListMediaTimes[0], + C.MICROS_PER_SECOND, track.timescale); + } + return new TrackSampleTable(offsets, sizes, maximumSize, timestamps, flags); + } + // Count the number of samples after applying edits. int editedSampleCount = 0; int nextSampleIndex = 0;