简体   繁体   English

在android中如何在播放时将RTSP流保存到文件?

[英]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. 我需要能够播放通过RTSP接收的视频并同时将其保存到光盘(即SD卡)。 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从机载摄像机录制视频,我可以使用MediaPlayer或VideoView接收RTSP流,但我不知道如何将两者结合起来。

MediaRecorder seems to be the only way to record video, but it only supports one video source: the camera. MediaRecorder似乎是录制视频的唯一方式,但它只支持一个视频源:相机。 Its setVideoSource() method allows no other sources. 它的setVideoSource()方法不允许其他来源。 Perhaps I need to get an OutputStream somehow, which I can then write to a file? 也许我需要以某种方式得到一个OutputStream,然后我可以写入一个文件?

Thanks for any help. 谢谢你的帮助。

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 . 你必须自己在RTSP数据包中获取视频流(祝你好运,没有免费的库来完成它,我花了几个小时的工作)并将流存储在一个文件中,同时,你可以阅读这个文件并播放它,就像这里解释的那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM