Download YouTube live stream in real time with Python

Is there a way to download a YouTube live stream as it's happening in real-time in Python?

My best guess would be to use Pafy. For example,

import pafy

url = ""
video =
best = video.getbest(preftype="mp4")

However, I'm not sure if this works for live streams and how to download frames in real-time.

Or maybe using vidgear:

from vidgear.gears import CamGear

stream = CamGear(source='', stream_mode = True, logging=True).start()

while True:    
    frame =

I'm also not sure if that works in real-time.

These code examples are borrowed from a related question: How to read Youtube live stream using openCV python?

I'd like to be able to process the frames in a while loop kind of like this:

while True:
    # The current frame in real-time
    frame = get_frame()
🔴 No definitive solution yet