Raj Shekhar Dev

Back

Convert m3u8 to mp4 using ffmpeg

You want to download a video from m3u8 url. You can do the following:

ffmpeg -i "<url>" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4

If you are getting this error: Protocol ‘https’ not on whitelist ‘file,crypto,data’!

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "<url>" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4

If you are using a m3u8 file which contains a encryption key enc.key and you get the following error: Filename extension of ‘enc.key’ is not a common multimedia extension, blocked for security reasons.

ffmpeg -allowed_extensions ALL -i "<url>" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4

Finally

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -allowed_extensions ALL -i "<url>" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4