From f71aae7fbd3d8c4b54cbbe4b914bbd67bd146981 Mon Sep 17 00:00:00 2001 From: digitalcircuits Date: Sat, 9 Jan 2021 02:57:40 -0500 Subject: [PATCH] Added example to record screen of Windows OS --- examples/record_windows_screen.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/record_windows_screen.py diff --git a/examples/record_windows_screen.py b/examples/record_windows_screen.py new file mode 100644 index 0000000..50e6bbb --- /dev/null +++ b/examples/record_windows_screen.py @@ -0,0 +1,22 @@ +import ffmpeg, time + +#Setup for recording windows desktop to mp4 file +process = ( + ffmpeg + .input(format='gdigrab',framerate=30,filename="desktop") + .output(crf="0",preset="ultrafast",filename="./output.mp4",c= "libx264" ) + .overwrite_output() + ) +#Launch video recording +process = process.run_async(pipe_stdin=True) + + +#Let it record for 20 seconds +time.sleep(20) + +#Stop video recording +process.communicate(str.encode("q")) #Equivalent to send a Q + +# To be sure that the process ends I wait 3 seconds and then terminate de process (wich is more like kill -9) +time.sleep(10) +process.terminate() \ No newline at end of file