views:

42

answers:

1

I was wondering if anyone knows 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.

+1  A: 

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 :)

Pandoro
Thanks for that Pandoro, I eventually want to be able to stream it over a network though, so recording it using MediaRecorder is not an option as it will have to be contstantly recording and constantly playing
Donal Rafferty