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: Graham Cox <email@hidden>
- Date: Tue, 09 Dec 2014 10:37:05 +1100
OK, thanks. I was hoping that I didn't need to delve into the internals of the m3u8 format itself, since AVPlayer/AVPlayerView handles it just fine - I just make a NSURL from the m3u8 url and away it goes.
By the way, it isn't just audio, it's video and audio and possibly other things - there are three tracks in the asset for the stream I tested with but I forget what the third is now (first two were video and audio).
It seems as if the architecture of AV Foundation allows what I want, but the actual implementation doesn't, *unless I've missed something*. I'm wondering if this gap in the implementation is deliberate for some reason, is there but requires some other combinaiton of parameters from the nes I've tried, on Apple's 'to do' list or is fundamentally not possible.
--Graham
> On 9 Dec 2014, at 4:50 am, email@hidden wrote:
>
>
>
>
> Sent from my iPhone
>> On 2014/12/09, at 1:38, Jens Alfke <email@hidden> wrote:
>>
>> 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.
> It is not limited to MP3
> Http Live Streaming uses this playlist format.
> Literally just a list of URLs really. Where each one is a short clip of media content.
> The content on the other end is usually small files as parts of the whole.
> The u on the end means UTF8.
> The video format could vary.
_______________________________________________
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