shahen94 / react-native-video-processing

Native Video editing/trimming/compressing :movie_camera: library for React-Native
https://shahen94.github.io/react-native-video-processing/
MIT License
1.25k stars 326 forks source link

OutOfMemory error on Android while trimming. #271

Open rajeevrocker7 opened 4 years ago

rajeevrocker7 commented 4 years ago

Current Behavior

I noticed in android you are using 'com.googlecode.mp4parser:isoparser:1.1.20' to trim.

When trimming a video the native call goes to genVideoUsingMp4Parser() method and it crashes with log: Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 2065855864 byte allocation with 21747093 free bytes and 491MB until OOM, target footprint 43494189, growth limit 536870912 at java.nio.HeapByteBuffer.(HeapByteBuffer.java:54) at java.nio.HeapByteBuffer.(HeapByteBuffer.java:49) at java.nio.ByteBuffer.allocate(ByteBuffer.java:282) at com.googlecode.mp4parser.AbstractBox.parse(AbstractBox.java:110) at com.coremedia.iso.AbstractBoxParser.parseBox(AbstractBoxParser.java:107) at com.googlecode.mp4parser.BasicContainer.next(BasicContainer.java:185) at com.googlecode.mp4parser.BasicContainer.hasNext(BasicContainer.java:161) at com.googlecode.mp4parser.util.LazyList.blowup(LazyList.java:30) at com.googlecode.mp4parser.util.LazyList.size(LazyList.java:77) at com.googlecode.mp4parser.BasicContainer.getBoxes(BasicContainer.java:80) at com.googlecode.mp4parser.authoring.samples.DefaultMp4SampleList.(DefaultMp4SampleList.java:36) at com.coremedia.iso.boxes.mdat.SampleList.(SampleList.java:33) at com.googlecode.mp4parser.authoring.Mp4TrackImpl.(Mp4TrackImpl.java:64) at com.googlecode.mp4parser.authoring.container.mp4.MovieCreator.build(MovieCreator.java:57) at com.shahenlibrary.utils.VideoEdit.genVideoUsingMp4Parser(VideoEdit.java:107) at com.shahenlibrary.utils.VideoEdit.startTrim(VideoEdit.java:94) at com.shahenlibrary.VideoPlayer.VideoPlayerView.trimMedia(VideoPlayerView.java:367) at com.shahenlibrary.VideoPlayer.VideoPlayerViewManager.receiveCommand(VideoPlayerViewManager.java:132) at com.shahenlibrary.VideoPlayer.VideoPlayerViewManager.receiveCommand(VideoPlayerViewManager.java:42) ...

Same issue is coming in that 'com.googlecode.mp4parser:isoparser:1.1.20' library but they have fixed it some PR (https://github.com/sannies/mp4parser/pull/288) (https://github.com/sannies/mp4parser/pull/205) OR in latest version of com.googlecode.mp4parser:isoparser

@shahen94 Please help..

Expected Behavior

Trimming should work even with mp4Parser , if there is still time for ffmpeg implmentations.

Can you please solve this with updated library 'com.googlecode.mp4parser:isoparser:1.1.22' for same with updated readme?

Your Environment

software version
react-native-video-processing v1.13.0
react-native v0.59.10
node v12.12.0
xlogix commented 4 years ago

Just send a PR with the updated lib version and he'll merge it. @rajeevrocker7