Downloading Video Streams using Python
Why Stack Overflow recommends it
Stack Overflow users link it when answering how to download or record streamed video in Python without ffmpeg, especially fetching .m3u8 playlists and stitching their .ts segments.
Recommended by 3 people across 3 different months, 2019 to 2021.
What it is
A Python tutorial from the Indian Pythonista channel on downloading videos from sites that offer no download button. It walks through two websites that use different streaming methods, including HLS playlists made of .ts segments, and shares code on a gist.
What people said
Recommends DarkLeader · 2019-08 · Stack Overflow · on “trying to download a video from a streaming site, can't get the link i need”
import requests import m3u8 def download_file(url): local_filename = 'video.ts' r = requests.get(url) m3u8_master = m3u8.loads(r.text) playlist_url = m3u8_master.data['playlists'][0]['uri'] full_url = url.split('/') full_url = "/".join(full_url[0:-2]) full_url += '/' playlist_url = full_url + playlist_url new_r = requests.get(playlist_url) playlist = m3u8.loads(new_r.text) with open(local_filename, 'wb') as f: for segment in playlist.data['segments']: url = full_url + segment['uri'] req = requests.get(url) f.write(req.content) download_file(" [LINK] ") so this function works.. i got some help from this video : [this video] if someone wants to get a more detailed explanation. i had to go to the ne
Recommends Asd20752 · 2020-09 · Stack Overflow · on “Is there a way to record a livestream with Python?”
The .m3u8 format just tells where to find the video files and in what order they come. It is the .ts files them self that contain the video and since you mention not using ffmpeg I would suggest running a loop to fetch all the files and save them. The nice thing about .ts files is that they can be combined into one file, so you can just append the last file to the next one as long as they are sequential. And then run a loop to fetch the next files as they are produced. A good video for showing this is [this video] he goes through how do do a static .m3u8 file video stream, but can easily be adopted to live video.
Recommends KApril · 2021-10 · Stack Overflow · on “Downloading video from website using python”
Thank you Mr. Bertrand!! I found this solution by watching this video ( [this video] ) but I have another question about scraping a zoom steam video with passcode, could you please also take a look into this question ( [LINK] )