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. One problem with varible passing

Hi,
I have 2 activity which are using RadioButtons. I am getting some int
value by the buttons. Now I want to pass these 2 values to some other
class (not activity). The class is the game loop and I want to use
this 2 values for diffrent level changes and other stuff.

I am confused about that how can I do it.

I tried to use object of that Activity class in the class file of
game. The problem is that Activity is no longer in use when this game
class comes into existance. So I can't pass the value even by creating
the object of activity class.

Is there any way I can solve this?

Thanks,
Mitul
--~--~---------~--~----~------------~-------~--~----~

2. getListView().setTextFilterEnabled(true) get the filter text problem

no people?

On Dec 3, 2:11am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>


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

3. AuthenticationException when accessing Google Spreadsheets

4. Can we register a callback which is called when user clicks on the play button of MediaController?

5. Streaming RTSP directly by suing MediaPlayer

6. Custom Style

7. Cheap functional phones