How to download aes encrypted m3u8 using ffmpeg or youtube-dl?

6,566

You can use ffmpeg like so:

ffmpeg -i video.m3u8 -c copy -bsf:a aac_adtstoasc video.mp4

Also if the urls are https you can add https to allowed protocols like so:

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i video.m3u8 -c copy -bsf:a aac_adtstoasc video.mp4

Original article: Download encrypted HLS content with ffmpeg - davd.io

Share:
6,566

Related videos on Youtube

weakplayrxw
Author by

weakplayrxw

Updated on September 18, 2022

Comments

  • weakplayrxw
    weakplayrxw almost 2 years

    I have the m3u8 file and the key.bin, inside the m3u8 file is:

    #EXTM3U
    #EXT-X-VERSION:4
    #EXT-X-PLAYLIST-TYPE:VOD
    #EXT-X-INDEPENDENT-SEGMENTS
    #EXT-X-TARGETDURATION:6
    #EXT-X-MEDIA-SEQUENCE:0
    #EXT-X-KEY:METHOD=AES-128,URI="key.bin"
    #EXTINF:6.000000,
    segment-0.ts
    ...
    #EXTINF:4.416667,
    segment-159.ts
    #EXT-X-ENDLIST
    

    and inside the key.bin file is

    Ú{±€rl”ÜJÌy«‡mó
    

    How do I download this as an mp4 using ffmpeg or youtube-dl?.

    • Kamil Maciorowski
      Kamil Maciorowski over 3 years
      You can share the knowledge then.
    • weakplayrxw
      weakplayrxw over 3 years
      youtube-dl -o file.mp4 "m3u8-URL" might need to pass proper headers for youtube-dl/ffmpeg to be allowed to download the key. use --user-agent "" and --referer "" (use same user-agent as your browser, find yours easily at ifconfig.me/ua, and referer is the main URL in the browser from where you sniffed out the m3u8 URL) ( Thanks goes to the guy from reddit who gave the solution.)
  • gronostaj
    gronostaj over 3 years
    -1 because the answer is basically unreadable