Android 上的 FFmpeg [英] FFmpeg on Android

查看:21
本文介绍了Android 上的 FFmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Android 上编译了 FFmpeg (libffmpeg.so).现在我必须构建一个像 RockPlayer 这样的应用程序,或者使用现有的 Android 多媒体框架来调用 FFmpeg.

I have got FFmpeg compiled (libffmpeg.so) on Android. Now I have to build either an application like RockPlayer or use existing Android multimedia framework to invoke FFmpeg.

  1. 您是否有在 Android/StageFright 上集成 FFmpeg 的步骤/程序/代码/示例?

  1. Do you have steps / procedures / code / example on integrating FFmpeg on Android / StageFright?

你能指导我如何使用这个库进行多媒体播放吗?

Can you please guide me on how can I use this library for multimedia playback?

我有一个要求,我已经有音频和视频传输流,我需要将其提供给 FFmpeg 并对其进行解码/渲染.我如何在 Android 上执行此操作,因为 IOMX API 是基于 OMX 的,无法在此处插入 FFmpeg?

I have a requirement where I have already audio and video transport streams, which I need to feed to FFmpeg and get it decoded / rendered. How can I do this on Android, since IOMX APIs are OMX based and cannot plug-in FFmpeg here?

我也找不到有关需要用于播放的 FFmpeg API 的文档.

Also I could not find documentation on the FFmpeg APIs which need to be used for playback.

推荐答案

以下是我让 ffmpeg 在 Android 上运行所经历的步骤:

Here are the steps I went through in getting ffmpeg to work on Android:

  1. 为 Android 构建 ffmpeg 的静态库.这是通过使用 olvaffe 的 ffmpeg android 端口 (libffmpeg) 实现的Android 构建系统.只需将源放在/external 和 make 下即可.您还需要从 Android 版本中提取 bionic(libc) 和 zlib(libz),因为 ffmpeg 库依赖于它们.
  2. 使用 Android NDK 创建包装 ffmpeg 功能的动态库.有很多关于如何使用 NDK 的文档.基本上,您需要编写一些 C/C++ 代码来将您需要的功能从 ffmpeg 导出到 java 可以通过 JNI 与之交互的库中.NDK 允许您轻松链接到您在第 1 步中生成的静态库,只需在 Android.mk 中添加与此类似的行:LOCAL_STATIC_LIBRARIES := libavcodec libavformat libavutil libc libz

  1. Build static libraries of ffmpeg for Android. This was achieved by building olvaffe's ffmpeg android port (libffmpeg) using the Android Build System. Simply place the sources under /external and make away. You'll need to extract bionic(libc) and zlib(libz) from the Android build as well, as ffmpeg libraries depend on them.
  2. Create a dynamic library wrapping ffmpeg functionality using the Android NDK. There's a lot of documentation out there on how to work with the NDK. Basically you'll need to write some C/C++ code to export the functionality you need out of ffmpeg into a library java can interact with through JNI. The NDK allows you to easily link against the static libraries you've generated in step 1, just add a line similar to this to Android.mk: LOCAL_STATIC_LIBRARIES := libavcodec libavformat libavutil libc libz

使用来自您的 java 源代码的 ffmpeg-wrapping 动态库.有足够多的关于 JNI 的文档,你应该没问题.

Use the ffmpeg-wrapping dynamic library from your java sources. There's enough documentation on JNI out there, you should be fine.

关于使用ffmpeg进行播放,有很多例子(ffmpeg二进制本身就是一个很好的例子),这里 的基础教程.最好的文档可以在标题中找到.

Regarding using ffmpeg for playback, there are many examples (the ffmpeg binary itself is a good example), here's a basic tutorial. The best documentation can be found in the headers.

祝你好运:)

这篇关于Android 上的 FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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