diff --git a/0001-record-Use-vp8-instead-of-x264.patch b/0001-record-Use-vp8-instead-of-x264.patch new file mode 100644 index 0000000..a0f9eac --- /dev/null +++ b/0001-record-Use-vp8-instead-of-x264.patch @@ -0,0 +1,64 @@ +From bfeb50c28c5282a451ca9e48ca6736e66de108a8 Mon Sep 17 00:00:00 2001 +From: Aleix Pol +Date: Mon, 30 Jan 2023 03:00:07 +0100 +Subject: [PATCH] record: Use vp8 instead of x264 + +Initially tried using vp9 but it's much slower in comparison and the videos +I get with this are acceptable. +It's better than x264 because it's easier to distribute by the different +distributions that ship our software. +--- + src/pipewirerecord.cpp | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +diff --git a/src/pipewirerecord.cpp b/src/pipewirerecord.cpp +index 385b59c..8098d33 100644 +--- a/src/pipewirerecord.cpp ++++ b/src/pipewirerecord.cpp +@@ -85,7 +85,7 @@ PipeWireRecord::PipeWireRecord(QObject *parent) + : QObject(parent) + , d(new PipeWireRecordPrivate) + { +- d->m_encoder = "libx264rgb"; ++ d->m_encoder = "libvpx"; + av_log_set_level(AV_LOG_DEBUG); + } + +@@ -220,7 +220,7 @@ void PipeWireRecordProduce::finish() + + QString PipeWireRecord::extension() + { +- return QStringLiteral("mp4"); ++ return QStringLiteral("webm"); + } + + void PipeWireRecordProduce::setupStream() +@@ -229,8 +229,8 @@ void PipeWireRecordProduce::setupStream() + disconnect(m_stream.get(), &PipeWireSourceStream::streamParametersChanged, this, &PipeWireRecordProduce::setupStream); + avformat_alloc_output_context2(&m_avFormatContext, nullptr, nullptr, m_output.toUtf8().constData()); + if (!m_avFormatContext) { +- qCWarning(PIPEWIRERECORD_LOGGING) << "Could not deduce output format from file: using MPEG." << m_output; +- avformat_alloc_output_context2(&m_avFormatContext, nullptr, "mpeg", m_output.toUtf8().constData()); ++ qCWarning(PIPEWIRERECORD_LOGGING) << "Could not deduce output format from file: using WebM." << m_output; ++ avformat_alloc_output_context2(&m_avFormatContext, nullptr, "webm", m_output.toUtf8().constData()); + } + if (!m_avFormatContext) { + qCDebug(PIPEWIRERECORD_LOGGING) << "could not set stream up"; +@@ -265,7 +265,13 @@ void PipeWireRecordProduce::setupStream() + } + m_avCodecContext->time_base = AVRational{1, 1000}; + +- if (avcodec_open2(m_avCodecContext, m_codec, nullptr) < 0) { ++ AVDictionary *options = nullptr; ++ av_dict_set_int(&options, "threads", 4, 0); ++ av_dict_set(&options, "preset", "ultrafast", 0); ++ av_dict_set(&options, "tune-content", "screen", 0); ++ av_dict_set(&options, "quality", "realtime", 0); ++ ++ if (avcodec_open2(m_avCodecContext, m_codec, &options) < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open codec"; + return; + } +-- +2.39.1 + diff --git a/kpipewire.spec b/kpipewire.spec index a45a4da..11da4d1 100644 --- a/kpipewire.spec +++ b/kpipewire.spec @@ -1,7 +1,7 @@ Name: kpipewire Summary: Set of convenient classes to use PipeWire in Qt projects Version: 5.26.90 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ URL: https://invent.kde.org/plasma/%{name} @@ -14,6 +14,10 @@ URL: https://invent.kde.org/plasma/%{name} %endif Source0: http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{version}.tar.xz +# Use VP8 on WebM instead of x264 on MP4 for screen recording by default +# Adapted from: https://invent.kde.org/plasma/kpipewire/-/merge_requests/20 +Patch0: 0001-record-Use-vp8-instead-of-x264.patch + BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: extra-cmake-modules @@ -99,6 +103,9 @@ developing applications that use %{name}. %{_libdir}/cmake/KPipeWire/*.cmake %changelog +* Mon Jan 30 2023 Neal Gompa - 5.26.90-3 +- Add patch to use VP8 on WebM for screen recording by default + * Thu Jan 26 2023 Neal Gompa - 5.26.90-2 - Add dependency on pipewire-devel for devel subpackage