Created
September 15, 2022 18:52
-
-
Save nikicat/95614865ddc0a0c7678af9a29b0d8467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dbus | |
import sys | |
def get_object(bus): | |
return bus.get_object('org.gnome.Shell.Screencast', '/org/gnome/Shell/Screencast') | |
def main(filename: str): | |
bus = dbus.SessionBus() | |
iface = dict(dbus_interface='org.gnome.Shell.Screencast') | |
get_object(bus).StopScreencast(**iface) | |
options = { | |
"draw-cursor": True, | |
"pipeline": ' ! '.join([ | |
'vaapipostproc', | |
#'video/x-raw,format=NV12,width=1920,height=1200,max-framerate=60/1', | |
'video/x-raw,format=NV12,max-framerate=60/1', | |
'queue', | |
'vaapih264enc', | |
'video/x-h264,profile=main', | |
'queue', | |
'h264parse', | |
'matroskamux', | |
]), | |
"framerate": 60, | |
} | |
(status, filename) = get_object(bus).Screencast(filename, options, **iface) | |
if not status: | |
raise Exception("Failed to start recording, look through logs `journalctl --user -afu dbus.service`") | |
input(f"writing to {filename}. press enter to stop") | |
get_object(bus).StopScreencast(**iface) | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment