How to capture screen on Wayland with pipewire?
Shmerl 4 Jul 2022
Any recommendation how to capture screen using some minimalist tools like ffmpeg? I didn't find any info on ffmpeg / pipewire integration. Is there anything else (besides using something full blown OBS)?
kit89 4 Jul 2022
Pipewire should act as a PulseAudio system.

If you type:

 
pactl info


You should see something around the lines of:

 
Server Name: PulseAudio (on PipeWire 0.3.53)
Server Version: 15.0.0
Default Sample Specification: float32le 2ch 48000Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-MOTU_M4_M4AE0CDBMD-00.analog-surround-40


If you do, then following the documentation here: https://trac.ffmpeg.org/wiki/Capture/PulseAudio should be fine.

I tested this with my own machine and it works as expected.
Shmerl 4 Jul 2022
That's for audio. I need to capture the screen. OBS works, but I was interested in something more lightweight.

Last edited by Shmerl on 4 Jul 2022 at 8:53 pm UTC
kit89 4 Jul 2022
This documentation shows how to use ffmpeg to capture the screen: https://trac.ffmpeg.org/wiki/Capture/Desktop

You can capture both audio and the screen with one command operation, or you can trigger screen and audio capture independently and then mix the two together later with a Video Editor.
Shmerl 4 Jul 2022
Nah, no good either. x11grab is X11 only obviously. And they don't have Pipewire integration. The only other option is kmsgrab, but that had some kind of issue with pixel format.
Shmerl 5 Jul 2022
I ended up using OBS for now. It works very well actually. I'm surprised there no some CLI tool for that though.

Last edited by Shmerl on 5 Jul 2022 at 3:43 am UTC
LilaBortz 15 Jul 2022
I am using GNOME to capture the screen. Because it is the quick and easiest way to record your screen. But it doesn't record any sound tho.
Shmerl 27 Feb 2024
Any news on this? I'm trying to figure out if ffmpeg can capture the screen through pipewire or it's still lagging behind with that? OBS can already do it.
whizse 27 Feb 2024
Doesn't seeem to be a priority Feature request with zero replies here:
https://trac.ffmpeg.org/ticket/10742
peta77 27 Feb 2024
Does SimpleScreenRecorder support wayland nowadays? I don't know and the SSR-Homepage doesn't say anything about it. Haven't looked at the source either.
But it's simple and does wonderfully capture screen and audio.
Shmerl 27 Feb 2024
I need ffmpeg specifically since it's not just for recording a screen, I want to stream a window over LAN.

OBS can do it, but there are issues with that too.

Last edited by Shmerl on 27 Feb 2024 at 3:12 pm UTC
peta77 27 Feb 2024
SSR uses ffmpeg or libav (depending on availability) under the hood, so if you're willing to dig through the source code it may help you to acquire the command line options....
whizse 27 Feb 2024
kmsgrab is probably the only way to do it using only ffmpeg. You can crop the recording to only the location of the window you want. Something like this works for me:

ffmpeg -device /dev/dri/card0 -f kmsgrab -framerate 60 -i - -vaapi_device /dev/dri/renderD128 -vf 'hwmap=derive_device=vaapi,crop=1434:650:974:774,scale_vaapi=w=1435:h=650:format=nv12' -c:v hevc_vaapi -qp 18 -y output-file.mkv

But it's downright messy. You need to figure out the window co-ordinates and the drivers seem very picky. Notice that the scale width is 1 pixel wider than the crop. I get a ton of errors and video full of noise without it...
whizse 27 Feb 2024
Does SimpleScreenRecorder support wayland nowadays? I don't know and the SSR-Homepage doesn't say anything about it. Haven't looked at the source either.
But it's simple and does wonderfully capture screen and audio.
From perusing the Github issue tracker it seems to be X11 only, and development seems to be in maintenance mode for now. A pity since it seems to be quite useful!
Shmerl 27 Feb 2024
kmsgrab is probably the only way to do it using only ffmpeg

KDE developers say to avoid kmsgrab, it's just completely not suitable for the task and will get even more broken as they explain. Too bad ffmpeg doesn't yet implement pipewire screen capture.

I tried it and it didn't even work in the first place. Too many issues to dig into the method that's wrong anyway.

Last edited by Shmerl on 27 Feb 2024 at 5:33 pm UTC
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register