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

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

问题描述

因此,在我的应用程序中,我能够使用 GPUImage 库.

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 格式,然后对该图像应用效果并显示在 SurfaceGLSurfaceView 使用 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.

现在我想使用 Surface 的帧记录为视频"nofollow noreferrer">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 来自 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.

同样可能感兴趣的是,Record 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天全站免登陆