如何在Android中以编程方式上传到服务器之前减小视频大小 [英] how to reduce size of video before upload to server programmatically in android

查看:150
本文介绍了如何在Android中以编程方式上传到服务器之前减小视频大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将视频上传到服务器,当我从图库中捕获视频或从摄像机录制时,服务器响应我该错误,但是当我上传2 MB大小的视频时,它已成功上传.如何压缩视频以减小尺寸?我从脸书上传了视频,手机上的视频大小为140 MB,但是脸书对视频进行了处理,并将其大小减小到1.35 MB

I want to upload video to server, when I catch video from gallery or record from camera , the server response to me that error but when I upload video with size 2 MB , it is uploading successfully. How can I compress the video to reduce the size? I uploaded the video from face book , the size of video on my mobile is 140 MB , but face book make a process on the video and reduce it's size to 1.35 MB

推荐答案

您有两种方法可以做到这一点:

You have two way to do that:

尝试压缩/压缩它.在这里看看: http://www.jondev.net/articles/Zipping_Files_with_Android_%28Programmatically %29

Try to zip/compress it. Have a look here: http://www.jondev.net/articles/Zipping_Files_with_Android_%28Programmatically%29

不幸的是,我从未尝试使用140MB的视频来做到这一点.这就是为什么我向您建议第一个库(FFmpeg 4 Android)的原因.

Unfortunately I never tried to do that with a 140MB video. This is why I suggested to you the first library (FFmpeg 4 Android).

顺便尝试增加服务器上的UPLOAD_LIMIT.但这不是问题,即使将其增加到10MB,也仍然必须对其进行压缩.不要尝试将UPLOAD_LIMIT增加到140MB,这肯定会导致HTTP超时.

By the way, try to increase also your UPLOAD_LIMIT on your server. But this is not the problem, even if you increase it to 10MB you still have to compress it. Do not try to increase the UPLOAD_LIMIT to 140MB, it will cause for sure an HTTP timeout.

否则,您需要启用分块上传.

Otherwise you need to enable a chunked upload.

看看这个讨论:

Android:上传视频时出现OutOfMemoryError-最好如何分块?

这篇关于如何在Android中以编程方式上传到服务器之前减小视频大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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