OutOfMemoryError: how best to transfer large video files into a byte array?

by Abdul Mateen » Fri, 09 Apr 2010 05:31:45 GMT


Sponsored Links
 I got the same problem, when I uploaded the videos to Facebook, I have got
the same issue while uploading big files, have you found any workarround,
even I flushed the outstream on every read. but it did not also seems be the
solution.




>



OutOfMemoryError: how best to transfer large video files into a byte array?

by Anna Powell-Smith » Sat, 10 Apr 2010 00:44:27 GMT


 >


Because it's the only way that I know to get from a content Uri to the byte
array that I use to create the FilePart element of the multipart message.

It is possible to create the FilePart element using a File object (this
handles even a 50MB file successfully, though it takes around half an hour
to create, so I don't fancy using it in practice). However, I can't work
from a File object, because I have to use the content Uri that is returned
by ACTION_VIDEO_CAPTURE. Originally I did pass a File Uri as extra output to
ACTION_VIDEO_CAPTURE, but that unfortunately breaks the 'retake' and
'delete' buttons on the video camera.




Thanks, but please could you explain what you mean by that? Perhaps with an
example?

Mark warned that creating buffers tends to clog up memory. Indeed, after
increasing the buffer size to 1MB, as he predicted, I can now handle files
up to about 5MB.

--


Sponsored Links


OutOfMemoryError: how best to transfer large video files into a byte array?

by Anna Powell-Smith » Sat, 10 Apr 2010 02:35:46 GMT


 



Thanks. Constructing a FilePart from a File is actually as easy as this, I
think - but do you think your method would provide some advantage?

    File temp_file = new File(Environment.getExternalStorageDirectory(),
 "myfile.gif");
    FilePart vFile = new FilePart("fileupload", temp_file);

As I say, this works for files of 50MB. The only reason I can't use it is
that I can't construct a File object from an Android content Uri. I have to
use an Android content Uri because that's what the video intent returns.

--



OutOfMemoryError: how best to transfer large video files into a byte array?

by Anna Powell-Smith » Sat, 10 Apr 2010 02:49:46 GMT


 




Ah. If I could transform my content Uri into FileInputStream (will have to
experiment) then I could use your method.

I can convert a content Uri to an InputStream already, so it'll just be
getting from an InputStream to a FileInputStream that might be the
challenge. I'll experiment.

--



OutOfMemoryError: how best to transfer large video files into a byte array?

by Android Development » Thu, 22 Apr 2010 00:03:11 GMT


 Select a fixed buffer size first.

Then start writing the byte array to a file. Once the file size reaches the
buffer size configured, copy that file to a temporary location (a temp
file). Then transfer this temp file to the web server. Once transferred
successfully, make sure to delete this temp file (by calling deleteOnExit()
) when the file was created.

To make this work properly, there have to be 2 threads at work  - the thread
that is writing the byte array to a file and the thread that is doing the
heavy duty stuff in the background - copy to the temp file location and
finally upload it to a server etc. This heavy duty thread waits on a
condition (waits for the file to reach the buffer size configured to start
the transfer).

I hope this makes sense...just sharing my thoughts aloud.

Best Regards
Indodroid.

On Sat, Apr 10, 2010 at 12:19 AM, Anna Powell-Smith <





>



Other Threads

1. How to get network consumption?

Dear all,
     I want to get the network consumption (includes uplink
consumption and downlink consumption), can you give me a sample?

Sincerely,
Daniel

--~--~---------~--~----~------------~-------~--~----~

2. Need to know if it can access the USB as a com port

I have gone through the documents and found that there is a linux
kernel running.
according to the capabilities of the linux if i plug in the USB to
serial converter it should detecte it as a com port such as /dev/
ttyUSBX...

So by using the SDK can i access the Serial port some how?

I read that the usb signals are detected as a mass storage device
connectivity or power connected signals but what about the above
mentioned task?

The documentation also says there are C++ libraries inside but the sdk
sample codes are in java. is it possible to access using C++?

BR

--~--~---------~--~----~------------~-------~--~----~

3. setting proxy selectively

4. Browser Bookmarks Enhancement & CTS Certification

5. In-place upgrade of app, outside of Market

6. Changing volume of voice calls

7. Protecting application uninstall with password