[FFmpeg-user] How to decrypt .ts files into separate .ts files with ffmpeg without using a playlist?

Crazy Red Elephant crazyredelephant at protonmail.com
Mon Feb 10 23:16:36 EET 2020

This works, Moritz, thank you. However, for some reason it works only for the part0 file, two others don't open in Windows Media Player after decryption. That's weird...

What's also interesting is that there's about 17 KB difference in size between the part0 file decrypted with openssl (3,476 KB, which is 16 bytes less than the original encrypted one) and part0 decrypted from m3u8 (3,496 KB). Do you have any idea why it's like that?

Another thing is that I'm getting a "hex string is too short, padding with zero bytes to length" message but I suppose is fine since we use -iv 0...

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, February 10, 2020 9:18 PM, Moritz Barsnick <barsnick at gmx.net> wrote:

> On Mon, Feb 10, 2020 at 13:40:59 +0000, Crazy Red Elephant via ffmpeg-user wrote:
> > I have a number of .ts files, .m3u8 playlist and a key to decrypt
> > them. The key is a file, not a hexadecimal string. My goal is to
> > decrypt some of these .ts files to analyze them individually. I also
> > obviously don't want to modify the actual video/audio streams in them
> > in any way, just a decryption.
> I had to google my way into this, but have a solution:
> This AES encryption is on the outmost layer. In other words, no
> demuxing has to be done before decrypting. You can just apply straight
> AES decryption onto the input segments, without using ffmpeg.
> You already figured out the key from the keyfile. As your m3u8 has no
> "IV" section, I assumed your encryption uses no such initialization
> vector.
> I found that the openssl command line tool can do this decrption:
> $ openssl aes-128-cbc -d -nosalt -K 5e5852fab5eedf7c6b7a367b1fc140a1 -iv 0 -in part0.ts -out part0.dec.ts
> I did this for each segment (in a shell loop obviously), and got the
> desired results. The decrypted segments now play exactly like your
> encrypted playlist.
> > So how to do this properly? The ffmpeg documentation wasn't helpful...
> As far as I can tell, the HLS demuxer handles key files, but the
> command line tool itself only takes actual decryption keys (and IVs),
> not files. And I didn't manage to decrypt the individual segments with
> ffmpeg, even with use of the key values on the command line.
> > Here
> > are the files I'm working with in a zip archive. I've included only
> > three of the .ts files there, that should be enough for a test.
> Appreciated. That was good for testing.
> Hope this helps,
> Moritz
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".

More information about the ffmpeg-user mailing list