In this new covid-19 world it happens more and more often that I need to record full-screen videos, for example for lectures. This is something that one can do live with Zoom, but that is not the most practical option for non-live recordings.
In Ubuntu there is a nice software, Kazam screencaster, that is perfect for the job, except that it does not get correctly the screen size if you have a high pixel density display (HiDPI): you end up with a video with only the top-left corner of the screen cropped.
There is a simple patch to fix that issue, which I describe here in case it’s useful to someone else and for the benefit of my future self.
First, you need to find the files gstreamer.py
and prefs.py
in the Kazam installation. For me they were in /usr/lib/python3/dist-packages/kazam/backend/
.
Next, you have to fix these such that they take into account the screen scaling factor, which is obtained from the get_monitor_scale_factor
function in the Gtk library
This cane be done by adding these lines to the file gstreamer.py
.
scale = self.video_source['scale']
startx = startx * scale
starty = starty * scale
endx = endx * scale
endy = endy * scale
They should be added around lines 120 or so, right after the properties endx
and endy
are set up (endy = starty + height - 1
).
Next, open the file prefs.py
and, around line 324, change this bit
for i in range(self.default_screen.get_n_monitors()):
rect = self.default_screen.get_monitor_geometry(i)
self.logger.debug(" Monitor {0} - X: {1}, Y: {2}, W: {3}, H: {4}".format(i,
rect.x,
rect.y,
rect.width,
rect.height))
rect.height))
self.screens.append({"x": rect.x,
"y": rect.y,
"width": rect.width,
"height": rect.height})
into this
for i in range(self.default_screen.get_n_monitors()):
rect = self.default_screen.get_monitor_geometry(i)
scale = self.default_screen.get_monitor_scale_factor(i)
self.logger.debug(" Monitor {0} - X: {1}, Y: {2}, W: {3}, H: {4}, scale: {5}".format(i,
rect.x,
rect.y,
rect.width,
rect.height,
scale))
self.screens.append({"x": rect.x,
"y": rect.y,
"width": rect.width,
"height": rect.height,
"scale": scale})
That’s it! Restart Kazam and the next fullscreen recording should work OK.
Thanks to user sllorente for describing the patch here!