0

我已经从相机捕获了一个视频并存储在 sd 卡中,现在我需要将该视频文件转换为我的过程的二进制格式。谁能告诉我如何将视频文件转换为二进制格式。提前致谢!!!!

4

1 回答 1

1

我使用以下方法转换了我的图像文件和pdf文件,请根据您的要求尝试

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);

这可能会帮助你

于 2012-11-16T12:31:04.113 回答