Mohammad Olfatmiri
Mohammad Olfatmiri

Reputation: 1675

decrypt AES-128 encrypted .m3u8 playlist and .TS files with ffmpeg

I'm trying to decrypt a .m3u8 playlist, I followed these steps :

and using this command to decrypt the playlist

ffmpeg -i playlist.m3u8 -c copy output.ts

but I got this error : Invalid data found when processing input

here is my m3u8 :

#EXTM3U
#EXT-X-TARGETDURATION:12
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=AES-128,URI="my.key"
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:6.000,
s-1-v1-a1.ts
#EXTINF:6.000,
s-2-v1-a1.ts
#EXTINF:6.000,
s-3-v1-a1.ts
#EXTINF:12.000,
s-4-v1-a1.ts
#EXTINF:12.000,
s-5-v1-a1.ts
#EXTINF:6.000,
s-6-v1-a1.ts
#EXT-X-ENDLIST

Upvotes: 9

Views: 31755

Answers (1)

John
John

Reputation: 418

Try specifying the full local path in your manifest so make the KEY like:

#EXT-X-KEY:METHOD=AES-128,URI="file://path/to/local/my.key"

and the TS chunks all like:

file://path/to/local/s-6-v1-a1.ts

If that doesn't work then ffmpeg could need the input for a m3u8 to be served over HTTP. So put your m3u8 file and the key and all your chunks on some web dir and rerun your ffmpeg command using the URL for the m3u8 so it'd be like:

ffmpeg -i http://mytestwebserver.com/playlist.m3u8 -c copy output.ts

If you don't have access to a webserver you can install some local and free like MAMP. I have had no issues using the above command to copy a HLS stream locally when the input is a HLS URL.

Upvotes: 10

Related Questions