如何从base64解码video?

我希望转换video在base64字符串,所以我转换migBase64方法通过我在Android的video它将video转换成字符串成功,但当我解码字符串到video然后它不正确转换video。 如果有人知道,请帮助我。

我尝试如下代码:

String encodedString; //Decode Video To String File tempFile = new File(Environment.getExternalStorageDirectory()+ "/my/part/my_0.mp4"); byte fileContent[] = new byte[3000]; try { FileInputStream fin = new FileInputStream(tempFile); while (fin.read(fileContent) >= 0) { // b.append(Base64.encodeToString(fileContent, true)); encodedString = Base64.encodeToString(fileContent, true); } } catch (IOException e) { } //Encoding Video To String Successfully. //Decode String To Video try { byte[] decodedBytes = Base64.decodeF File file2 = new File(Environment.getExternalStorageDirectory() + "/my/Converted.mp4"); FileOutputStream os = new FileOutputStream(file2, true); os.write(decodedBytes); os.close(); } catch (Exception e) { // TODO: handle exception Log.e("Error", e.toString()); } // Problem is in Decoding. 

我的问题是解码字符串到video,我的原始video是1 MB,解码后的video是1.1 kb它不转换我的原始video请帮助我。

我解决了我的问题,我发布了一些帮助的代码。

 //Encode Video To String With mig Base64. File tempFile = new File(Environment.getExternalStorageDirectory() + "/my/part/my_0.mp4"); String encodedString = null; InputStream inputStream = null; try { inputStream = new FileInputStream(tempFile); } catch (Exception e) { // TODO: handle exception } byte[] bytes; byte[] buffer = new byte[8192]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { while ((bytesRead = inputStream.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } } catch (IOException e) { e.printStackTrace(); } bytes = output.toByteArray(); encodedString = Base64.encodeToString(bytes, true); Log.i("Strng", encodedString); //Decode String To Video With mig Base64. byte[] decodedBytes = Base64.decodeFast(encodedString.getBytes()); try { FileOutputStream out = new FileOutputStream( Environment.getExternalStorageDirectory() + "/my/Convert.mp4"); out.write(decodedBytes); out.close(); } catch (Exception e) { // TODO: handle exception Log.e("Error", e.toString()); }