From db490dbaf75b33f7fed59d9f89a0d5d209420dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 22 Jan 2023 19:29:23 +0100 Subject: [PATCH] screencastService: Add gstreamer pipeline for h264 encoding Add pipelinea for h264 software encoding using openh264. This is the least problematic (from a patent perspective) software encoder for h264, Fedora ships it in a pre-installed repo and it can be enabled very easily. Most people should have it enabled already to allow for decoding of h264 content. Unlike vp8enc, this encoder is optimized for realtime and is really fast, it outperforms the vp8 encoder by an order of magnitude and should allow for smooth recordings even on older hardware. The reason why mp4 was chosen as a container format over mkv is that mp4 can be played inside firefox and chromium, whereas mkv can't be played. It's ensured that the mp4 file is still playable in case the recording got cancelled by using the "first-moov-then-finalise" fragment-mode on mp4mux. Even though h264 is problematic from a patent perspective and often can't be shipped by default, it still the best supported and most popular codec out there. The software encoders and decoders are really fast, it's used everywhere on the web, and it can be hardware decoded on almost any device out there. See also: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2080 https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7335 Part-of: --- .../screencast/screencastService.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/js/dbusServices/screencast/screencastService.js b/js/dbusServices/screencast/screencastService.js index ac0e461c6..d664a51b0 100644 --- a/js/dbusServices/screencast/screencastService.js +++ b/js/dbusServices/screencast/screencastService.js @@ -31,6 +31,30 @@ const DEFAULT_DRAW_CURSOR = true; const PIPELINE_BLOCKLIST_FILENAME = 'gnome-shell-screencast-pipeline-blocklist'; const PIPELINES = [ + { + id: 'swenc-dmabuf-h264-openh264', + fileExtension: 'mp4', + pipelineString: + 'capsfilter caps=video/x-raw(memory:DMABuf),max-framerate=%F/1 ! \ + glupload ! glcolorconvert ! gldownload ! \ + queue ! \ + openh264enc deblocking=off background-detection=false complexity=low adaptive-quantization=false qp-max=26 qp-min=26 multi-thread=%T slice-mode=auto ! \ + queue ! \ + h264parse ! \ + mp4mux fragment-duration=500 fragment-mode=first-moov-then-finalise', + }, + { + id: 'swenc-memfd-h264-openh264', + fileExtension: 'mp4', + pipelineString: + 'capsfilter caps=video/x-raw,max-framerate=%F/1 ! \ + videoconvert chroma-mode=none dither=none matrix-mode=output-only n-threads=%T ! \ + queue ! \ + openh264enc deblocking=off background-detection=false complexity=low adaptive-quantization=false qp-max=26 qp-min=26 multi-thread=%T slice-mode=auto ! \ + queue ! \ + h264parse ! \ + mp4mux fragment-duration=500 fragment-mode=first-moov-then-finalise', + }, { id: 'swenc-dmabuf-vp8-vp8enc', fileExtension: 'webm',