I am streaming video from an IP camera onto my android app using rtsp protocol. There is a SurfaceView
in the layout. A SurfaceHolder
was created which then gets the holder from the SurfaceView
then this is viewed using a MediaPlayer
object.
My question is 1) How do I take a picture of what is being displayed in the SurfaceView/SurfaceHolder/MediaPlayer and save it onto the external storage without necessarily just taking a screenshot of the whole screen and 2) How do I record the feed for a maximum of 15seconds and save it to external storage too.
You can't pull frames back out of a SurfaceView. The Surface is the producer end of a producer-consumer pair, and the consumer side is in a different process (SurfaceFlinger, the system graphics compositor).
If you feed the video into a SurfaceTexture instead, you can get access to each frame as an "external" OpenGL ES texture. You can then render this to the screen or to an offscreen buffer that you save to disk, or to a video encoder.
Various examples that use Camera as a video source can be found in Grafika.