HLS stream ( m3u8 ) is a well-known media type in the Internet. How could I download the m3u8 to MP4 by using ffmpeg
Some application, website has protected their stream by cross-domain policy. We’ll need to add something legal into header. That’s OK? Here is my working download script by ffmpeg, bypass the policy by http headers option’s referer:
ffmpeg -user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36" -headers "origin: https://streaming-website.com" -headers "referer: https://streaming-website.com" -i https://streaming-website.com/playlist.m3u8 -c copy your-playlist.mp4
Bonus tips: download by youtube-dl script
youtube-dl --add-header Accept-Encoding:"identity;q=1, *;q=0" --add-header Range:"bytes=6488064-" --add-header Referer:"https://streaming-website.com" --add-header User-Agent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36" https://streaming-website.com/playlist.m3u8 --output your-playlist.mp4
Please let me know if this share help your program work. Thank you!