Michaël
Michaël

Reputation: 6734

Save HLS stream on iPhone/iPad

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 !

Upvotes: 3

Views: 2826

Answers (2)

Samet DEDE
Samet DEDE

Reputation: 1621

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.

Upvotes: 1

vipw
vipw

Reputation: 7645

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

Upvotes: 1

Related Questions