Coachella is streaming live on YouTube this weekend. It looks like a great show, and a lot of different artists are playing. I like one of the bands especially, Infected Mushroom. I decided to try to rip their show, and I was quite successful.
Many people use screen recording software to do this, but this approach have a lot of problems. The framerate is usually very uneven, and it has to encode it on the fly which takes a lot of CPU, the audio levels gets distorted because it passes through the mixer in your computer, and so on. The result is never that good.
Whenever possible, you should capture the stream and get the data files directly. To do that for YouTube Live, start by opening the YouTube page, like the current Coachella stream. Then use your favorite browser’s network monitor and watch for the entries that end with “index.m3u8?stream_seq=X”. These are requests for “playlist files” that contain urls to “shards”. The way YouTube Live works is by breaking the stream up into “shards”, which are then fetched individually by the clients and assembled during playback, and the playlist files contain several different urls (most likely used for load balancing). The size of the shards seems to range from 1 MB to 4 MB. What you need to figure out is what shard you want to start capturing from and what shard you want to stop at.
Note: The urls will only work for a few hours, and all urls in this post have already timed out! None of the commands here will work without a new url!

The requests you need to pay attention to.
If you right click the entry and copy the url, you will get something like this:
http://www.youtube.com/api/manifest/hls_playlist/id/z7ttfmzInwk.1/itag/96/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/playlist_type/DVR/pmbypass/yes/maudio/1/cp/U0hVSlhQVV9KUUNONV9QSllJOkpaVjlSZVplT2pm/upn/CoU6Y0yLL4Y/fexp/932000,932004,906383,916911,916910,902000,901208,919512,929903,925714,931202,900821,900823,931203,906090,909419,908529,930807,919373,930803,906836,920201,929602,930101,930609,900824/sver/3/cpn/ZoiDPn4zGjWpdBen/ip/81.21.214.101/ipbits/8/expire/1365857857/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,playlist_type,pmbypass,maudio,cp/signature/6AD4B2BFC126BFA177905B1B0A7ADFC0C36F4C71.4B7BA10E778BE86E2AA757EECD07CA99FB09E288/key/dg_yt0/file/index.m3u8?start_seq=5423
The parameter in the url that determine the quality is the itag value, where 92 is 240p, 93 is 360p, 94 is 480p, 95 is 720p and 96 is 1080p. You can’t just change it though, since the signature parameter will then become invalid. So pick the quality you want in the player and then copy the playlist url. When you have the playlist url, you can use mplayer to dump the stream for that shard. Use this syntax:
mplayer -dumpstream -dumpfile "stream.dump.5423.ts" -playlist "http://www.youtube.com/api/manifest/hls_playlist/id/z7ttfmzInwk.1/itag/96/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/playlist_type/DVR/pmbypass/yes/maudio/1/cp/U0hVSlhQVV9KUUNONV9QSllJOkpaVjlSZVplT2pm/upn/CoU6Y0yLL4Y/fexp/932000,932004,906383,916911,916910,902000,901208,919512,929903,925714,931202,900821,900823,931203,906090,909419,908529,930807,919373,930803,906836,920201,929602,930101,930609,900824/sver/3/cpn/ZoiDPn4zGjWpdBen/ip/81.21.214.101/ipbits/8/expire/1365857857/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,playlist_type,pmbypass,maudio,cp/signature/6AD4B2BFC126BFA177905B1B0A7ADFC0C36F4C71.4B7BA10E778BE86E2AA757EECD07CA99FB09E288/key/dg_yt0/file/index.m3u8?start_seq=5423"
Now you will get a file called “stream.dump.5423.ts”, a 5 second long clip that you can play with VLC. Anyone who’s reading this can figure out that all you have to do is create a simple script that dumps all the shards from shard X to Y, then just combine the files and you’re done. Here’s a bat script for Windows users:
set i=%1
set max=%2
if "%2" == "" (
set max=%1
)
:loop
if %i% gtr %max% goto stop
if not exist "stream.dump.%i%.ts" (
mplayer -dumpstream -dumpfile "stream.dump.%i%.ts" -playlist "http://www.youtube.com/api/manifest/hls_playlist/id/z7ttfmzInwk.1/itag/96/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/playlist_type/DVR/pmbypass/yes/maudio/1/cp/U0hVSlhQVV9KUUNONV9QSllJOkpaVjlSZVplT2pm/upn/CoU6Y0yLL4Y/fexp/932000,932004,906383,916911,916910,902000,901208,919512,929903,925714,931202,900821,900823,931203,906090,909419,908529,930807,919373,930803,906836,920201,929602,930101,930609,900824/sver/3/cpn/ZoiDPn4zGjWpdBen/ip/81.21.214.101/ipbits/8/expire/1365857857/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,playlist_type,pmbypass,maudio,cp/signature/6AD4B2BFC126BFA177905B1B0A7ADFC0C36F4C71.4B7BA10E778BE86E2AA757EECD07CA99FB09E288/key/dg_yt0/file/index.m3u8?start_seq=%i%"
)
set /a i+=1
goto loop
:stop
Save that as dump.bat and run it like “dump 5392 5989″ to download the whole Infected Mushroom set. Yes, you can do that even though that part of the Coachella event ended hours ago. My guess is that they allocate servers for this whole event and that the requests will work until the event ends and the servers are used for other purposes. This allows you to download the full event, from the very beginning, even though you start late.
You’ll get 598 .ts files that you have to join together. I suggest that you use TSSplitter for that. If you simply want to upload it to YouTube straight away, I suggest that you use mkvmerge to just mux the existing streams to an mkv container. This way you won’t transcode the streams and the quality will be the same, and it’s a lot faster than re-encoding. Even if you’re going to trim it (e.g. because you want it to start in the middle of a shard), I suggest that you use YouTube’s Video Editor, since that will skip an extra encoding step (YouTube uses the original file that you uploaded when you use the video editor).
I hope everyone enjoyed this little tutorial. If you did, please consider donating. Thank you!