2

I am trying to save any m3u8 stream playlist as video to disk as 1 complete video file, similar to vlc. I can create an AVAsset and play it in an AVPlayer fine, however the m3u8 links i have tried all return false from asset.isExportable so using AVAssetExportSession does not work. I thought it might be possible opening the link as an InputStream and then writing it to an OutputStream but was lost on how to do this. Is this a viable option or will it only return the actual m3u8 file instead of the .ts video links? Any guidance in the right direction would be appreciated. I am fine doing the research on how to use the different classes, i'm just kinda lost on where to go from here.

Thank you, Phil

Phil
  • 71
  • 1
  • 6

1 Answers1

2

Building a single video from all the streams in a m3u8 playlist may not actually give you what you want, depending on the m3u8 file.

This is because m3u8 playlists can contain multiple bit rate versions for a single video - so if you added them all together you would get the same video with different quality levels (bit rates) one after another.

Its also worth noting that some videos streams will be encrypted, in fact most high value streams such as Netflix etc will be, so downloading them will not allow you to play them back unless you do it as part of the providers own 'download and go' service.

Finally, some services may make it hard for you to access the streams by requiring some form of authentication in parallel with the video stream URL.

Assuming all the above is fine or does not apply in your case, then the video files themselves can be downloaded as files using a HTTP downloading function. Good examples of these exist such as: https://stackoverflow.com/a/35510812/334402

Community
  • 1
  • 1
Mick
  • 24,231
  • 1
  • 54
  • 120
  • Thanks for the response Mick. I don't believe using the httpdownloading function on an m3u8 file will return the .ts video files i am wanting to save. I think it will only return the m3u8 file. I can parse the m3u8 file to obtain the actual link's im looking for but that seems like more work than is necessary since the video plays fine as an avasset. After doing some more research, I believe i can use an AVAssetResourceLoader to handle the data coming into my AVAsset so I'm thinking this will work. I'll update my post if this option works. – Phil Apr 19 '17 at 18:29
  • Yes - I mean use the download function on the URLs to the video stream themselves, not the m3u8 file. – Mick Apr 19 '17 at 19:57