安卓视频过滤器 [英] Android video filter

查看:34
本文介绍了安卓视频过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个应用程序,我可以在其中向录制的视频添加过滤器.基本上,我想复制 Instagram 视频或 Viddy 中存在的功能.

I'm trying to create an app where I am able to add filters to a recorded video. Basically, I want to replicate the functionality that exists in Instagram video, or Viddy.

我已经做过研究,但无法拼凑起来.我研究过使用 GLSurfaceView 播放录制的视频,我知道我可以使用 NDK 进行像素操作并将其发送回 SurfaceView 或以某种方式保存.问题是,我不知道如何发送像素数据,因为似乎没有访问它的功能.这个想法来自相机功能onPreviewFrame".该函数返回一个字节数组,允许我操作像素并显示它.

I've done research and I can't piece it all together. I've looked into using GLSurfaceView to play the recorded video and I know I could use NDK to do the pixel manipulation and send it back to the SurfaceView or save it somehow. The problem is, I don't know how to send the pixel data because there seems to be no function to access it. This idea came from the Camera function "onPreviewFrame". The function returns a byte array allowing me to manipulate the pixels and display it.

另一个想法是使用 GLSurfaceView 并使用 OpenGL 来渲染过滤器.GLSurfaceView 有一个你可以设置的渲染器,但我对 OpenGL 不是很熟悉.但同样,这又回到了实际获取每个视频帧的像素.我还阅读了有关将每一帧作为纹理翻录,然后在 OpenGL 中操作纹理的内容,但我遇到的答案不是很详细.

Another idea is to use GLSurfaceView and use OpenGL to render the filter. GLSurfaceView has a renderer you can set, but I'm not very familiar with OpenGL. But again, this goes back to actually getting the pixels of each video frame. I also read about ripping each frame as a texture and then manipulating the texture in OpenGL but the answers I've come across are not very detailed.

最后,我研究了 JavaCV.尝试使用 FFmpegFrameGrabber,但我也没有太多.我只想抓取一帧,但是当我尝试将帧的 ByteBuffer 写入 ImageView 时,出现缓冲区不足以容纳像素"错误.

Lastly, I've looked into JavaCV. Trying to use FFmpegFrameGrabber, but I haven't had much either. I wanted to just grab one frame, but when I try to write the frame's ByteBuffer to an ImageView, I get a "buffer not large enough for pixels" error.

任何指导都会很棒.

推荐答案

从 Android 4.3 开始,您可以使用 Surface 作为编码器的输入.http://developer.android.com/about/versions/android-4.3.html#多媒体

From Android 4.3 you can use a Surface as the input to your encoder. http://developer.android.com/about/versions/android-4.3.html#Multimedia

因此您可以使用 GLSurfaceView 并使用片段着色器应用过滤器.

So you can use GLSurfaceView and apply the filters using fragment shaders.

你可以在这里找到一些很好的例子.http://bigflake.com/mediacodec/

You can find some good examples here. http://bigflake.com/mediacodec/

这篇关于安卓视频过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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