wseemann / FFmpegMediaMetadataRetriever

FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
1.72k stars 387 forks source link

getFrameAtTime OutOfMemoryError #147

Closed jaydonga closed 7 years ago

jaydonga commented 7 years ago

Retrieving Bitmap from video in loop and saving Bitmap to ArrayList results in OutOfMemoryError

while (oneSecondInMilli < dur) {
     listFrames.add(mmRetriever.getFrameAtTime(oneSecondInMilli * 1000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST));
     oneSecondInMilli = oneSecondInMilli + 100;
}
wseemann commented 7 years ago

@jaydonga Yes, you are filling an array with several hundred (if not thousands) of objects that consume memory. This is the expected outcome. If you are trying to capture images I suggest using an approach that doesn't consist of trying to store all of them in memory at once.