在iPhone / iPad上保存HLS流 [英] Save HLS stream on iPhone/iPad
问题描述
我有一个iPhone / iPad应用程序,播放电视频道的HTTP直播。我想添加一个记录功能,以便像电视录像机一样在设备上保存直播。
I have an iPhone/iPad app which play a HTTP Live Stream of a tv channel. I want to add a record functionnality to save on the device the live stream like a TV recorder.
我不知道是否可能,但我认为我有记录流的两种方法。
I don't know if it's possible, but I think that I have 2 ways to record the stream.
-
保存屏幕上显示的输出流,但我不知道如何要做到这一点...
Save the output stream which is displayed at the screen, but I don't know how to do this ...
打开m3u8播放列表并下载播放列表的片段,将其保存为创建m3u8播放列表以及已下载的片段。但在这种情况下,我会下载2倍的视频,一个使用MPMoviePlayer,一个下载段。
Open m3u8 playlists and download segments of the playlist, save it an create a m3u8 playlist with the donwloaded segments. But in this case, I will download 2 times the video, one with the MPMoviePlayer, and one in downloading segments.
任何人已经做了一个samilar的事情,或者知道怎么做?
Anyone have already do a samilar thing, or know how to do this ?
提前谢谢!
推荐答案
你应该使用选项2.
让我们说你在Documents文件夹(Documents / downloads)中创建一个downloads文件夹
Lets say you create a "downloads" folder in Documents folder (Documents/downloads)
- 首先在应用程序中运行HTTPServer(即Mongoose)。
- 定义Mongoose到您的下载文件夹的根路径。
- 将视频和m3u8文件下载到下载文件夹。如果你想改变m3u8,请使用NSString方法。
播放录制的视频时,请使用以下地址
When you play recorded video, use address like below
http://localhost:8080/playlist.m3u8
MPMoviePlayer应该没有问题播放录制的视频。
And MPMoviePlayer should play recorded videos without problem.
如果你想录制不同的视频,你可以在你的下载目录中实现目录系统。
If you want to record different videos, you can implement directory system into your downloads dir.
这篇关于在iPhone / iPad上保存HLS流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!