Audio/video stream recording forums

Attention Visitor:
You may have to register or log in before you can post:
  • Click the register link to sign up.
  • Registered members please fill in the form below and click the "Log in" button.
To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Audio/video stream recording forums > Streaming media recording forum > Video stream recording
Register FAQ Members List Calendar Mark Forums Read

Reply Post New Thread
 
Thread Tools Display Modes
  #51  
Old 06-12-2014, 05:36 PM
enrud enrud is offline
Member
 
Join Date: Jun 2014
Posts: 33
enrud is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by ItsAngel View Post
Thanks a lot! I managed to download a video which appears to be HD due to file size, but the UVD app won't play the video, only the audio. I went to decrypt the video file like I would usually and when I got my .ts file I can't convert it or watch it anywhere, any idea how I could get the videos to play? Thanks again!
Did you decrypt it? Can you post the m3u8 files?
Reply With Quote
  #52  
Old 06-12-2014, 07:13 PM
ItsAngel ItsAngel is offline
Senior Member
 
Join Date: Jul 2012
Posts: 102
ItsAngel is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by enrud View Post
Did you decrypt it? Can you post the m3u8 files?
I'm sure I did decryot it, and here are all the files. I didn't include the video/audio because of file size. But here are the m3u8s https://www.dropbox.com/sh/ynohnax12...sREoOHZF2jvxsa
Reply With Quote
  #53  
Old 06-12-2014, 08:45 PM
enrud enrud is offline
Member
 
Join Date: Jun 2014
Posts: 33
enrud is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Code:
  $key = file_get_contents($argv[3]); 
  if ($key === false) 
      die("Failed to open key file."); 
  $iv = $key; 
  LogDebug("Key: " . hexlify($key)); 
  LogDebug("IV : " . hexlify($iv));
The IV isn't the same as the key.

According the HLS spec, if the IV isn't specified in the #EXT-X-KEY, which it isn't, then the IV is the sequence number. The #EXT-X-MEDIA-SEQUENCE tag specifies the starting sequence number for the playlist, in this case, 0. Each url in the playlist is a sequence. So the first url in this case is sequence #0, the second is sequence #1, etc.

The IV for each url is then encoded as a 128 bit big endian representation of the sequence number for that url.

