开发者

Android - How do I capture and loop video to the screen?

I was wondering if anyone know开发者_StackOverflow中文版s of a tutorial explaining how to capture the video from the camera on an Android device and then display the video in real time on the screen?

I have looked up MediaRecorder, MediaPlayer, Videoview but they all seem concerned with recording audio/video to a file or playing audio/video from a file or a URL.

I simply want to be able to take the data from what the camera is seeing and display it on the screen.


I am not exactly sure how you would record it AND loop it back with one thing. But I guess one way to do it is record it with a MediaRecorder on one side and just show the camera preview on the screen. To do that you will need to create a class which extends SurfaceView. In the SurfaceCreated method you just open a new Camera object and set the surfaceView as PreviewDisplay for the camera with the setPreviewDisplay methode. In the SurfaceChanged method you can do some configuration of the size camera resolution and actually start the preview of the camera. Probably this is also the place where you want to start recording. And in the SurfaceDestroyed method you can stop the preview again.
This won't play the recorded file in realtime, but it will show the same as what is being recorded, unless you modify the video in some way. I'm not sure if this is helpful, I use the camera preview for a different purpose, but maybe it is something to look into. At least I would try to do it this way if it would be my task. Let me know if it worked out :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