使用MediaCodec记录表面 [英] Recording a Surface using MediaCodec

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

问题描述

因此,在我的应用程序中,我可以使用

So, In my application, I am able to show effects(like blur filter, gaussian) to video that comes from Camera using GPUImage library.

基本上,我(库)将从相机获取输入,获取原始字节数据,将其从YUV格式转换为RGBA格式,然后对该图像应用效果,并使用显示在GLSurfaceViewSurface上OpenGL.最终,对用户来说,它就像是应用了效果的视频.

Basically, I (library) will take the input from the Camera, get's the raw byte data, converts it into RGBA format from YUV format, then applies effects to this image and displays on the Surface of GLSurfaceView using OpenGL. finally, to the user, it looks like a video with effects applied.

现在,我想使用 MediaCodec API.

Now I want to record the frames of Surface as a video using MediaCodec API.

但这是讨论表示我们无法将预定义的Surface传递给MediaCodec.

but this discussion says that we can not pass a predefined Surface to the MediaCodec.

我在 bigflake 上看到了一些示例,他在其中使用MediaCodec.createInputSurface()创建Surface,但是对于我,Surface来自GLSurfaceView.

I have seen some samples at bigflake where he is creating Surface using MediaCodec.createInputSurface() but for me, Surface comes from the GLSurfaceView.

那么,如何录制Surface的帧作为视频?

So, how can I record a frames of a Surface as a video?

我将并行记录音频,使用FFMPEG合并视频和音频,并以应用了效果的视频形式呈现给用户.

I will record the audio parallelly, merge that video and audio using FFMPEG and present to the user as a Video with effects applied.

推荐答案

您可以在 Grafika中看到完整的示例.

尤其是,显示+捕获摄像机"活动将摄像机输出记录到.mp4.它还演示在GL着色器中应用了一些简单的图像处理技术.它使用GLSurfaceView和回旋的舞蹈来保持录音在方向变化中的表现.

In particular, the "Show + capture camera" activity records camera output to .mp4. It also demonstrates applying some simple image processing techniques in the GL shader. It uses a GLSurfaceView and a convoluted dance to keep the recording going across orientation changes.

"Recording GL app with FBO"活动还可能引起人们的兴趣,该活动记录了OpenGL ES渲染的几种不同方式.它使用普通的SurfaceView并且更加简单.

Also possibly of interest, the "Record GL app with FBO" activity records OpenGL ES rendering a couple different ways. It uses plain SurfaceView and is much more straightforward.

这篇关于使用MediaCodec记录表面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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