how to store video in a recordstore
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Kurinchikumaran_Thavarajah
Posted On:   Wednesday, August 16, 2006 06:57 AM

hi all, I am developing a J2ME application which stores video clips(mpeg) of 5 second in a recordstore and play it later. the code is like this; InputStream is = Connector.openInputStream(url); byte[] buffer = new byte[4*1024]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while (true) { int read = is.read(buffer, 0, buffer.length); if (read < 0) { break; } baos.write(buffer, 0, read); } buffer = baos.toByteArray(); int id = fileRecordstore.addRecord(buffer, 0 , buffer.length); but when I read    More>>

hi all,

I am developing a J2ME application which stores video clips(mpeg) of 5 second in a recordstore and play it later. the code is like this;


InputStream is = Connector.openInputStream(url);

byte[] buffer = new byte[4*1024];

ByteArrayOutputStream baos = new ByteArrayOutputStream();

while (true) {

int read = is.read(buffer, 0, buffer.length);

if (read < 0) {

break;

}

baos.write(buffer, 0, read);

}

buffer = baos.toByteArray();

int id = fileRecordstore.addRecord(buffer, 0 ,

buffer.length);

but when I read (in the while loop) after reading some time it throws Uncaught exception java/lang/OutOfMemoryError. I changed the byte array size also, but no use. the size of the mpeg file is 406 kB. but the application work when I run it without storing.

can anyone let me know how can I change the code to eliminate this problem

Kumaran

   <<Less

Re: how to store video in a recordstore

Posted By:   Anonymous  
Posted On:   Friday, August 18, 2006 02:55 PM

Looks like to me you are creating a ByteArray in the stack that will grow to 406kB. How big is the stack on your device?

You should include more details about the exception. Like what line does it occur on? But it seems to me the culprit will be that ByteArrayOutputStream will grow to the size of what ever comes in your InputStream and eventually run you out of Stack memory.
About | Sitemap | Contact