diff --git a/CHANGELOG.md b/CHANGELOG.md index 6496c8b6a..b2ce2dc98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. ### Fixed +- crash when cataloguing some MP4 files - reading metadata for some MP4 files ## [v1.7.4] - 2022-11-11 diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/DebugHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/DebugHandler.kt index 12f098cbf..440e535e0 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/DebugHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/DebugHandler.kt @@ -42,6 +42,7 @@ import kotlinx.coroutines.launch import org.beyka.tiffbitmapfactory.TiffBitmapFactory import org.mp4parser.IsoFile import org.mp4parser.PropertyBoxParserImpl +import org.mp4parser.boxes.iso14496.part12.FreeBox import org.mp4parser.boxes.iso14496.part12.MediaDataBox import org.mp4parser.boxes.iso14496.part12.SampleTableBox import java.io.FileInputStream @@ -344,9 +345,15 @@ class DebugHandler(private val context: Context) : MethodCallHandler { FileInputStream(it.fileDescriptor).use { stream -> stream.channel.use { channel -> val boxParser = PropertyBoxParserImpl().apply { - // parsing `MediaDataBox` can take a long time - // parsing `SampleTableBox` may yield OOM - skippingBoxes(MediaDataBox.TYPE, SampleTableBox.TYPE) + skippingBoxes( + // parsing `MediaDataBox` can take a long time + MediaDataBox.TYPE, + // parsing `SampleTableBox` or `FreeBox` may yield OOM + SampleTableBox.TYPE, FreeBox.TYPE, + // some files are padded with `0` but the parser does not stop, reads type "0000", + // then a large size from following "0000", which may yield OOM + "0000", + ) } IsoFile(channel, boxParser).use { isoFile -> isoFile.dumpBoxes(sb) diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Mp4ParserHelper.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Mp4ParserHelper.kt index c479e8b4c..358e82ad2 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Mp4ParserHelper.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Mp4ParserHelper.kt @@ -22,9 +22,14 @@ object Mp4ParserHelper { FileInputStream(it.fileDescriptor).use { stream -> stream.channel.use { channel -> val boxParser = PropertyBoxParserImpl().apply { - // parsing `MediaDataBox` can take a long time // do not skip anything inside `MovieBox` as it will be parsed and rewritten for editing - skippingBoxes(MediaDataBox.TYPE) + skippingBoxes( + // parsing `MediaDataBox` can take a long time + MediaDataBox.TYPE, + // some files are padded with `0` but the parser does not stop, reads type "0000", + // then a large size from following "0000", which may yield OOM + "0000", + ) } // creating `IsoFile` with a `File` or a `File.inputStream()` yields `No such device` IsoFile(channel, boxParser).use { isoFile -> diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt index 8665bfffc..41e7f3e34 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt @@ -23,6 +23,7 @@ import deckers.thibault.aves.utils.StorageUtils import org.mp4parser.IsoFile import org.mp4parser.PropertyBoxParserImpl import org.mp4parser.boxes.UserBox +import org.mp4parser.boxes.iso14496.part12.FreeBox import org.mp4parser.boxes.iso14496.part12.MediaDataBox import org.mp4parser.boxes.iso14496.part12.SampleTableBox import java.io.FileInputStream @@ -144,9 +145,15 @@ object XMP { FileInputStream(it.fileDescriptor).use { stream -> stream.channel.use { channel -> val boxParser = PropertyBoxParserImpl().apply { - // parsing `MediaDataBox` can take a long time - // parsing `SampleTableBox` may yield OOM - skippingBoxes(MediaDataBox.TYPE, SampleTableBox.TYPE) + skippingBoxes( + // parsing `MediaDataBox` can take a long time + MediaDataBox.TYPE, + // parsing `SampleTableBox` or `FreeBox` may yield OOM + SampleTableBox.TYPE, FreeBox.TYPE, + // some files are padded with `0` but the parser does not stop, reads type "0000", + // then a large size from following "0000", which may yield OOM + "0000", + ) } // creating `IsoFile` with a `File` or a `File.inputStream()` yields `No such device` IsoFile(channel, boxParser).use { isoFile ->