简体   繁体   English

Android MediaCodec api压缩视频

[英]Android MediaCodec api compress video

I am building an app where i need to compress video before uploading it to server. 我正在构建一个应用程序,我需要压缩视频,然后再将其上传到服务器。 I have tried ffmpeg4android( https://github.com/chloette/ffmpeg4android ) which is very heavy in size. 我尝试了ffmpeg4android( https://github.com/chloette/ffmpeg4android ),它的体积非常大。 Its increasing 20MB size of my app. 我的应用程序的大小增加了20MB。

I tried MediaCodec android api, which is not working as expected. 我尝试了MediaCodec android api,它没有按预期工作。

Can anyone have working code example for compressing a video with MediaCodec android api? 任何人都可以使用MediaCodec android api压缩视频的工作代码示例吗?

Update: Yes looking for MP4 containers. 更新:是的,正在寻找MP4容器。

This is a vague question since you do not specify a codec or file container, but assuming you are interested in H.264 codecs and MP4 containers there are a lot of examples here . 这是一个含糊不清的问题,因为你没有指定编解码器或文件容器,但假设你有兴趣的H.264编解码器和MP4容器有很多的例子在这里 Specifically, you will probably be interested in CameraToMpegTest.java . 具体来说,您可能会对CameraToMpegTest.java感兴趣。

Note that even though the requirements are stated as Android 4.3, MediaCodec support is poor until Android 5.1. 请注意,即使要求被称为Android 4.3,MediaCodec支持也很差,直到Android 5.1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM