Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   Video stream recording (http://stream-recorder.com/forum/forumdisplay.php?f=4)
-   -  

Download encrypted YouTube livestreams

(http://stream-recorder.com/forum/showthread.php?t=18100)

sebastian 03-26-2014 01:29 AM

Download encrypted YouTube livestreams


 
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! :-)

peterpan 03-26-2014 01:47 AM

Re: Download encrypted YouTube livestreams


 
Give specific examples. If you have the encrypted stream in question and you're trying to download it, post it.

blimey 03-26-2014 02:49 AM

Re: Download encrypted YouTube livestreams


 
UVDConvert.php will probably work on that sort of encryption, either as-is, or with minor modifications. See usage.

sebastian 03-26-2014 04:33 AM

Re: Download encrypted YouTube livestreams


 
Thanks blimey. I will see if that will work! :-)
But what's the advantage on Flash Stream Hunter over ffmpeg here?

Quote:

Originally Posted by peterpan (Post 66632)
Give specific examples. If you have the encrypted stream in question and you're trying to download it, post it.

It's a livestream, so the example doesn't exist yet. ;-) It's the livestream of Ultra Music Festival in Miami. They are streaming on Friday to Sunday via http://www.youtube.com/umftv

sebastian 03-28-2014 01:48 PM

Re: Download encrypted YouTube livestreams


 
Here it is. But I have absolutely no idea, how to record it.

https://www.youtube.com/watch?v=MF0UNmHzu5Y

Anyone with a hint?

blimey 03-28-2014 02:40 PM

Re: Download encrypted YouTube livestreams


 
It has m3u8, link is encoded with your IP. Use firefox...

lesor 03-28-2014 03:28 PM

Re: Download encrypted YouTube livestreams


 
Quote:

Originally Posted by blimey (Post 66684)
It has m3u8, link is encoded with your IP. Use firefox...





magichandz 03-28-2014 08:31 PM

Re: Download encrypted YouTube livestreams


 
lesor has it right. just get the m3u8 out of the page source the only problem i've run into is after about an hour or so the stream will disconnect and i have to start over. the same m3u8 will work but i get the same disconnect. i think i'll have to write a script that starts downloading the stream over again if it stops.

or i'll just hope that he download doesn't get interrupted.

Code:

ffmpeg -i "http://www.youtube.com/api/manifest/hls_playlist/id/MF0UNmHzu5Y.1/itag/95/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/dg_shard/MF0UNmHzu5Y.1_95/hls_chunk_host/www.youtube.com/maudio/1/pmbypass/yes/playlist_type/LIVE/gcr/us/fexp/906373,931946,938647,914089,937417,913434,936910,936913,934022/sver/3/upn/ijUA-7cc8gI/ip/{my-ip}/ipbits/0/expire/1396073058/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,dg_shard,hls_chunk_host,maudio,pmbypass,playlist_type,gcr/signature/14C8FBE4DEB9D29DB85FC0AE6A552445526A13B8.8F86EAC0860F4D4591799128175A839A572793DB/key/dg_yt0/file/index.m3u8" -c copy ultra02.ts
ffmpeg version 2.2 Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar 25 2014 08:36:03 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-fontconfig --enable-libfreetype --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
  libavutil      52. 66.100 / 52. 66.100
  libavcodec    55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter    4.  2.100 /  4.  2.100
  libavresample  1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample  0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[hls,applehttp @ 0x7fd0d5000600] Estimating duration from bitrate, this may be inaccurate
Input #0, hls,applehttp, from 'http://www.youtube.com/api/manifest/hls_playlist/id/MF0UNmHzu5Y.1/itag/95/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/dg_shard/MF0UNmHzu5Y.1_95/hls_chunk_host/www.youtube.com/maudio/1/pmbypass/yes/playlist_type/LIVE/gcr/us/fexp/906373,931946,938647,914089,937417,913434,936910,936913,934022/sver/3/upn/ijUA-7cc8gI/ip/{my-ip}/ipbits/0/expire/1396073058/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,dg_shard,hls_chunk_host,maudio,pmbypass,playlist_type,gcr/signature/14C8FBE4DEB9D29DB85FC0AE6A552445526A13B8.8F86EAC0860F4D4591799128175A839A572793DB/key/dg_yt0/file/index.m3u8':
  Duration: 00:00:00.12, start: 1815.000000, bitrate: 233 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 256 kb/s
