diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java index b2db7a6df5..dc098994df 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java @@ -231,20 +231,22 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; *

Atoms of type {@link Atom#TYPE_meta} are defined to be full atoms which have four additional * bytes for a version and a flags field (see 4.2 'Object Structure' in ISO/IEC 14496-12:2005). * QuickTime do not have such a full box structure. Since some of these files are encoded wrongly, - * we can't rely on the file type though. Instead we must check the 4 bytes after the common + * we can't rely on the file type though. Instead we must check the 8 bytes after the common * header bytes ourselves. * - * @param meta The 4 or more bytes following the meta atom size and type. + * @param meta The 8 or more bytes following the meta atom size and type. */ public static void maybeSkipRemainingMetaAtomHeaderBytes(ParsableByteArray meta) { - int startPosition = meta.getPosition(); - // The next 4 bytes can be either: - // (iso) 4 zero bytes (version + flags) - // (qt) 4 byte size of next atom + int endPosition = meta.getPosition(); + // The next 8 bytes can be either: + // (iso) [1 byte version + 3 bytes flags][4 byte size of next atom] + // (qt) [4 byte size of next atom ][4 byte hdlr atom type ] // In case of (iso) we need to skip the next 4 bytes. - if (meta.readInt() != 0) { - meta.setPosition(startPosition); + meta.skipBytes(4); + if (meta.readInt() != Atom.TYPE_hdlr) { + endPosition += 4; } + meta.setPosition(endPosition); } /** diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java index f284eaff4f..08c399baff 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java @@ -728,8 +728,8 @@ public final class Mp4Extractor implements Extractor, SeekMap { } private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input) throws IOException { - scratch.reset(4); - input.peekFully(scratch.getData(), 0, 4); + scratch.reset(8); + input.peekFully(scratch.getData(), 0, 8); AtomParsers.maybeSkipRemainingMetaAtomHeaderBytes(scratch); input.skipFully(scratch.getPosition()); input.resetPeekPosition();