So the first URL (sequence #0) the IV is \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x00

For the second URL (sequence #1) the IV is \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x01

and so forth.

I believe that's the reason why you can't decrypt.
Reply With Quote
  #54  
Old 06-12-2014, 08:57 PM
enrud enrud is offline
Member
 
Join Date: Jun 2014
Posts: 33
enrud is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


To help you further along, I found that if I muxed the audio and video as whole files I occasionally had audio sync problems. To resolve that, I would mix them as chunks. So my decryption process was something like (pseudocode):

Code:
create output.ts file
for each segment:
  read segment from video
  read segment from audio
  decrypt video 
  write video segment to temporary.ts file
  write audio segment to temporary.aac file
  ffmpeg -i temporary.ts -i temporary.aac -acodec copy -vcodec copy muxed_temporary.ts
  append muxed_temporary.ts to output.ts

// then convert to mp4
ffmpeg -i output.ts -acodec copy -vcodec copy -bsf:a aac_adtstoasc output.mp4
some players won't play the audio without the "-bsf:a aac_adtstoasc" flag (windows media player, iirc).

You are getting close...
Reply With Quote
  #55  
Old 06-12-2014, 09:08 PM
ItsAngel ItsAngel is offline
Senior Member
 
Join Date: Jul 2012
Posts: 102
ItsAngel is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by enrud View Post
Code:
  $key = file_get_contents($argv[3]); 
  if ($key === false) 
      die("Failed to open key file."); 
  $iv = $key; 
  LogDebug("Key: " . hexlify($key)); 
  LogDebug("IV : " . hexlify($iv));
The IV isn't the same as the key.

According the HLS spec, if the IV isn't specified in the #EXT-X-KEY, which it isn't, then the IV is the sequence number. The #EXT-X-MEDIA-SEQUENCE tag specifies the starting sequence number for the playlist, in this case, 0. Each url in the playlist is a sequence. So the first url in this case is sequence #0, the second is sequence #1, etc.

The IV for each url is then encoded as a 128 bit big endian representation of the sequence number for that url.

So the first URL (sequence #0) the IV is \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x00

For the second URL (sequence #1) the IV is \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x01

and so forth.

I believe that's the reason why you can't decrypt.
Thanks for helping me out with this! we are definitely getting there! i do have a question though, where are you finding these urls and different .ts chunks? when i download a video it comes in only one .ts file.
Reply With Quote
  #56  
Old 06-12-2014, 09:17 PM
WHOOKIDSON WHOOKIDSON is offline
Senior Member
 
Join Date: Dec 2010
Posts: 142
WHOOKIDSON is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by ItsAngel View Post
Thanks for helping me out with this! we are definitely getting there! i do have a question though, where are you finding these urls and different .ts chunks? when i download a video it comes in only one .ts file.
I know you don't wanna post the entire file due to the file size but is it possible for you to post a sample of it? I'll try this out
Reply With Quote
  #57  
Old 06-12-2014, 09:24 PM
ItsAngel ItsAngel is offline
Senior Member
 
Join Date: Jul 2012
Posts: 102
ItsAngel is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by WHOOKIDSON View Post
I know you don't wanna post the entire file due to the file size but is it possible for you to post a sample of it? I'll try this out
Yea I'll post the entire thing. The file is untouchable basically until after its been decrypted so I wouldn't be able to split it. I have pretty bad upload speed. So give me a few. Lol
Reply With Quote
  #58  
Old 06-12-2014, 09:25 PM
enrud enrud is offline
Member
 
Join Date: Jun 2014
Posts: 33
enrud is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Each line in the video (and audio) m3u8 that does not begin with a # character is a url for a segment of audio or video (a sequence). If you download the whole thing as a single download, you need to extract out the byte ranges as specified in the M3U8. There is junk before the actual video (well not junk, but that's a different discussion...) and audio begins in the file. You'll notice that the first byterange does not begin at zero. Those byte ranges aren't just where decryption begins and ends, it also is the locations where the video and audio are stored in the whole file. If you leave the other stuff (pretty much all at the beginning of the file, iirc) on then nothing will play the video.

What you are doing is well enough correct. Just don't write the decrypted stuff back to the original file. Each byte range is what I'm referring to as a chunk. In my code, I simply read each byterange (whether directly from the download or from and already downloaded file doesn't really matter) decrypt the video, mux the audio and video and then append all of those muxed segments together. Once that's all done, I do a final conversion to convert from the ts container to mp4.

Clear as mud?
Reply With Quote
  #59  
Old 06-12-2014, 10:02 PM
ItsAngel ItsAngel is offline
Senior Member
 
Join Date: Jul 2012
Posts: 102
ItsAngel is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by enrud View Post
Each line in the video (and audio) m3u8 that does not begin with a # character is a url for a segment of audio or video (a sequence). If you download the whole thing as a single download, you need to extract out the byte ranges as specified in the M3U8. There is junk before the actual video (well not junk, but that's a different discussion...) and audio begins in the file. You'll notice that the first byterange does not begin at zero. Those byte ranges aren't just where decryption begins and ends, it also is the locations where the video and audio are stored in the whole file. If you leave the other stuff (pretty much all at the beginning of the file, iirc) on then nothing will play the video.

What you are doing is well enough correct. Just don't write the decrypted stuff back to the original file. Each byte range is what I'm referring to as a chunk. In my code, I simply read each byterange (whether directly from the download or from and already downloaded file doesn't really matter) decrypt the video, mux the audio and video and then append all of those muxed segments together. Once that's all done, I do a final conversion to convert from the ts container to mp4.

Clear as mud?
okay, so in order to get this HD file decrypted and playable, i must remove the "junk" which is the first line in the M3u8, which in this case is "EXT-X-BYTERANGE:6772528@7520
-_2" And THEN go ahead and decrypt the file? Because from what i understood the first line of byterange is what is causing the video to not decrypt. By the way, by any chance did you successfully get an HD video to decrypt?
Reply With Quote
  #60  
Old 06-12-2014, 10:19 PM
ItsAngel ItsAngel is offline
Senior Member
 
Join Date: Jul 2012
Posts: 102
ItsAngel is on a distinguished road
Default

Re: I downloaded Netflix videos in HD, I can play off line,need a little help W/.key


Quote:
Originally Posted by WHOOKIDSON View Post
I know you don't wanna post the entire file due to the file size but is it possible for you to post a sample of it? I'll try this out
Here are all the files that are downloaded from netflix when downloading an HD video. Video/Audio files included https://www.dropbox.com/sh/ynohnax12...sREoOHZF2jvxsa
Reply With Quote
Reply Post New Thread
Tags: , , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 07:58 AM.


Powered by All-streaming-media.com; 2006-2011
vB forum hacked with Zoints add-ons