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 key protected m3u8

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

bloodhand 01-25-2017 03:12 AM

Download key protected m3u8


 
Hello!

This is the original link for the video: http://protvplus.ro/produs/apropo-tv...decembrie-2016.

I tried the following ffmpeg batch with no success:
Code:

ffmpeg -i http://cdn.drm.protv.ro/protvplus.ro/2017/01/12/43c7a0a664d7d0fa805d26a047feda05.ism/43c7a0a664d7d0fa805d26a047feda05.m3u8 -c copy -absf aac_adtstoasc video.mp4
The error I get is:
Quote:

HTTP ERROR 403 Forbidden
Unable to open key file http://drmapi.protv.ro/keys/get/protvplus.ro/61307737
I guess I have to download the key file and put it into the folder along with ffmpeg.exe, but I have no idea how to do this...

Thanks in advance.

bloodhand 01-25-2017 07:15 PM

Re: Download key protected m3u8


 
Nothing, anyone? I tried parsing cookies with various methods, none of them worked... If someone could only guide me what I should start with... maybe I could accomplish it myself after that.

Irritant4 01-25-2017 10:32 PM

Re: Download key protected m3u8


 
I tried everything I know about but nothing worked


Code:

"E:\video\livestreamer-v1.12.2\livestreamer.exe" "hlsvariant://http://cdn.drm.protv.ro/protvplus.ro/2017/
01/12/43c7a0a664d7d0fa805d26a047feda05.ism/43c7a0a664d7d0fa805d26a047feda05.m3u8" best -o "c:\temp\TEST_1.ts"
[cli][info] Found matching plugin stream for URL hlsvariant://http://cdn.drm.protv.ro/protvplus.ro/2017/01/12/43c7a0a664
d7d0fa805d26a047feda05.ism/43c7a0a664d7d0fa805d26a047feda05.m3u8
[cli][info] Available streams: 136k (worst), 480p (best)
[cli][info] Opening stream: 480p (hls)
[stream.hls][error] Failed to create decryptor: Unable to open URL: http://drmapi.protv.ro/keys/get/protvplus.ro/6130773
7 (403 Client Error: Forbidden)
[cli][error] No data returned from stream


bloodhand 01-26-2017 02:11 PM

Re: Download key protected m3u8


 
Someone from videohelp forum gave me the solution I already knew about: modify m3u8 to load a local key file instead of url, update every .ts part with full link and place the key file, m3u8 file and ffmpeg in the same folder, then issue -c copy command for that m3u8. But I don't know how he managed to get the key file, as entering key url in browser gives nothing.

bloodhand 02-09-2017 06:32 PM

Re: Download key protected m3u8


 
I made the guide as requested in PM, hoping it would help others too:

How to:
1) Install Firefox and AdBlock Plus plugin. Then, open the page with the video: http://protvplus.ro/produs/apropo-tv...decembrie-2016 and click ABP icon in upper-right corner and choose Open blockable items.
2) A menu will appear on the bottom and search there for "m3u8". You are interested in this link http://cdn.drm.protv.ro/protvplus.ro...o=1994000.m3u8. Right click on it and choose open in new tab. A download prompt will appear with the m3u8, save it, rename it to "1994000.m3u8" and start editing it with notepad (make sure to have format -> word wrap activated).
3) Click edit -> replace and replace "43c7a0a664d7d0fa805d26a047feda05" with "http://cdn.drm.protv.ro/protvplus.ro/2017/01/12/43c7a0a664d7d0fa805d26a047feda05.ism/43c7a0a664d7d0fa805d26a047feda05" and make sure to replace all.
4) Then, look for "URI="http://drmapi.protv.ro/keys/get/protvplus.ro/61307737"" and replace "http://drmapi.protv.ro/keys/get/protvplus.ro/61307737" with "61307737.key". After this, save the modified m3u8 file.
5) Now, to have the correct key, you need to install Fiddler 2 Portable from here: https://downloads.sourceforge.net/pr...e_mirror=netix. Install it and run it.
6) Now, go to Mozilla and refresh the page with the video: http://protvplus.ro/produs/apropo-tv...decembrie-2016. Keep it running until the video starts playing, then close the tab.
7) Go to Fiddler and look in the list for the key url: "http://drmapi.protv.ro/keys/get/protvplus.ro/61307737". Right click on it and choose decode selected session. Then, right click again and choose inspect in new window. Select Response from top, then go to HexView tab, and select all blue bytes (from F9 to 10), right-click on the selction and choose save selected bytes and save as "61307737.key".
8) Now make a folder an place "61307737.key" and "1994000.m3u8", but also a copy of ffmpeg.exe. Then, create a new batch file with this command without the quote marks: "ffmpeg -protocol_whitelist "file,http,https,tcp,tls,crypto" -i "1994000.m3u8" -c copy 1994000.mp4" and run it and you should see the video downloading successfully.

