I am attempting to download and convert an m3u8 stream to mp4 using ffmpeg. The command I first tried was
ffmpeg -i MIE.m3u8 -c copy -bsf:a aac_adtstoasc -safe 0 -protocol_whitelist file,http,https,tcp,tls,crypto MIE.mp4
(see below for contents of MIE.m3u8
)
This failed immediately with error
[https @ 0x7fb419607d40] Protocol 'https' not on whitelist 'file,crypto'!
MIE.m3u8: Invalid argument
(Note that the memory address changes each time.)
I discovered the -protocol_whitelist
flag and appended -protocol_whitelist file,http,https,tcp,tls,crypto
to my command
ffmpeg -i MIE.m3u8 -c copy -bsf:a aac_adtstoasc -safe 0 -protocol_whitelist file,http,https,tcp,tls,crypto MIE.mp4
but this still resulted in the same error.
Why does ffmpeg
appear to ignore the protocol_whitelist
flag and parameters?
MIE.m3u8
(which I managed to fetch from the website I am trying to scrape video from) looks like this:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=508000,RESOLUTION=640x360,CODECS="avc1.77.30, mp4a.40.2"
https://nhk-vh.akamaihd.net/i/das/D0005140/D0005140255_00000_V_000.f4v/index_0_av.m3u8?null=0&id=AgBdrl8GX2UAVyUXA1tF7MYlFTbSF88WtA7oAMDksTsiVdAKPuuREVfi8iXMsOWFp6eQU2sk6dnE9g%3d%3d
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=47000,CODECS="mp4a.40.2"
https://nhk-vh.akamaihd.net/i/das/D0005140/D0005140255_00000_V_000.f4v/index_0_a.m3u8?null=0&id=AgBdrl8GX2UAVyUXA1tF7MYlFTbSF88WtA7oAMDksTsiVdAKPuuREVfi8iXMsOWFp6eQU2sk6dnE9g%3d%3d
protocol_whitelist
is a parameter only on the input
file (in your case, MIE.m3u8
), so it must be specified before the input in your command.
Specify -protocol_whitelist file,http,https,tcp,tls
prior to -i
and it'll work as you expect:
ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i MIE.m3u8 -c copy -bsf:a aac_adtstoasc MIE.mp4
You can a similar case on a Debian Bugs discussion board, and read up more on the syntax of ffmpeg commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With