Hi guys,
this weekend I'd like to download a livestream from YouTube which won't get archived. Now I would like to learn, what I can do, if the stream would be encrypted. With my google search, I found the following info by the user "recover" on
http://stefansundin.com/blog/452
Quote:
@sawl I’ve figured it out. It’s an encrypted “stream”, but thankfully, it’s not that difficult to decrypt. It’s obviously not live, that’s why there are no index.m3u8 requests. It only needs one, in the beginning, so it’s easy to miss.
A trick you can do to get a new index.m3u8 request is to change the quality. Download that index.m3u8 and open it with a text editor. One of the first lines will have: “#EXT-X-KEY:METHOD=AES-128″, then an URL which contain the key, and then an IV value which contains the initialization vector for the key. Download the key, it’s in binary so I recommend that you use wget, or your browser may insert HTML and crap into the file when you save it. Save the key as hlskey.txt.
Now that you have the keys, you must get the encrypted ts files. Instead of using mplayer in the post above, you should simply do a few regular expressions on the playlist entries so you get a nice wget script (use -O to specify the output filename). Then when you have everything, it’s time to decrypt the files. I use Linux commands below, but you can probably find openssl for Windows as well (or run in a VM).
Create a bash script:
Code:
hexKey=$(cat hlskey.txt | hexdump -e '16/1 "%02x"')
hexIV=990C276E28BC6B83E21A6D6F75483732
openssl aes-128-cbc -d -p -nosalt -iv ${hexIV} -K ${hexKey} -in encrypted.ts -out decrypted.ts
As you can see you must remove 0x from the IV. And obviously make a loop or something to go through all your ts files.
Then you can continue as normally and merge the ts files. Good luck!
|
So how could that work on a windows machine? For the encrypted stream itself, would it be a good method to get it via
Code:
ffmpeg -i “http://streamlocation.m3u8″ -c copy c:\FileName.ts
and the find a way to decrypt it? Or would ffmpeg mess the encrypted stream up?
It would be great if you could help me! :-)