[FFmpeg-user] How to download encrypted m3u8 providing the key?

Moritz Barsnick barsnick at gmx.net
Tue Jul 7 23:21:31 EEST 2020


Hi Matheus,

On Tue, Jul 07, 2020 at 14:45:08 -0300, Matheus Silva wrote:
> Guys, how can I download from an encrypted m3u8 but that the key's URI is
> no longer available? Obviously I downloaded the key previously, a 16 byte
> file (that I get the hex string using "xxd -p"), I tried the following
> using the cryptokey parameter but ffmpeg keeps trying to do the decryption
> using the key URI provided in the m3u8 file. https://pastebin.com/SNA0CAJ2

I'm not sure you can override the key URI given by the HLS (m3u8). What
you should be able to do is to download the m3u8, replace all the
"URI=" in each "EXT-X-KEY:" line, retaining the "IV=", and expanding
each segment to a full path, from e.g.
k0_chunk_1594093207765475768_0_a.ts
to
https://prod-ec-sa-east-1.video.periscope.tv/Transcoding/v1/hls/TZPcueFo9ipbNHlYV8n1AMloI1ea7i-9j4o5BqRsDYGuuqxctEEZEvDHDZbpcVLgY1V0M9kLLIi5QeOlp3q8qA/non_transcode/sa-east-1/periscope-replay-direct-prod-sa-east-1-private/k0_chunk_1594093207765475768_0_a.ts

Then use the local m3u8 file as ffmpeg's input.

You may need some protocol whitelist or some "safe" flag on the ffmpeg
command line, in order to be able to load content from file and
network, but ffmpeg will probably tell you so.

Good luck. I'm too lazy to convert your hex command line key argument
back to a key file in order to test. ;-)

Cheers,
Moritz


More information about the ffmpeg-user mailing list