Output #0, mpegts, to 'ultra02.ts':
  Metadata:
    encoder        : Lavf55.33.100
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 90k tbn, 25 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[tcp @ 0x7fd0d3e05760] Failed to resolve hostname www.youtube.com: nodename nor servname provided, or not known
[tcp @ 0x7fd0d3c00f20] Failed to resolve hostname www.youtube.com: nodename nor servname provided, or not known

frame=49250 fps= 25 q=-1.0 Lsize=  644339kB time=00:32:50.01 bitrate=2679.4kbits/s   
video:528667kB audio:61563kB subtitle:0 data:0 global headers:0kB muxing overhead 9.167596%

$ ffmpeg -i "http://www.youtube.com/api/manifest/hls_playlist/id/MF0UNmHzu5Y.1/itag/95/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/dg_shard/MF0UNmHzu5Y.1_95/hls_chunk_host/www.youtube.com/maudio/1/pmbypass/yes/playlist_type/LIVE/gcr/us/fexp/906373,931946,938647,914089,937417,913434,936910,936913,934022/sver/3/upn/ijUA-7cc8gI/ip/{my-ip}/ipbits/0/expire/1396073058/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,dg_shard,hls_chunk_host,maudio,pmbypass,playlist_type,gcr/signature/14C8FBE4DEB9D29DB85FC0AE6A552445526A13B8.8F86EAC0860F4D4591799128175A839A572793DB/key/dg_yt0/file/index.m3u8" -c copy ultra03.ts
ffmpeg version 2.2 Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar 25 2014 08:36:03 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-gnutls --enable-fontconfig --enable-libfreetype --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
  libavutil      52. 66.100 / 52. 66.100
  libavcodec    55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter    4.  2.100 /  4.  2.100
  libavresample  1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample  0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[hls,applehttp @ 0x7f900381b400] Estimating duration from bitrate, this may be inaccurate
Input #0, hls,applehttp, from 'http://www.youtube.com/api/manifest/hls_playlist/id/MF0UNmHzu5Y.1/itag/95/source/yt_live_broadcast/ratebypass/yes/live/1/cmbypass/yes/newshard/yes/gir/yes/dg_shard/MF0UNmHzu5Y.1_95/hls_chunk_host/www.youtube.com/maudio/1/pmbypass/yes/playlist_type/LIVE/gcr/us/fexp/906373,931946,938647,914089,937417,913434,936910,936913,934022/sver/3/upn/ijUA-7cc8gI/ip/{my-ip}/ipbits/0/expire/1396073058/sparams/ip,ipbits,expire,id,itag,source,ratebypass,live,cmbypass,newshard,gir,dg_shard,hls_chunk_host,maudio,pmbypass,playlist_type,gcr/signature/14C8FBE4DEB9D29DB85FC0AE6A552445526A13B8.8F86EAC0860F4D4591799128175A839A572793DB/key/dg_yt0/file/index.m3u8':
  Duration: 00:00:00.13, start: 4120.000000, bitrate: 225 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 251 kb/s
Output #0, mpegts, to 'ultra03.ts':
  Metadata:
    encoder        : Lavf55.33.100
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 90k tbn, 25 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, 251 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=20179 fps= 25 q=-1.0 size=  264446kB time=00:13:27.16 bitrate=2683.9kbits/s


sebastian 03-29-2014 02:58 AM

Re: Download encrypted YouTube livestreams


 
Thanks guys. I really wonder why URLSnooper2 didn't find the mu3 link, while I could find it myself in the source code... ;-)

lesor 03-29-2014 04:48 AM

Re: Download encrypted YouTube livestreams


 
Quote:

Originally Posted by sebastian (Post 66697)
I really wonder why URLSnooper2 didn't find the mu3



All times are GMT -6. The time now is 03:38 AM.