Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In android how can I save an RTSP stream to file while playing it?

I need to be able to play a video received over RTSP AND save it to disc (well, the SD card) at the same time. This is a live stream, so I cannot download the entire file first and then play it. I must play and record simultaneously. I can record video from the on board camera using MediaRecorder, and I can receive an RTSP stream using MediaPlayer or VideoView, but I don't know how to combine the two.

MediaRecorder seems to be the only way to record video, but it only supports one video source: the camera. Its setVideoSource() method allows no other sources. Perhaps I need to get an OutputStream somehow, which I can then write to a file?

Thanks for any help.

like image 996
Mark Herscher Avatar asked Nov 12 '10 00:11

Mark Herscher


Video Answer


1 Answers

What you want to do is hard. There is no easy way to do this.

You have to get the video stream inside the RTSP packet by yourself (good luck with that, there is no free library to do it, it took me hours and hours of work) and store the stream in a file, in the same time, your can read this file and play it, like explained here.

like image 107
Anthony Chatellier Avatar answered Sep 23 '22 20:09

Anthony Chatellier