Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.4k views
in Technique[技术] by (71.8m points)

encryption - How to decrypt AES 128 encrypted HLS stream when URI for key is "k/timestamp"

I have downloaded 1784 .ts files and they are AES 128 encrypted.

The .m3u8 file has #EXT-X-KEY:METHOD=AES-128,URI="k/timestamp",IV=0x496daa1c6914000e408c65cead91fc29 which I guess indicates that the key must be in a file named timestamp. I got the "timestamp" file and now I want to decrypt.

I tried replacing the URI with URI="file:timestamp" with all the .ts, the .m3u8 and the timestamp file all in same directory and ran the ffmpeg command

ffmpeg -allowed_extensions ALL -protocol_whitelist file,tcp,crypto,http,https -i playlist.m3u8 -c copy op.mp4

but got the errors Error when loading first segment 'hls_350k_000.ts' playlist.m3u8: Invalid data found when processing input even though it opened the file successfully.

I tried specifying the URI as URI="http://localhost/mydir/timestamp" but got the same error as specified above. I had all .ts,.m3u8,"timestamp" file in XAMPP's htdocs folder.

When I open the "timestamp" file in browser's inspect->Network->Click on file->preview, I see weird text like kfˉ2“.ú?“á?a Bn5ydr/x$.9+cgKC!<??¢ìN??j??? and it changes everytime I refresh the site.

I specified the link of the file in URI and tried, same error.

I tried specifying .key extension to the "timestamp" file, same error.

I downloaded the "timestamp" file by entering its URL into browser which I got from inspect->Network->Click on file->Headers, I didn't download it as HAR or other stuff.

I tried playing the .m3u8 file in chrome using chrome by using Native HLS Playback extension with files hosted using XAMPP but it doesn't play, video player shows loading and the chrome's console has following errors

(anonymous) @ player.js:57
player.js:11 trying to recover from media Error ...
handleMediaError @ player.js:11
hls.0.12.4.min.js:1 Uncaught (in promise) DOMException: The play() request was interrupted by a new load request.
player.js:57 Player error: mediaError - fragParsingError
(anonymous) @ player.js:57
player.js:17 trying to swap Audio Codec and recover from media Error ...
handleMediaError @ player.js:17
player.js:57 Player error: mediaError - fragParsingError
(anonymous) @ player.js:57
player.js:22 cannot recover, last media error recovery failed ...
handleMediaError @ player.js:22
DevTools failed to load SourceMap: Could not load content for chrome-extension://emnphkkblegpebimobpbekeedfgemhof/hlsjs/hls.min.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME

I tried combining the .ts files using ffmpeg but got the same errors specified above.

How do I decrypt the files and combine them into a single vlc playable file?

question from:https://stackoverflow.com/questions/65884819/how-to-decrypt-aes-128-encrypted-hls-stream-when-uri-for-key-is-k-timestamp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...