How To Download YouTube Stream Video with Python?

1] You have to install the YT downloader tool called “streamlink” by using the following PIP command:

pip install streamlink

2] change the current working directory in the terminal to the path where you want to download the file:

Windows: cd c:\users\YourUserName\downloads
Mac/Unix: cd /Users/YourUserName/downloads
Linux: cd /home/YourUserName/downloads

3] And finally, to download a live YT video stream type the following command (the below command is specific for the video link you provided)

streamlink --hls-live-edge 99999 --hls-segment-threads 5 -o "video.mp4" best

4] You will see the tool streaming the video to your hard drive. Since it’s an ongoing stream, it will probably never end, so when you think you’ve downloaded enough you can stop the process by hitting CTRL+C and your file will be ready.

Below is an example output of this command that downloaded 24 sec. / 178 MB of live stream:

Image for post
Image for post

[WARNING: this tool and the above command will download the best quality video, so make sure you have enough hard drive space for it]

Written by

Machine Learning / Deep Learning / Python / Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store