Javacv: Working around with long video creation from Images

Created on 31 Oct 2019  路  3Comments  路  Source: bytedeco/javacv

Recently I'm working around with FFmpegFrameRecorder on Android to convert a folder of Bitmaps to a Video. Things went smoothly with Video length that < 1 minutes. But when it bigger than 1 minutes. The app tend to close without any exceptions
So I went deep down to see what happend. It appear that
_AndroidFrameConverter().convert(bitmap)_
AndroidFrameConverter using copyPixelsToBuffer to copy from Bitmap to Frame's Buffer and it's using native memory which maybe the cause that made the app fail.
I want to ask if there's anyway we can convert Bitmap to Javacv Frame without using Native Memory. Because I want to achieve like 10 minutes long video (about 12000 Images)

question

Most helpful comment

It's probably just the garbage collector that isn't able to keep up and it's running out of memory. The easiest thing to do is probably to create only a single instance of AndroidFrameConverter and reuse it for every frame. That will create less garbage.

All 3 comments

It's probably just the garbage collector that isn't able to keep up and it's running out of memory. The easiest thing to do is probably to create only a single instance of AndroidFrameConverter and reuse it for every frame. That will create less garbage.

I will try that. Thank for your reply.

Confirmed, it's my bad to put a class constructor inside a for loop. Thank for your help @saudet .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SenudaJayalath picture SenudaJayalath  路  3Comments

myScoopAndroidCamera picture myScoopAndroidCamera  路  4Comments

chrisliu12345 picture chrisliu12345  路  4Comments

iamazy picture iamazy  路  4Comments

cansik picture cansik  路  4Comments