DavidBuchanan314 / DeCENC

Tools for decrypting MPEG-CENC files without knowledge of the key
https://phrack.org/issues/71/6.html#article
MIT License
100 stars 6 forks source link

Segmented MP4 issues #4

Closed jmaoxuan closed 1 month ago

jmaoxuan commented 1 month ago

Hello,

This is quite an interesting project! I did get it to work with the included test file, however it did not completely work for a segmented mp4 that was merged into a single file then tested with testall.sh.

Is this because each chunk/segment needs to be separately ran through the project then merged together? I was getting lots of errors related to duplicate and unexpected frame matches.

When the output finished and I tested the file with mpv, I was able to play the first two minutes without issues, then the file unexpectedly closes on its own. I would assume this is where the next chunk begins?

Any suggestions would be welcome.

Cheers

jmaoxuan commented 1 month ago

Examples of the errors:

[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 199 size 100 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 1 referenced
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (12) is invalid, previous id (2) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 186 size 210 truncated at 4
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (1) is invalid, previous id (12) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 176 size 134 truncated at 4
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 191 size 42 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 2 referenced
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 164 size 26 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 1 referenced
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 249 size 235 truncated at 4
[NULL @ 0x564d6975fdc0] luma_log2_weight_denom 9 is out of range
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (2) is invalid, previous id (-1) error ignored (1)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 150 size 137 truncated at 4
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (1) is invalid, previous id (2) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 53 size 201 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 62 referenced
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 159 size 96 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 2 referenced
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:invalid syntax cabac_init_idc 4
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 19 size 207 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 4 referenced
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (62) is invalid, previous id (-1) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (2) is invalid, previous id (62) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 23 size 152 truncated at 4
[NULL @ 0x564d6975fdc0] SEI type 216 size 99 truncated at 4
[NULL @ 0x564d6975fdc0] illegal reordering_of_pic_nums_idc 19
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (4) is invalid, previous id (2) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 241 size 236 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 1 referenced
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 49 size 47 truncated at 4
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 224 size 207 truncated at 4
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (1) is invalid, previous id (-1) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 30 size 167 truncated at 4
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 12 size 240 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 4 referenced
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 7 size 16 truncated at 4
[NULL @ 0x564d6975fdc0] non-existing PPS 2 referenced
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 175 size 212 truncated at 4
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (4) is invalid, previous id (-1) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 231 size 248 truncated at 4
[libopenh264 @ 0x564d697886c0] [OpenH264] this = 0x0x564d69ac3750, Error:PPS id (2) is invalid, previous id (4) error ignored (0)!
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
[vist#0:0/h264 @ 0x564d69788540] Error submitting packet to decoder: Unknown error occurred
[NULL @ 0x564d6975fdc0] SEI type 248 size 117 truncated at 4
[libopenh264 @ 0x564d697886c0] DecodeFrame failed
DavidBuchanan314 commented 1 month ago

How did you merge the segments?

jmaoxuan commented 1 month ago

@DavidBuchanan314 After double checking some stuff, this media file was actually downloaded in one piece, NOT segmented. I thought the errors were related to merging the segments but its apparently not so.

I am currently running testall again and its still spitting out similar errors so I am not sure whats going on.

I tried with another encrypted file with the same encryption, and it again plays perfectly fine for the first 2 minutes and few seconds, then the file force closes.

I do have the decryption key and can decrypt it with mp4decrypt and it is playable so it is not an issue with the media file.

DavidBuchanan314 commented 1 month ago

testall.sh will only work if the encryption key matches the one here https://github.com/DavidBuchanan314/DeCENC/blob/6b447b4b331545cc15352963030c3379050ea7ef/testall.sh#L31

If you're testing with a different key you'll need to change it there

jmaoxuan commented 1 month ago

testall.sh will only work if the encryption key matches the one here

https://github.com/DavidBuchanan314/DeCENC/blob/6b447b4b331545cc15352963030c3379050ea7ef/testall.sh#L31

If you're testing with a different key you'll need to change it there

Wait I am confused; I thought this can decrypt without knowledge of the key? If I decrypt it using mp4decrypt and the key I have it works of course, but shouldn't DeCENC be able to decrypt without knowledge of the key?

I shot you a message on discord as that would be a bit more convenient than this if you'd be so inclined.

DavidBuchanan314 commented 1 month ago

testall.sh is just an artificial test, you'd need to use a modified variation of the "open loop" procedure if you want to test against a real CDM provisioned with real keys