Skip to content
Oct 23 / Adam

Capture Apple’s HTTP Streaming to File

When Apple introduced HTTP streaming to the world on their iOS platform, I always wondered what would involved in capturing it. After all, it’s just http data, how hard can it be? Well, I’m flying out tomorrow morning for work, and decided it’d be nice to watch the hour+ Celebrating Steve video that Apple just released on the plane ride. Only one problem: It was a streaming video, with no download link in sight.

I dove into the source, and found the <video> tag, and the source file, an HTTP Streaming .m3u8 playlist file. I downloaded the sl_mvp.m3u8 file it an opened it in TextEdit. Inside were the links to the various quality program stream playlists:

#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1308077

http://qthttp.apple.com.edgesuite.net/11ajdjnvkjnd10weoihf23ohfoihqw/2540/prog_index.m3u8

I figured the higher the bandwidth, the higher the quality, so I went with the highest. I then downloaded the prog_index.m3u8 file, which contained a sequential list of the transport stream chunks of the video. Each segment was about 10 seconds long. this file contained two important pieces of information: The base file name (fileSequenceXXX.ts), and the total number of chunks (486) for this stream. I figured this would be a perfect use for OS X’s built in curl utility and fired up the Terminal. I made a new folder for my video chunks, cd’d into it, and ran curl:

curl -O http://qthttp.apple.com.edgesuite.net/11ajdjnvkjnd10weoihf23ohfoihqw/2540/fileSequence[0-486].ts

hitting return went about downloading all 487 chunks. When all 1.6GB were done, I had to merge them together. Because these are transport streams, cat works well enough:

cat * > ~/output.ts

That command makes a file called output.ts in my home folder by merging all the small chunks in the folder together (I did use Automator to rename the files to three digit numbers just in case my shell’s file ordering was different than the Finder).

QuickTime X has no problem playing back this H264 video, AAC audio transport stream file directly, which is great: Mission accomplished. But being the perfectionist I am, I felt the need to try and maximize compatibility and get the .ts into a .mov or .mp4 container. VLC did this for me no problem using its wonderful export wizard, but for whatever reason when I played back the resultant .mov (or .mp4) in QuickTime I got black video. VLC played it fine. I’ll look into this more later, but here’s to hoping this info can help someone else!

4 Comments

leave a comment
  1. Henrik / Oct 24 2011

    Worked like a charm, thanks for sharing :)

  2. Lonnie / Oct 24 2011

    Thanks very much for the instructions, the downloads all seem to work fine and each individual video plays fine but the sound is messed up I seem to get about a second of sound then a second of nothing, then a second of sound, etc. This happens in Quicktime and VLC. If you have any idea what I am doing wrong any help will be appreciated. I haven’t tried concatenating the files yet, trying to get the sound working first.
    Thanks,
    Lonnie

  3. Adam / Oct 24 2011

    Cat them together; they’ll play fine. The pause between .ts files in vlc is a “feature” of how vlc playlists work…

  4. Lonnie / Oct 24 2011

    Thanks, I really appreciate the initial instructions & the help. After Cat’ing them it plays fine in quicktime (takes a few seconds to get started but then it’s perfect.
    Thanks again

Leave a Comment