如何使用摄像头preVIEW上TextureView录制视频 [英] How to record the video using camera preview on TextureView

查看:1659
本文介绍了如何使用摄像头preVIEW上TextureView录制视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在一些Android 4.0的设备玩TextureView。例如,我试图开发一个简单的应用程序,它可以录制视频,并使用TextureView为其preVIEW。但是,据我读到了Android API文档,标准MediaRecorder需要一定的表面,以便进行视频录制,但在另一方面,TextureView没有自己的面了,所以TextureView和MediaRecorder之间不兼容似乎存在。

I have been playing with TextureView on some Android 4.0 devices. For example, I tried to develop a simple app, which can record the video and uses TextureView for its preview. However, as far as I read the Android API documents, standard MediaRecorder requires certain surface in order to perform video recording, but on the other hand, TextureView does not have its own surface anymore, so an incompatibility between TextureView and MediaRecorder seems exist.

<一个href="http://developer.android.com/reference/android/media/MediaRecorder.html#set$p$pviewDisplay%28android.view.Surface%29">MediaRecorder.set$p$pviewDisplay

TextureView

有谁知道如何使用标准MediaRecorder与TextureView作为其摄像头preVIEW录制视频?或者是有什么办法可以录制视频以外的其他MediaRecorder?

Does anyone know how to record video using standard MediaRecorder with TextureView as its camera preview? Or is there any way to record video other than MediaRecorder?

非常感谢你。

推荐答案

根据这个问题,在果冻豆及以上,你根本不叫设置previewDisplay() MediaRecorder 将自动使用所用的相机preVIEW 。我可以证实,没有要求设置previewDisplay()确实工作,至少在Android 4.2中,摄像机 preVIEW被设置为一个 TextureView 。我还没有尝试过在旧的Andr​​oid版本,这证实4.1的作品。

According to this issue, on Jelly Bean and higher, you simply don't call setPreviewDisplay(), and MediaRecorder will automatically use the preview used by the Camera. I can confirm that not calling setPreviewDisplay() does indeed work, at least on Android 4.2, when the Camera preview is set to be a TextureView. I have not yet tried this on older Android versions to confirm that 4.1 works.

这确实留下了一点的差距,在3.0-4.0的Andr​​oid设备可能无法使用 TextureView 为previews。

This does leave a bit of a gap, in that Android 3.0-4.0 devices perhaps cannot use TextureView for previews.

这篇关于如何使用摄像头preVIEW上TextureView录制视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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