dvershinin / green-recorder

A simple screen recorder for Linux desktop. Supports Wayland & Xorg
GNU General Public License v3.0
57 stars 3 forks source link

[Enhancement] Recording wayland session in mp4 format? #7

Closed FredBezies closed 3 years ago

FredBezies commented 3 years ago

Hello.

I wonder if you can add a mp4 encode option for wayland sessions? Webm is really low in quality compared to others formats.

Thanks for your answer.

dvershinin commented 3 years ago

Seems possible. Found here. Will try to see if it works when I'm back home (not using Linux GUI for some time).

FredBezies commented 3 years ago

Seems possible. Found here. Will try to see if it works when I'm back home (not using Linux GUI for some time).

Thanks for your answer. It will be great to have a better quality encoder for wayland.

dvershinin commented 3 years ago

@FredBezies sorry to keep your waiting. I tried implementing that according to the reference link, however even the short example script there fails to work. I am not sure what's missing there.

#!/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()

If anyone can get the recording to work with that script or point out what's missing, I'll be waiting :-)

lfom commented 3 years ago

@dvershinin The Python3 script above works just fine here on Wayland (Pop!_OS 20.10, like Ubuntu 20.10, Gnome 3.38.3).

Screenshot from 2021-04-06 22-19-11

By the way, I could not install your fork using either of the bellow (to ~/.local or /usr/local):

python3 setup.py install --user
sudo python3 setup.py install --prefix=/usr/local

I had to use pip (version 20.1.1 from Python3):

pip install .

and then it correctly installed as an user app to ~/.local. But then it would not open, because the ui.glade file could not be found, what was fixed in the source code easily. Maybe it is a good idea to update the README, also stating that it requires Python3? I am not sure about the minimal version tho, I have 3.8.6 here.

dvershinin commented 3 years ago

@lfom this app depends on a fair number of external libs that have to be built when installed via pip, thus such bugs, because the primary preferrable installation method is through packages. Things are not well tested when installed via pip.

In the new release ui.glade should be found fine when you install via pip.

It works with both Python 2 and 3. For Python 2, I'm testing with Python 2.7; and it should work fine with Python >= 3.6.

Don't know what I did before in my tests, but now it magically works (both the script and from within green-recorder). Added the codes to the new release. Replaced matroskamux with mp4mux so that we have a nice mp4 file and not an mkv:

image

FredBezies commented 3 years ago

Thanks. It seems to work with Archlinux and Gnome 40.0. At least, I have a working screen recorder for Wayland now.