视频大串的base64导致的OutOfMemoryError [英] Big video to string base64 causes outofmemoryerror

查看:1186
本文介绍了视频大串的base64导致的OutOfMemoryError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要发送视频到.NET Web服务,即时通讯发送一个字符串的base64连接code,如果视频的约2MB或6 O 7秒内它的好,但如果是更为沉重的原因的OutOfMemoryError当我这样做Bas.en code [字节[]);

i need to send video to webservice in .net, im send a string base64 encode, if the video its about 2MB or 6 o 7 seconds all its ok, but when is more heavy causes outofmemoryerror when i do Bas.encode[byte[]);

这是我的code:

videoPath = getRealPathFromURI(fileUri);
                            File tmpFile = new File(videoPath);
                            in = null;
                            in = new BufferedInputStream(new FileInputStream(tmpFile));
                            bos = new ByteArrayOutputStream();
                            long tamano = tmpFile.length();
                            int iTamano = (int) tamano;
                            byte[] b = new byte[iTamano];
                            int bytesRead;
                            while ((bytesRead = in.read(b)) != -1) {
                                bos.write(b, 0, bytesRead);
                            }
                            ficheroAEnviar = bos.toByteArray();
try {
                    strBase64 = Base64.encode(ficheroAEnviar);

                }
                catch (Exception e) {

                    correcto = false;
                    e.printStackTrace();
                }

在崩溃这一行:strBase64 = Base64.en code(ficheroAEnviar);

Crash in this line: strBase64 = Base64.encode(ficheroAEnviar);

推荐答案

您不能做到这样。内存采用的是Android的一个问题。你应该每个部分一分为几部分视频,连接code,把它(我想你想通过WS或东西发送)和重组它的目的地。

You cannot do like this. The memory is an issue in android. You should split the video in few parts, encode each part, send it (I think you want to send it over a WS or something) and recombine it on destination.

这篇关于视频大串的base64导致的OutOfMemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