Last active
April 18, 2020 13:31
-
-
Save hdante/6036f7fdc90cd59f92a77cbc610bcbc0 to your computer and use it in GitHub Desktop.
Lossless screencast for Gnome Shell (supports wayland and X)
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
#!/usr/bin/env python3 | |
from dbus import SessionBus, Interface | |
from os import getcwd, path | |
from sys import argv | |
BUS_NAME = 'org.gnome.Shell.Screencast' | |
PATH_NAME = '/org/gnome/Shell/Screencast' | |
INTERFACE_NAME = BUS_NAME | |
PIPELINE='x264enc pass=qual quantizer=0 speed-preset=ultrafast ! queue ! matroskamux' | |
if path.isabs(argv[1]): | |
name = argv[1] | |
else: | |
name = path.join(getcwd(), argv[1]) | |
bus = SessionBus() | |
screen_cast = bus.get_object(BUS_NAME, PATH_NAME) | |
screen_cast = Interface(screen_cast, INTERFACE_NAME) | |
ret, name = screen_cast.Screencast(name, {'pipeline': PIPELINE}) | |
if not ret: | |
print('Error starting screencast.') | |
raise SystemExit(1) | |
try: | |
i = input() | |
except (EOFError, KeyboardInterrupt): | |
pass | |
finally: | |
screen_cast.StopScreencast() |
Great script! What file format does it output to?
It's configured for H.264 Matroska (.mkv) files. It can be configured with the PIPELINE variable, in line 9.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great script! What file format does it output to?