RTSP Stream Capture on Android Device

I want to capture the RTSP video stream from an ip camera using Nexus S. To watch the stream using VideoView and a media player is not a problem.

I tried to save it as follows:

URL url = new URL("rtsp://192.168.4.222:554/ipcam.sdp"); URLConnection ucon = url.openConnection(); ucon.connect(); InputStream is = ucon.getInputStream(); fos = new FileOutputStream(VideoFile); bis = new BufferedInputStream(is); isRecording = true; baf = new ByteArrayBuffer(50); int current = 0; FileOutputStream fos = new FileOutputStream(VideoFile); while (((current = bis.read()) != -1) & isRecording) { baf.append((byte) current); fos.write(baf.toByteArray()); baf.clear(); } fos.close(); 

I get MalformedURLException because android does not support rtsp: // urls.

Does anyone know how to solve this problem?

+4
source share
2 answers

According to http://developer.android.com/reference/java/net/URLConnection.html RTSP protocol is not yet supported

+1
source

You can use the ffmpeg libraries through the JNI / NDK to capture the rtsp stream. It is not very simple, but it works.

0
source

Source: https://habr.com/ru/post/1346225/


All Articles