Gif screen recording in Wayland environment

When I was writing some interesting functions of Firefox yesterday, I needed to demonstrate some ui operation steps. At this time, the screenshots are not clear enough to record the process. I think that there are often some gif pictures on Github to demonstrate the operation steps. I used the command line to combine two pictures to produce a A gif picture is also possible, a little troublesome. In this scenario, recording the steps of the screen and then generating a gif image is an ideal way. Of course, it is also possible to embed videos on the website, but many platforms do not support video uploads. For simple web tutorials, pictures are more suitable.

1. Dying Throes

In the current Linux ecosystem, peek and Kooha are the mainstream software for recording screens and generating gifs. It is regrettable:

-peek

In my labwc environment, the gif recorded by installing peek is a black screen, nothing can be seen, and the author does not maintain it. For details, see [this statement](https://github.com/phw/peek/issues /1191).

-Kooha

When peek is invalid, there is no choice but to switch to Kooha. After finally installing the dependency package, an error is reported in the final compilation stage: the version of libadwaita-1 is wrong, and I am too lazy to compile and install, so I voluntarily gave up.

 1error: failed to run custom build command for `libadwaita-sys v0.4.1`
 2
 3Caused by:
 4   process didn't exit successfully: `/home/mephisto/github/Kooha/_build/src/release/build/libadwaita-sys-324727e752f0426f/build-script-build` (exit status: 1)
 5   ---stdout
 6   cargo:rerun-if-env-changed=LIBADWAITA_1_NO_PKG_CONFIG
 7   cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
 8   cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
 9   cargo:rerun-if-env-changed=HOST_PKG_CONFIG
10   cargo:rerun-if-env-changed=PKG_CONFIG
11   cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
12   cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
13   cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
14   cargo:rerun-if-env-changed=PKG_CONFIG_PATH
15   cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
16   cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
17   cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
18   cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
19   cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
20   cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
21   cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
22   cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
23   cargo:warning=`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "libadwaita-1" "libadwaita-1 >= 1.4"` did not exit successfully: exit status: 1
24   error: could not find system library 'libadwaita-1' required by the 'libadwaita-sys' crate
25
26   --- stderr
27   Package dependency requirement 'libadwaita-1 >= 1.4' could not be satisfied.
28   Package 'libadwaita-1' has version '1.3.3', required version is '>= 1.4'
29
30warning: build failed, waiting for other jobs to finish...
31[45/47] Generating data/io.github.seadve.Kooha.metainfo.xml with a custom command
32FAILED: src/kooha
33/usr/bin/env CARGO_HOME=/home/mephisto/github/Kooha/_build/cargo-home /home/mephisto/.cargo/bin/cargo build --manifest-path /home/mephisto/github/Kooha/Cargo. toml --target-dir /home/mephisto/github/Kooha/_build/src --release && cp src/release/kooha src/kooha
34ninja: build stopped: subcommand failed.

In particular, if the reader's environment can install peek/Kooha, I personally recommend using it directly, saving worry and effort.

2. The willows are dark and the flowers are bright

When I was about to use the imagemagick tool set again to make a gif image as shown below, I seemed to hear someone say: "You overflowed here, and there is a semicolon missing here, this is wrong...".

1convert -delay 100 -loop 0 *.jpeg animatedGIF.gif

At this point, I thought of wf-recorder, a simple and powerful screen recording tool. Maybe it can output not only mp4/webp, but also gif?

I looked through the Readme document, Ctrl + F searched for the gif keyword, and there was no matching result. Usually, in this case, a solid Linux user will not give up. Finally, search for gif in the issues list to find Know the real solution, refer to issue

You just need to do this from the command line:

1wf-recorder -f test.gif -c gif -g "$(slurp)"
  • slurp is actually another software that will let you choose the range, without this parameter, it will let you choose the screen (if you use multiple screens)
  • -c gif specifies the encoding (codec) format, without this parameter, the output test.gif will report an error.

In fact, there are related instructions in the wf-recorder help document, which is too hidden, and most people will not notice it.

-c, --codec Specifies the codec of the video. Supports GIF output also.

To modify codec parameters, use -p <option_name>=<option_value>

Example gif image (recorded for many seconds, size 792K):

test gif

Stop recording, press Ctrl + c, there will be an error, just ignore it.

1➜ ~ wf-recorder -f test.gif -c gif -g "$(slurp)"
2Detected output based on geometry: DP-1
3selected region 1936,44 1263x973
4Using video filter: null
5Output #0, gif, to 'test.gif':
6   Stream #0:0: Video: gif, bgr8(pc), 1262x972 [SAR 1:1 DAR 631:486], q=2-31, 200 kb/s
7^C[gif @ 0x7f031c000d40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1167 >= 1102
Lastmod: Monday, August 28, 2023

See Also:

Translations: