How To Download YouTube Stream Video with Python?

Yanwei Liu
1 min readFeb 4, 2020

--

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" https://www.youtube.com/watch?v=hHW1oY26kxQ 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:

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

--

--

Responses (2)