Skip to content

Instantly share code, notes, and snippets.

@mojienjoyment
Forked from frozenpandaman/widevine-decryption.md
Last active September 30, 2026 02:35
Show Gist options
  • Select an option

  • Save mojienjoyment/a90340a69d060d13a22439caadfaf8c5 to your computer and use it in GitHub Desktop.

Select an option

Save mojienjoyment/a90340a69d060d13a22439caadfaf8c5 to your computer and use it in GitHub Desktop.
download videos protected with widevine DRM

Downloading Widevine content

Specifically from https://www.kocowa.com/

FMI: https://cdm-project.com/How-To/ & https://old.reddit.com/r/Piracy/comments/y30ffr/

Setup

  1. Install Tampermonkey: https://www.tampermonkey.net/
  2. Install yt-dlp: https://github.com/yt-dlp/yt-dlp#installation
  3. Install ffmpeg: https://ffmpeg.org/download.html
  4. Download Bento4: https://www.bento4.com/downloads/
  5. Have a proxy/VPN if you're not in countries that Available to Watch!

Getting your decryption key

Get PSSH

  1. Install this userscript: https://greasyfork.org/en/scripts/373903-eme-logger
  2. Search browser JS Console for MediaKeySession::generateRequest, then press play on the video and look under "Init Data"
  3. Get something like AAAAMnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAXXXXXXXXFtoyTEzFOZDD4T9lmTiI=

Getting the key

  1. Install extension Widevine L3 Decrypter by YeetMasta
  2. Go to DRM content tab and hit exension icon while playing.
  3. Hit Guess! button.
  4. Hopefully see the a key that looks like e0c5b68c93133XXXXXXXX84fd9664e22:499047f36b770957XXXXXXXX9dfc4033

Downloading the encrypted files

  1. Go to DRM content tab.
  2. In the developer console Network tab, search for mpd
  3. While playing content, Find something that starts with Manifest, right click and copy the URL, e.g. https://azclwds01.akamaized.net/9dc3547a-ede5-4aed-841f-5cXXXXXXXX0f/tXyKyP_tab_hd.ism/Manifest(format=mpd-time-csf,encryption=cenc,filter=pc_hd_001)
  4. Run the Terminal command: yt-dlp --allow-unplayable [url]
  5. Get two files, an .mp4 and an .m4a

Decrypting & merging the files

  1. In Bento4's bin/ folder, find the mp4decrypt command line utility
  2. Navigate to this folder in your Terminal and run mp4decrypt --key [yourkey] /path/to/corrupted.file /path/to/fixed.file on both files
  3. Run ffmpeg -i fixedvideo.mp4 -i fixedaudio.m4a -c:v copy -c:a copy output.mp4
  4. The end

Getting subtitle file

  1. In the developer console Network tab, search for .vtt
  2. While playing content, Find something that starts with Manifest, right click and copy the URL and download it with some tools like wget. That is the subtitle file.
  3. merge files with subtitle: ffmpeg -i fixed.mp4 -i fixed.m4a -i subtitle.vtt -map 0:v:0 -map 1:a:0 -map 2:0 -c:v copy -c:a copy -c:s srt -metadata:s:s:0 language=eng output.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment