在 Android 上提取/修改视频帧
我有一个视频文件。我想获取视频的每一帧并对帧进行一些修改,例如在其中绘制另一个位图,放置一些文本等。
是否有任何 API/框架可用于从 Android 中的视频中获取帧?我在 iOS 中使用他们的 AVFramework 做了类似的事情。
如果可以使用 ffmpeg,我将使用一些可用的开源 NDK。
I have a video file. I want to get each frame of the video and do some modifications to the frame, such as drawing another bitmap in that, putting some text etc.
Is there any API/framework available to get frames from video in Android? I've done something similar in iOS using their AVFramework.
If it is possible with ffmpeg, I will use some of the opensource NDKs available.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选项 A:
您可以创建一个 SurfaceTexture 对象并将其附加到MediaPlayer 如下
这样,播放器的解码流被“重定向”到 SurfaceTexture 而不是 SurfaceView。
只要有可用的解码帧,就会调用 OnFrameAvailableListener。
要访问/修改图像,您可以使用 Surface 的锁定/解锁方法
我的重定向表面。
重要提示:您需要有 API 级别 14 支持才能正常工作!
选项 B:
正如您已表明使用 ffmpeg 的可能性,您可以实现您的预期,因为您可以完全访问解码器的输出帧。
您可以从 RockPlayer 或 MoboPlayer 的 ffmpeg 端口开始。
但在此选项中,渲染 NDK 的视频输出并不是直接进行的。 !
Option A:
You can create a SurfaceTexture object and attach this to the MediaPlayer as follows
This way, the player's decoded stream is "redirected" to SurfaceTexture and not the SurfaceView.
The OnFrameAvailableListener is called whenever you have a decoded frame available.
To access/modify the image, you can use the Surface's lock/unlock methods on
myRedirectionSurface.
IMPORTANT NOTE: You need to have API level 14 support to get this working !
Option B:
As you have indicated likelihood of using ffmpeg, you can achieve what you intend to, as you have full access to the decoder's output frames.
You can start with RockPlayer's or MoboPlayer's ffmpeg port.
But in this option, rendering the video output from NDK is not staright-forward. !