Fast Video Compression on Android

这一生的挚爱 提交于 2019-11-26 20:57:29

x264 cpu capabilities

Your ffmpeg console output/log shows the following message from libx264:

using cpu capabilities: none!

For your device I would expect something like:

using cpu capabilities: ARMv7 NEON

You should re-evaluate how you compiled x264 so it properly supports the capabilities of your CPU. With none it encodes significantly slower.

  • Do not use the --disable-asm configure option for x264.
  • After you run ./configure for x264 the console output should show asm: yes.
  • Use a recent x264. I see many users compiling old versions that may miss out on optimizations.
  • Then recompile ffmpeg so it uses the new x264. Make sure ffmpeg does not link to the wrong x264 if you have multiple versions.

MediaCodec hardware acceleration

ffmpeg currently supports hardware assisted H.264 and HEVC decoding via the MediaCodec API in Android which may help decrease the overall processing time. For more info and an up-to-date list of capabilities see FFmpeg Wiki: Hardware Acceleration.

To use it ensure your ffmpeg is compiled with --enable-jni and --enable-mediacodec.

You'll have to use the hardware accelerated encoding capabilities of the device, if any. As far as I can tell ffmpeg doesn't offer HW accelerated encoding on Android. There is a libstagefright but it's used for HW decoding.

Depending on your target API version you may be able to use MediaCodec (API 16) to do HW encoding and MediaMuxer (API 18) to mux into mp4. If you manage to encode with MediaCodec you could use ffmpeg to do the muxing part, which would require only API 16.

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