Skip to content

Instantly share code, notes, and snippets.

@nikicat
Created September 15, 2022 18:52
Show Gist options
  • Save nikicat/95614865ddc0a0c7678af9a29b0d8467 to your computer and use it in GitHub Desktop.
Save nikicat/95614865ddc0a0c7678af9a29b0d8467 to your computer and use it in GitHub Desktop.
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