Hi.
I'm looking for a .bat script that will decrypt video and audio (mp4, m4a) using keys stored in a txt file.
I came across sth like this:
The above script is not too good because it runs each key separately and creates redundant files. So If I have 20 keys in txt, the will script create 20 videos (one decrypted among them).Code:setlocal enabledelayedexpansion for /f "delims=" %%a in ('dir /B *.mp4') do ( set /a counter=0 for /f "delims=" %%b in (keys.txt) do ( set /a counter+=1 mp4decrypt --key %%b --show-progress "%%a" "%%~na_!Counter!.mp4" ) )
Can you guys come up with sth better?
Support our site by donate $5 directly to us Thanks!!!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
Try StreamFab Downloader and download streaming video from Netflix, Amazon!
+ Reply to Thread
Results 1 to 14 of 14
-
-
put on same folder key.txt, mp4decrypt, decrypt.bat, video.mp4, audio.aac, ffmpeg
audio and video are encrypted
edit key.txt with your key:
Code:video,xxxx:xxxx audio,xxxx:xxxx
Code:@echo off pushd "%~dp0" md ".\decode" >nul 2>nul for /f "tokens=1,2 delims=," %%a in (key.txt) do ( for %%c in (mp4 aac) do ( if exist ".\%%a.%%c" ( mp4decrypt.exe --key %%b "%%a.%%c" "____tmp.%%c" move /y ".\____tmp.%%c" ".\Decode\%%a.%%c" ) if exist ".\%%a(Audio).%%c" ( mp4decrypt.exe --key %%b "%%a(Audio).%%c" "____tmp.%%c" move /y ".\____tmp.%%c" ".\Decode\%%a(Audio).%%c" ) ) ) echo,ok pause>nul
Code:echo off ffmpeg.exe -i ..Decode\video.mp4 -i --Decode\audio.aac -c copy muxed.mp4
-
Doesn't work.
Besides my keys txt file looks like this:
Code:0100c6ff9e3c64f14ba77e3bbb6a82dc:20bc0db1734e4a368af98f8340cc37c6 0105e2531122ec62ae1adbfcd2d30e84:3787f7c1fbbc8b6494e3411ddeae23a3 010280d0df7acf79502606dc4fd1ec46:4d7519e64031a171a01422fb84a7b6fe 01011b0127298b4a0ffb2862b321aca7:b9bfd3f6417f902ce8fd6899fbb210b5
mp4decrypt does that automatically.Last edited by m0ck; 14th Mar 2022 at 11:49.
-
If python is ok this can be achieved easily.....
keys.txt
Code:eb676abbcb345e96bbcf616630f1a3da:100b6c20940f779a4589152b57d2dacb 0294b9599d755de2bbf0fdca3fa5eab7:3bda2f40344c7def614227b9c0f03e26 639da80cf23b55f3b8cab3f64cfa5df6:229f5f29b643e203004b30c4eaf348f4
Code:import subprocess kid = input('Enter the KID:') with open('keys.txt') as f: for line in f: stripped = line.strip() if stripped[0:32] == kid: key = stripped[-32:] key_pair = kid+':'+key #print(key_pair) subprocess.run([mp4decrypt, "--key", str(key_pair),"video_encrypted.mp4","video_decrypted.mp4"])
-
yes not work. for you. look better my key.txt:
Code:video,xxxx:xxxx audio,xxxx:xxxx
and same for audio. replace kid:key with your data like 0105e2531122ec62ae1adbfcd2d30e84:3787f7c1fbbc8b649 4e3411ddeae23a3
but need video, first where video, is the name of your video file encrypted.
if you don't follow this syntax the command does not work -
But as I said, I don't know which key is for video and which is for audio and keys txt contains lots of keys so unfortunately your script won't do in my case.
-
do you know the kid for the video and audio?
if not, you can get it from the video/audio file with mp4dump.
(alot of smaller streaming sites only use the one kid per content)
eg.
Code:mp4dump <encrypted_file> | findstr /I kid default_KID = [59 d5 c7 a1 e3 6d 1c d7 0c b7 4c 51 ca b5 ac e1]
the other way is to add all the kid:keys to the mp4decrypt command and it will use the one that matches the kid of the file.
ie.
Code:mp4decrypt --key <kid1:key1> --key <kid2:key2> --key <kid3:key3> --key <kid4:key4> --key <kid5:key5> <encrypted_filename> <decrypted_filename>
-
That is EXACTLY what I want to achieve. But instead of copying each key to the command line, I want the script to take them from txt file.
That's all.
Concept:
mp4decrypt --key keys.txt encrypted.mp4 decrypted.mp4
In keys.txt thare might be lots of different keys and only one is correct (don't know which).
Is sth like this even possible in batch script? -
This is what you are looking for
Code:@echo off :start setlocal enableextensions enabledelayedexpansion echo. set dec=dec.mp4 set enc=enc.mp4 for /f "delims=" %%a in (keys.txt) do ( set /a totalKeys += 1 set "keys=!keys! --key %%a" ) echo Found total %totalKeys% keys :decrypt_process set mp4dec_args="mp4decrypt.exe" --show-progress !keys! "!enc!" "!dec!" echo MP4DECRYPT ARGUMENTS & echo !mp4dec_args! & echo. !mp4dec_args! echo. endlocal pause
-
@zackmark29 This is AWESOME and exactly waht I was looking for!
Thanks a ton!
One more thing though.
How to change the script to also decrypt audio?
There are two files in a folder.
encrypted.mp4 (video) and encrypted.m4a (audio) -
Code:
@echo off :start setlocal enableextensions enabledelayedexpansion echo. set enc_v=enc_v.mp4 set dec_v=dec_v.mp4 set enc_a=enc_a.m4a set dec_a=dec_a.m4a for /f "delims=" %%a in (keys.txt) do ( set /a totalKeys += 1 set "keys=!keys! --key %%a" ) echo Found total %totalKeys% keys :decrypt_process echo DECRYPTING VIDEO TRACK mp4decrypt.exe --show-progress !keys! "!enc_v!" "!dec_v!" echo. echo DECRYPTING AUDIO TRACK mp4decrypt.exe --show-progress !keys! "!enc_a!" "!dec_a!" echo. endlocal pause
-
hi there, batch script from @zackmark29 is awesome and work perfectly but i want more comfortable to use
i've read this thread from @A_n_g_e_l_a (thank for your python) and i see the way to improve zackmark script "Copy stream URL as 'Table Entry' from The Stream Detector"
read keys from key.txt and use Table Entry for set a filename and MPD_URL (using with N_m3u8DL-RE)
i try to implement zackmark batch script but it gave me more error when query string from Table Entry to filename , mpdurl , timestamp
can anyone help me ? thanks a lot.Last edited by Biggy4; 14th Feb 2023 at 10:05. Reason: typo
Similar Threads
-
Got keys but can't get encrypted video. Please help
By daigo99 in forum Video Streaming DownloadingReplies: 7Last Post: 28th Oct 2022, 02:28 -
How to decrypt webm video file?
By webcyb in forum Video Streaming DownloadingReplies: 3Last Post: 25th Oct 2021, 04:01 -
decrypting the video with keys
By jamkiya in forum Video Streaming DownloadingReplies: 4Last Post: 30th Aug 2021, 02:11 -
Decrypt HLS on demand video file
By shock in forum Video Streaming DownloadingReplies: 9Last Post: 6th Nov 2019, 08:42 -
Luma value in a TXT file
By barabba2005 in forum Video ConversionReplies: 6Last Post: 17th Nov 2017, 10:34