Re: Using AV Foundation to record m3u8 stream to disk
Re: Using AV Foundation to record m3u8 stream to disk
- Subject: Re: Using AV Foundation to record m3u8 stream to disk
- From: Jens Alfke <email@hidden>
- Date: Mon, 08 Dec 2014 08:38:42 -0800
> On Dec 7, 2014, at 11:00 PM, Graham Cox <email@hidden> wrote:
>
> The title says it all really: is it possble to use AV Foundation to record a m3u8 stream to a movie file (optionally transcoded).
m3u8 isn't a stream, it's simply a small playlist file that contains one or more HTTP URLs, which resolve to audio files, usually MP3. In the case of streaming, the HTTP audio resource uses the Shoutcast format, which is basically just an audio stream that looks like an infinitely long MP3 file.
So all you need to do is read the URL from the .m3u8 file (which is pretty trivial; IIRC it's just a text file containing a URL) and use something like NSURLConnection to read data from it and write it to a file with a ".mp3" extension. Since it's a stream you'll never hit EOF so you'll want to stop the connection after a while.
If you need to write the audio into some other kind of movie file you should be able to feed the data received from the URL into AVFoundation. You'll just need to inform it that the data format is MP3.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden