how to reduce size of video before upload to server programmatically in android

独自空忆成欢 提交于 2019-12-03 07:22:30

问题


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


回答1:


You have two way to do that:

  • Encode it to a lower bit rate and/or lower resolution. Have a look here: Is it possible to compress video on Android?.

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

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

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.

Have a look on this discussion:

Android: OutOfMemoryError while uploading video - how best to chunk?



来源:https://stackoverflow.com/questions/29263797/how-to-reduce-size-of-video-before-upload-to-server-programmatically-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!