Save HLS Stream to iPhone / iPad

I have an application for iPhone / iPad that plays streams of the HTTP channel of the TV channel. I want to add a recording function in order to save the stream in real time on the device, like a TV.

I don't know if this is possible, but I think I have 2 ways to record the stream.

  • Save the output stream that is displayed on the screen, but I don’t know how to do it ...

  • Open m3u8 playlists and load playlist segments, save it, create m3u8 playlist with loaded segments. But in this case, I will upload 2 times the video, one with MPMoviePlayer and one in loading segments.

Does anyone already do the same thing or know how to do it?

Thanks in advance!

+2
source share
2 answers

You must use option 2.

Suppose you created a “downloads” folder in the “Documents / downloads” folder

  • First, run HTTPServer in your application (i.e. Mongoose).
  • Define the Mongoose root path to the download folder.
  • Download the video and m3u8 file to the download folder. If you want to change m3u8, use the NSString methods.

When playing back recorded video, use the address below

http://localhost:8080/playlist.m3u8 

And MPMoviePlayer should play the recorded videos without any problems.

If you want to record different videos, you can embed a directory system in the download directory.

+1
source

You can use option 2 and make your http proxy download code.

Your proxy will download the m3u8 playlist and re-write the urls for the localhost address. Then the proxy server will boot from the server at the request of MPMoviePlayer. He simply recorded content in two places (storage and movie player).

+1
source

Source: https://habr.com/ru/post/946648/


All Articles