Video recording with Python

Any python script to record video while it plays, want to analyse videos with ChatGPT. Been searching through the net but can’t find any. Thanks

Any idea how about doing the above mentioned?