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

发布于 2024-10-01 12:13:47 字数 302 浏览 1 评论 0原文

我需要能够播放通过 RTSP 接收的视频并同时将其保存到光盘(好吧,SD 卡)。这是直播,因此我无法先下载整个文件然后播放。我必须同时播放和录音。我可以使用 MediaRecorder 从板载摄像头录制视频,并且可以使用 MediaPlayer 或 VideoView 接收 RTSP 流,但我不知道如何将两者结合起来。

MediaRecorder 似乎是录制视频的唯一方法,但它只支持一个视频源:摄像头。它的 setVideoSource() 方法不允许其他来源。也许我需要以某种方式获取 OutputStream,然后将其写入文件?

感谢您的任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情徒 2024-10-08 12:13:47

你想做的事很难。
没有简单的方法可以做到这一点。

你必须自己获取RTSP数据包内的视频流(祝你好运,没有免费的库可以做到这一点,这花了我几个小时的工作)并将流存储在一个文件中,同时,您可以读取此文件并播放它,如此处所述。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文