Azhar
Azhar

Reputation: 41

How to convert video file(.mp4, .3gp) format into binary format in android

I had captured a video from camera and stored in sd card, now i need to convert that video file into binary format for my process. Can any one tell me how can i convert video files into binary format. Thanks in advance!!!!

Upvotes: 0

Views: 3632

Answers (1)

Rajesh Rajaram
Rajesh Rajaram

Reputation: 3277

I converted my image files and pdf file with the following method, try this with your requirement

Bundle objBundle = objResult.getExtras();
Uri uriString = Uri.parse(objBundle.get("").toString());
File file = new File(uriString.getPath());
FileInputStream objFileIS = new FileInputStream(file);
ByteArrayOutputStream objByteArrayOS = new ByteArrayOutputStream();
byte[] byteBufferString = new byte[1024];
for (int readNum; (readNum = objFileIS.read(byteBufferString)) != -1;) 
{
 objByteArrayOS.write(byteBufferString, 0, readNum);
 System.out.println("read " + readNum + " bytes,");
}                    
byte[] byteBinaryData = Base64.encode((objByteArrayOS.toByteArray()), Base64.DEFAULT);
strAttachmentCoded = new String(byteBinaryData);

This may help you

Upvotes: 1

Related Questions