https://bugs.kde.org/show_bug.cgi?id=525050

            Bug ID: 525050
           Summary: h264vaapiencoder: only attach DRM hardware context to
                    input filter
    Classification: Frameworks and Libraries
           Product: KPipeWire
      Version First 6.7.4
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

Created attachment 195642
  --> https://bugs.kde.org/attachment.cgi?id=195642&action=edit
Fix VAAPI filter context overwrite in H264VAAPIEncoder::initialize

DESCRIPTION
When attempting to stream or record video using the h264_vaapi hardware encoder
in KPipeWire (such as with krdpserver or Spectacle on Wayland), frame filtering
fails immediately on the first frame with:
"Failed receiving filtered frame: Input/output error" followed by the filter
queue filling up and dropping all subsequent frames.

STEPS TO REPRODUCE
1. Start KRDP server or KPipeWire recording on a Wayland session with Intel
VAAPI hardware: KPIPEWIRE_FORCE_ENCODER=h264_vaapi krdpserver
 2. Connect to the session via an RDP client (e.g. FreeRDP / Microsoft Remote
Desktop).
 3. Observe the terminal output / journal logs.

OBSERVED RESULT
Encoding fails with Input/output error on the first frame:
krdpserver: Failed receiving filtered frame: Input/output error
krdpserver: Filter queue is full, dropping frame 132647399


EXPECTED RESULT
Frames should be encoded cleanly through the VAAPI hardware filter pipeline
without I/O errors or frame drops.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux (Linux x86_64)
KDE Plasma Version: 6.7.4
KDE Frameworks Version: 6.29.0
Qt Version: 6.11.2


ADDITIONAL INFORMATION
Fix: Only assign m_drmContext to m_inputFilter, allowing
hwmap=mode=direct:derive_device=vaapi to properly propagate the derived
AV_HWDEVICE_TYPE_VAAPI context downstream:

    --- a/src/h264vaapiencoder.cpp
    +++ b/src/h264vaapiencoder.cpp
    @@ -106,9 +106,7 @@ bool H264VAAPIEncoder::initialize(const QSize &size)
             return false;
         }

    -    for (auto i = 0u; i < m_avFilterGraph->nb_filters; ++i) {
    -        m_avFilterGraph->filters[i]->hw_device_ctx =
av_buffer_ref(m_drmContext);
    -    }
    +    m_inputFilter->hw_device_ctx = av_buffer_ref(m_drmContext);

         ret = avfilter_graph_config(m_avFilterGraph, nullptr);
         if (ret < 0) {

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to