P.S. When I said select all blue bytes I meant to select the bytes written in blue (dark-blue) font at the end. Select them directly in the hex (don't bother to select the text from the right part) as it's easier.

Also, be careful that the video we talk about is broken (missing segments somewhere in the middle of the video), so it will eventually stop downloading and the video will be unplayable. You have to look and note the last present segment and reedit the m3u8 to stop downloading at that segment. Then, you have to find the first working segment after the missing ones by trial and error, make a new m3u8 and download the second part separately. After that, I had to merge them with ffmpeg concatenate option, because they didn't fix the stream yet and I wanted to keep the working part of the video.

bloodhand 03-07-2017 10:05 AM

Re: Download key protected m3u8


 
As requested, I uploaded a picture which better explains the "select bytes from F9 to 10" part when saving the key file:

troller12 03-08-2017 01:32 PM

Re: Download key protected m3u8


 
Hi,

nice infos and step by step tut bloodhand,thank you for this.So I tried it to check whether it works but ffmpeg makes trouble and gives me a error message about "error when loading first segment ...invalid data found...".So it does stop on first ts segment.Also dosent work if I add header datas.Also get same error infos if I just use the playlist http link.Something is going wrong.

About the keyfile.Did you save the content of this as ASCII sting or in hex bytes?In browser console you can find the ASCII key.In my case...
Code:

??Ä×±?ZEb¦n÷\ ]

F93FC4D7B1CA5A4562A66EF75C205D10

Is there no option paramters for ffmpeg / livestreamer to to use keyfile from disk instead to read it from the playlist?Then you wouldnt need to download & edit the playlist anymore.

greetz

kumop4 03-09-2017 03:12 AM

Quote:

Originally Posted by bloodhand (Post 89515)
Hello! This is the original link for the video: http://protvplus.ro/produs/apropo-tv...decembrie-2016. I tried the following ffmpeg batch with no success:
Code:

ffmpeg -i http://cdn.drm.protv.ro/protvplus.ro/2017/01/12/43c7a0a664d7d0fa805d26a047feda05.ism/43c7a0a664d7d0fa805d26a047feda05.m3u8 -c copy -absf aac_adtstoasc video.mp4
The error I get is: I guess I have to download the key file and put it into the folder along with ffmpeg.exe, but I have no idea how to do this... Thanks in advance.

C??m ??n v?¬ b?*i viá??t hay v?* bổ ?*ch

troller12 03-09-2017 12:32 PM

Re: Download key protected m3u8


 
Hi,

ok I tried it again today and found the problem I had before.So Firefox did output a wrong ASCII string sign.Now it works using the right ASCII string. :)

greetz

bloodhand 03-13-2017 01:58 AM

Re: Download key protected m3u8


 
The ASCII characters displayed in Firefox are wrong, this is why you have to use Fiddler to save the key file directly, so no copy/paste involved that might wreck the special characters the key file has.

About reading key file from disk directly without editing the m3u8... Unfortunately, even if ffmpeg/livestreamer had such a parameter, you still have to save the key file using Fiddler, because the key file is generated after some complex cookie send/receive within the http coding, so you can't get the key file any other way. This is why if you leave the original key link into the m3u8 it won't work, because ffmpeg/livestreamer cannot parse cookies. I also tried in the first place to parse special cookies to the m3u8 before editing, but I did not succeed. Also, like I said above, copying and pasting the key code from Firefox might not work if there are special characters involved. You can test this by comparing the key characters from Firefox with the ones from the key file saved with Fiddler and you'll understand what I mean.


All times are GMT -6. The time now is 08:32 AM.