Save HLS stream on iPhone/iPad

雨燕双飞 提交于 2019-12-05 04:35:48

问题


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.

  1. Save the output stream which is displayed at the screen, but I don't know how to do this ...

  2. 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.

Anyone have already do a samilar thing, or know how to do this ?

Thank's in advance !


回答1:


You should use option 2.

Lets say you create a "downloads" folder in Documents folder (Documents/downloads)

  • Run a HTTPServer in your application first (ie. Mongoose).
  • Define Mongoose's root path to your downloads folder.
  • Download videos and m3u8 file to downloads folder. If you want to change m3u8, use NSString methods.

When you play recorded video, use address like below

http://localhost:8080/playlist.m3u8

And MPMoviePlayer should play recorded videos without problem.

If you want to record different videos, you can implement directory system into your downloads dir.




回答2:


You can use option 2, and make your downloading code as an http proxy.

Your proxy would download the m3u8 playlist, and re-write the urls to address localhost. Then the proxy would download from the server upon request by the MPMoviePlayer. It would just write the content to two locations (storage and the movie player).



来源:https://stackoverflow.com/questions/11171206/save-hls-stream-on-iphone-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!