axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
1.97k stars 479 forks source link

mp4decrypt does not work with m4a audio files? #589

Open Zeldrisz opened 3 years ago

Zeldrisz commented 3 years ago

I am trying to decrypt an audio file in .m4a format I am using the correct key, but the file is not being decrypted. The same file in .aac format is decrypted using the same key, but as I said, it doesn't work in m4a format.

"audio578956 m4a audio only [pt] DASH audio 128k , m4a_dash container, mp4a.40.2 (48000Hz)"

"mp4decrypt --key faxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:85xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "test.m4a" "decrypt.aac" or "mp4decrypt --key faxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:85xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx "test.m4a" "decrypt.m4a"

Either way, the m4a file is not decrypted. Is there any solution?

barbibulle commented 3 years ago

You should be using: mp4decrypt --key <track-id>:<key> encrypted.mp4 decrypted.mp4 where is the track ID with your audio track (if you have multiple tracks, you use multiple --key options). You can list the tracks in your file with mp4info. Typically, track IDs start at 1.

Zeldrisz commented 3 years ago

You should be using: mp4decrypt --key <track-id>:<key> encrypted.mp4 decrypted.mp4 where is the track ID with your audio track (if you have multiple tracks, you use multiple --key options). You can list the tracks in your file with mp4info. Typically, track IDs start at 1.

I'll try, thanks!

nammminn2 commented 2 years ago

You should be using: mp4decrypt --key <track-id>:<key> encrypted.mp4 decrypted.mp4 where is the track ID with your audio track (if you have multiple tracks, you use multiple --key options). You can list the tracks in your file with mp4info. Typically, track IDs start at 1.

i did that and i got unexpected error

CleanShot 2022-02-24 at 02 54 28@2x

but when i do it on my pc i have no error

CleanShot 2022-02-24 at 02 30 59@2x

on my pc i just do mp4decrypt.exe —-key 7733ab9b0ce54c666daa134568bd7f6c:cec588cbe2b6b7be20d300ae323fa548 ca.m4a ca_dec.mp4

bencollinz commented 2 years ago

I'm having the same issue. Audio and Video are separate on the target site. Video decrypts just fine. Audio does not.

barbibulle commented 2 years ago

You should be using: mp4decrypt --key <track-id>:<key> encrypted.mp4 decrypted.mp4 where is the track ID with your audio track (if you have multiple tracks, you use multiple --key options). You can list the tracks in your file with mp4info. Typically, track IDs start at 1.

i did that and i got unexpected error CleanShot 2022-02-24 at 02 54 28@2x but when i do it on my pc i have no error CleanShot 2022-02-24 at 02 30 59@2x on my pc i just do mp4decrypt.exe —-key 7733ab9b0ce54c666daa134568bd7f6c:cec588cbe2b6b7be20d300ae323fa548 ca.m4a ca_dec.mp4

In your example with the screenshot showing the error ('unexpected argument (ca.m4a)'), the command line argument is not correct. It should be --key 1:cec588cbe2b6b7be20d300ae323fa548, not --key 1:7733ab9b0ce54c666daa134568bd7f6c:cec588cbe2b6b7be20d300ae323fa548 (the argument means: decrypt track ID 1 with key cec588cbe2b6b7be20d300ae323fa548).

carmeldabush commented 5 months ago

im got "unexpected argument" error how can i fix it?

this command:

mp4decrypt.exe --key 1:edef8ba979d64acea3c827dcd51d21ed:AAAAWnBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADoIARIQsQDOCpU7Ee6gAS4RFK3dBiIkNjI4YWIyZmMtYWY3Ni00NDc2LThlMjgtMzJjNmNlOTdmZDI0:default_kid b100ce0a-953b-11ee-a001-2e1114addd06 1.mp4 new.mp4

barbibulle commented 5 months ago

The key value should be specified as : where is a track number and expressed in hex (32 hex characters). You can pass multiple keys, one per track.

rocketraccooo-n commented 3 weeks ago

Well, there ARE cases that audio tracks are encrypted in a way that a kid is present:

.\mp4dump.exe .\init.m4s
  [pssh] size=12+40, version=1
    system_id = [10 77 ef ec c0 b2 4d 02 ac e3 3c 1e 52 e2 fb 4b]
    data_size = 0
    kid 0 = [b3 9e be 4b 06 8b 9c d9 1c d9 be 5a 5d 63 65 0c]

In this case mp4decrypt just doesn't work with it. For people having the same frustration, we can use shaka-packager instead.

.\packager-win-x64.exe --enable_raw_key_decryption input=input.m4a,stream=0,output=output.m4a --keys key_id=b39ebe4b068b9cd91cd9be5a5d63650c:key=[your 16 byte key here]