How to convert video file(.mp4, .3gp) form

2019-08-18 14:47发布

问题:

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!!!!

回答1:

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