[英]Capture a RTSP Stream on an android device
I want to capture a RTSP video stream from an ip camera with my Nexus S. To watch the stream with a VideoView and the mediaplayer is no problem. 我想用我的Nexus S从ip摄像头捕获RTSP视频流。使用VideoView和媒体播放器观看流是没有问题的。
I tried to save it like this: 我试着像这样保存它:
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 a MalformedURLException, because android doesn't support rtsp:// urls. 我得到一个MalformedURLException,因为android不支持rtsp:// urls。
Has somebody an idea how to solve this problem? 有人知道如何解决这个问题吗?
You can use ffmpeg libraries through JNI/NDK to capture an rtsp stream. 您可以通过JNI / NDK使用ffmpeg库来捕获rtsp流。 It's not very easy, but it does work. 这不是很容易,但确实有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.