From time to time, I love to download a video stream to watch it later. For example the relive feature from bitsundso.de provides a stream to watch live or later, but no simple video download. Same for Apple with the keynotes in stream only format.
First you need the URL of the stream. e.g. for the last Apple website for their recent keynote:
You find it for bitsundso after login on the status page and than copying the link for video for QuickTime player. How you get the stream URL doesn't matter, but as soon as you have the URL to the m3u8 file, you can download all segments and merge them to one file.
But first you download that m3u8 file and you see inside the links for the various resolutions. You also find redirects for other languages there. What you need is the final m3u8 file URL to download.
e.g. we pick full resolution for the Apple keynote:
Now you need a copy of ffmpeg command line utility, which I just downloaded as disk image and copied to home folder. Now you can go into Terminal application and use a command like the following with your URL and desired file name:
./ffmpeg -i 'https://p-events-delivery.akamaized.net/18oihuabsdfvoiuhbsdfv03/vod327/8500/8500_vod.m3u8' -c copy -bsf:a aac_adtstoasc keynote.mp4
Once finished, you have a nice mp4 file, which is suitable for watching offline. And now you know why I need this from time to time. e.g. for watching something later in the train without reliable wifi or payable cellular.
PS: I tried the same myself with a self written app, but merging videos with AVMutableComposition and AVExportSession fails when you try to merge a few hundred little videos.
PPS: Apple's keynote podcast does have the video files, so no need to use the stream.