fixed crash when cataloguing some MP4 files
This commit is contained in:
parent
3f94a4f5a0
commit
885a9f3ff9
4 changed files with 28 additions and 8 deletions
|
@ -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
|
||||
|
||||
## <a id="v1.7.4"></a>[v1.7.4] - 2022-11-11
|
||||
|
|
|
@ -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 {
|
||||
skippingBoxes(
|
||||
// parsing `MediaDataBox` can take a long time
|
||||
// parsing `SampleTableBox` may yield OOM
|
||||
skippingBoxes(MediaDataBox.TYPE, SampleTableBox.TYPE)
|
||||
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)
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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 {
|
||||
skippingBoxes(
|
||||
// parsing `MediaDataBox` can take a long time
|
||||
// parsing `SampleTableBox` may yield OOM
|
||||
skippingBoxes(MediaDataBox.TYPE, SampleTableBox.TYPE)
|
||||
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 ->
|
||||
|
|
Loading…
Reference in a new issue