Last active
April 11, 2024 21:53
-
-
Save SophieShears/04781f37ee7d64b029659ff3846101f8 to your computer and use it in GitHub Desktop.
Download m3u8 links as mp4 with python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First have to pip install "ffmpeg-python" | |
# Code to download m3u8 links as mp4 files | |
import ffmpeg | |
def dl_m3u8(dl_url, filepath): | |
try: | |
stream = ffmpeg.input(dl_url) | |
stream = ffmpeg.output(stream, f'{filepath}.mp4') | |
ffmpeg.run(stream) | |
except Exception as e: | |
print(e) | |
# Test it works | |
url = 'https://manifest-gcp-us-east1-vop1.fastly.mux.com/H5OpRq9F8lbmryLoKO00eYORo7gfIWIYTe6QzasTx4GB02p6r9tf00Lly77iomn8Cs8z3PcwBMUgxRQNZ6TkprsqZ00RmLU7vgbGtlIRSylY0002I/rendition.m3u8?cdn=fastly&expires=1713477600&skid=default&signature=NjYyMTk3ZTBfMjgzNzg0ZmQ4NTQ5YmFiNGVlNzk3NTkxOTg0YzMwM2E1NTlkMjRiNTJmYjFjMzAxNDUyMzBkYTViZmFkMzg0YQ==&vsid=p4CSoUuDo1qJH84z6q9JnpT8dLqBRZLThbNBflxQlYFnv7SCQyg7Qj9W4MzzM7lIb67gToCMQLs' | |
dl_m3u8(url, 'output_file') | |
# Should produce an mp4 file called 'output_file.mp4' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment