Extract/modify video frames on Android

谁说胖子不能爱 提交于 2020-01-12 02:29:12

问题


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.


回答1:


Option A:

You can create a SurfaceTexture object and attach this to the MediaPlayer as follows

myPlayer = new MediaPlayer
...
myRedirectionSurface = new Surface(mySurfaceTexture);
myPlayer->setSurface(myRedirectionSurface);

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. !



来源:https://stackoverflow.com/questions/8665201/extract-modify-video-frames-on-android

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