Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Last active April 16, 2024 22:32
Show Gist options
  • Save tzmartin/fb1f4a8e95ef5fb79596bd4719671b5d to your computer and use it in GitHub Desktop.
Save tzmartin/fb1f4a8e95ef5fb79596bd4719671b5d to your computer and use it in GitHub Desktop.
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4

Alt text

Example final command

ffmpeg -i "http://host/folder/file.m3u8" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4
@raleighlittles
Copy link

If you run this exact command on newer FFMPEG versions you'll probably get an error about something not being on the whitelist: protocol https not on whitelist

Modify the command to use this instead

$ ffmpeg -protocol_whitelist file,https,tcp,tls -i master.m3u8 -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 video.mp4 

Tested with FFMPEG versions 5.0 and newer

@ArgX11
Copy link

ArgX11 commented Sep 6, 2023

Thanks! How to speed up the download (like, download concurrently?)

Use N_m3u8DL-RE with -mt argument.

@sanjukhunt
Copy link

Tried using VLC and it was being tempermental on me, this worked so much better thank you

can you please share more details how we can convert using VLC Kit?

@kolbdog3333
Copy link

Works great also i noticed if you copy a 1280x720 youtube video url from download helper and use this method it downloads the 1920x1080 video instead it downloads a higher qualtiy video then the original. It works perfectly thank you.

@garretttaco
Copy link

This works perfectly, thanks for sharing!

@geraldotech
Copy link

nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment