From e943d0ca542b4e4f4c458165fdcdc8e413c3d2a5 Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Mon, 22 Apr 2024 00:29:34 +0200 Subject: [PATCH] Record: support MagicYUV 4:4:4 The two codecs currently supported, H264 and WebM are not suitable for recording with minimal CPU overhead and losslessly for farther editing or archiving. This changeset adds support for recording in MagicYUV 4:4:4 in a Matroska container. This is suitably fast and satisfies the lossless goal, while still having some compression. These can be transcoded to FFV1 with no quality loss offline. --- src/pipewirerecord.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pipewirerecord.cpp b/src/pipewirerecord.cpp index ac8132e..232bbd6 100644 --- a/src/pipewirerecord.cpp +++ b/src/pipewirerecord.cpp @@ -301,10 +301,14 @@ void PipeWireRecordProduce::setupStream() m_avCodecContext->height = size.height(); m_avCodecContext->max_b_frames = 1; m_avCodecContext->gop_size = 100; - if (m_codec->pix_fmts && m_codec->pix_fmts[0] > 0) { - m_avCodecContext->pix_fmt = m_codec->pix_fmts[0]; + if (QStringLiteral("magicyuv") == QString::fromUtf8(m_encoder)) { + m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV444P; } else { - m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P; + if (m_codec->pix_fmts && m_codec->pix_fmts[0] > 0) { + m_avCodecContext->pix_fmt = m_codec->pix_fmts[0]; + } else { + m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P; + } } m_avCodecContext->time_base = AVRational{1, 1000}; @@ -462,7 +466,7 @@ QByteArray PipeWireRecord::encoder() const QList PipeWireRecord::suggestedEncoders() const { - QList ret = {"libvpx", "libx264"}; + QList ret = {"libvpx", "libx264", "magicyuv"}; std::remove_if(ret.begin(), ret.end(), [](const QByteArray &encoder) { return !avcodec_find_encoder_by_name(encoder.constData()); }); -- 2.43.2