转换视频文件时内存不足异常
我正在使用 Base64 编码将视频文件转换为字符串。
try {
encodedString =Base64.encodeBytes((getBytesFromFile(new File(Description.PATH))),Base64.GZIP);
} catch (IOException e) {
e.printStackTrace();
}
当我转换 60 秒视频时,出现内存不足异常。
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): Caused by: java.lang.OutOfMemoryError
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.CharArrayBuffer.<init>(CharArrayBuffer.java:43)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.ReadWriteCharArrayBuffer.<init>(ReadWriteCharArrayBuffer.java:47)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.BufferFactory.newCharBuffer(BufferFactory.java:82)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.CharBuffer.allocate(CharBuffer.java:53)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:214)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.charset.Charset.decode(Charset.java:730)
请让我知道如何解决此问题。
提前致谢
I'm converting a Video file to string using Base64 encoding.
try {
encodedString =Base64.encodeBytes((getBytesFromFile(new File(Description.PATH))),Base64.GZIP);
} catch (IOException e) {
e.printStackTrace();
}
When i'm converting 60 sec video, I'm getting out of memory exception..
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): Caused by: java.lang.OutOfMemoryError
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.CharArrayBuffer.<init>(CharArrayBuffer.java:43)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.ReadWriteCharArrayBuffer.<init>(ReadWriteCharArrayBuffer.java:47)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.BufferFactory.newCharBuffer(BufferFactory.java:82)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.CharBuffer.allocate(CharBuffer.java:53)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:214)
09-30 04:52:52.322: ERROR/AndroidRuntime(29995): at java.nio.charset.Charset.decode(Charset.java:730)
Please let me know how to solve this issue.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你应该使用encodeToString而不是encodeBytes()。
I think you should use encodeToString instead of encodeBytes().