<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Technical Writes by Dee]]></title><description><![CDATA[Technical Writes by Dee]]></description><link>https://blogs.deezyboi.space</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1767217599663/77a1f1be-6460-464e-978f-09714b7708c1.png</url><title>Technical Writes by Dee</title><link>https://blogs.deezyboi.space</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 22:55:24 GMT</lastBuildDate><atom:link href="https://blogs.deezyboi.space/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Debugging MPV Hardware Decoding on Hybrid Intel–NVIDIA Systems (Wayland, Ubuntu): A Step-by-Step Debugging Journey]]></title><description><![CDATA[Overview
Who am I? Just a regular guy who loves watching movies. I also tend to dig into the technical side of everyday problems — but I’m usually too lazy to actually solve them. A few months ago, I ran into an issue while trying to play a media fil...]]></description><link>https://blogs.deezyboi.space/debugging-mpv-hardware-decoding-on-hybrid-intelnvidia-systems-wayland-ubuntu-a-step-by-step-debugging-journey</link><guid isPermaLink="true">https://blogs.deezyboi.space/debugging-mpv-hardware-decoding-on-hybrid-intelnvidia-systems-wayland-ubuntu-a-step-by-step-debugging-journey</guid><category><![CDATA[AV1]]></category><category><![CDATA[FFmpeg]]></category><category><![CDATA[mpv]]></category><category><![CDATA[GPU]]></category><dc:creator><![CDATA[Dhireen Kumar Rajak]]></dc:creator><pubDate>Thu, 23 Oct 2025 00:30:52 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-overview">Overview</h1>
<p>Who am I? Just a regular guy who loves watching movies. I also tend to dig into the technical side of everyday problems — but I’m usually too lazy to actually solve them. A few months ago, I ran into an issue while trying to play a media file. That’s when I realized my system wasn’t too friendly with AV1-encoded videos.</p>
<p>So, what did I do? Well, since I have a dual-boot setup, I simply switched over to Windows to play it. (Don’t judge!) But honestly, how long could I keep doing that? It was <em>incredibly</em> inconvenient to switch OSes just to watch a movie.</p>
<p>A few days ago, I finally decided to dig deeper. At first, I looked online to see if others had the same issue. I had tried that before — back when the problem first appeared — but didn’t find any promising solutions. That’s why I kept relying on my quick “boot to Windows” workaround.</p>
<p>This time, though, I was serious. My inner engineer refused to stay quiet. And that’s how this debugging journey began. In this article, I’ll take you along with me — step by step — through how I diagnosed and finally solved what seemed like a complex issue that turned out to be surprisingly tricky but simple af.</p>
<h1 id="heading-introduction">Introduction</h1>
<h2 id="heading-problem-statement">Problem Statement</h2>
<p>I had this <code>.mkv</code> video file encoded with the shiny new <strong>AV1 codec</strong>, and for some reason, it just refused to play on my Ubuntu machine — even though I already had <code>mpv</code> and <code>ffmpeg</code> installed. The player would <strong>either crash</strong> or refuse to open the file. Was it a codec issue, a player quirk, or something weird going on with GPU hardware decoding behind the scenes?</p>
<h2 id="heading-system-overview">System Overview</h2>
<p>Here’s a brief summary of my setup:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Component</strong></td><td><strong>Details</strong></td></tr>
</thead>
<tbody>
<tr>
<td>OS</td><td>Ubuntu 24.04 LTS (Wayland)</td></tr>
<tr>
<td>Kernel</td><td>Linux 6.14.0-33-generic</td></tr>
<tr>
<td>MPV</td><td>0.37.0</td></tr>
<tr>
<td>FFmpeg</td><td>6.1.1</td></tr>
<tr>
<td>GPU</td><td>Intel iGPU + NVIDIA RTX 3050</td></tr>
<tr>
<td>Drivers</td><td>NVIDIA 570.172.08, CUDA 12.8</td></tr>
</tbody>
</table>
</div><h1 id="heading-investigation-process-the-journey">Investigation Process - The Journey</h1>
<h3 id="heading-check-mpv-amp-ffmepeg-build-info">Check MPV &amp; FFmepeg Build Info</h3>
<p>Some Ubuntu systems, especially if using <strong>older media players</strong> or missing certain libraries — <strong>don’t support AV1 playback natively</strong>. Although I had done basic installation of both the software and as my OS and Kernel not that old, I knew there must be support for AV1.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760186716460/b8f33c3b-50b6-40e6-94a0-0b3ae1ec57ae.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760186992134/55aa0def-c571-4346-b377-6d3c986dc11c.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">ffmpeg -codecs | grep av1
---Notable OUTPUT---
WARNING: library configuration mismatch
...
DEV.L. av1         Alliance <span class="hljs-keyword">for</span> Open Media AV1 (decoders: libdav1d libaom-av1 av1 av1_cuvid av1_qsv) (encoders: libaom-av1 librav1e libsvtav1 av1_nvenc av1_qsv av1_vaapi)
DEAIL. wmav1       Windows Media Audio 1
</code></pre>
<p>FFmpeg build does include <strong>AV1 decoding support,</strong> thus FFmpeg and MPV can handle AV1 — at least from a codec capability perspective.</p>
<p>As for the <strong>WARNING</strong> message, initially I thought MPV might be loading mismatched libraries but this message is common to have after upgrades. Trust me, I did the clean re-installation, the warning was gone for a new start. However, it recurred after few reboots.</p>
<p>Just in case if you would like to perform clean re-install:</p>
<pre><code class="lang-bash">sudo apt purge ffmpeg mpv -y
sudo apt autoremove -y
sudo apt update
sudo apt install ffmpeg mpv -v
ffmpeg --version &amp;&amp; mpv --version
</code></pre>
<h3 id="heading-check-if-ffmpeg-can-decode-it-manually">Check if FFmpeg can Decode it Manually</h3>
<pre><code class="lang-bash">ffmpeg -v error -i yourfile.mkv -f null -
</code></pre>
<p>This will attempt to decode the entire video to <code>/dev/null</code>. If you see <strong>no errors,</strong> FFmpeg can decode it fine — the issue is purely in playback. If there’s a decoding error at this step its because the file is corrupted or encoded with an unsupported AV1 profile like 10-bit.</p>
<p><strong>Inspect Video Stream Details</strong>:</p>
<pre><code class="lang-bash">ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,profile,pix_fmt,width,height,bit_rate -of default=nw=1 yourfile.mkv
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760188492914/9554c9b2-1f92-4f0a-b7bc-ff60709a7830.png" alt class="image--center mx-auto" /></p>
<p>Therefore, my media file is a <strong>10-bit AV1 video (</strong><code>pix_fmt=yuv420p10le</code><strong>)</strong>, so software decoders like <code>libdav1d libaom-av1</code> should easily handle it. I did this step out of curiosity as I read somewhere that some GPU-accelerated pipelines can’t handle 10-bit AV1 video file yet. So I just wanted to check that it.</p>
<h3 id="heading-check-mpv-logs">Check MPV logs</h3>
<pre><code class="lang-bash">mpv -v yourfile.mkv | tee mpv.log
---Notable OUTPUT---
[vo/gpu/wayland] GL_VENDOR=<span class="hljs-string">'Intel'</span>
[vo/gpu/wayland] GL_RENDERER=<span class="hljs-string">'Mesa Intel(R) Graphics (ADL GT2)'</span>
...
[vd] Opening decoder libdav1d
[vd] Looking at hwdec av1-vaapi...
[vo/gpu] Loading hwdec drivers <span class="hljs-keyword">for</span> format: <span class="hljs-string">'vaapi'</span>
[vo/gpu] Loading hwdec driver <span class="hljs-string">'vaapi'</span>
...
[vd] Pixel formats supported by decoder: cuda vaapi vdpau vulkan yuv420p10le
...
[ffmpeg/video] av1: Failed to end picture decode issue: 23 (internal decoding error).
[ffmpeg/video] av1: HW accel end frame fail.
[vd] Error <span class="hljs-keyword">while</span> decoding frame (hardware decoding)!
</code></pre>
<p>Well this log was full of informational details I needed. Lets see what did I find out:</p>
<ul>
<li><p>Intel integrated graphic was used as renderer. While Alder Lake does support <strong>AV1 hardware decoding,</strong> it depends on:</p>
<ul>
<li><p>The <strong>driver stack, VAAPI version, Wayland/X11 compositor setup</strong></p>
</li>
<li><p>Many systems with Intel iGPUs hit issues like <strong>black screen, freeze, or no output</strong> when AV1 VAAPI decoding is attempted — especially under <strong>Wayland.</strong></p>
</li>
</ul>
</li>
<li><p>My guess, MPV loads VAAPI → Wayland → EGL → dmabuf interop → hardware AV1 decoder. This is where it likely stops showing video — the FPU driver fails silently.</p>
</li>
<li><p>Hence, problem = <strong>VAAPI hardware docoding of AV1 under Intel-iGPU + Wayland combo.</strong></p>
</li>
</ul>
<p><mark>This is where the problem statement got real clear.</mark></p>
<h3 id="heading-switch-to-nvidia">Switch to NVIDIA</h3>
<p><strong>Confirm which GPU is active:</strong></p>
<pre><code class="lang-bash">glxinfo | grep <span class="hljs-string">"OpenGL renderer"</span>
</code></pre>
<p>If it says something like <code>OpenGL renderer string: Mesa Intel(R) Graphics …</code> then your session (<code>wayland or X</code>) is currently using the Intel GPU, not NVIDIA.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760684347798/ccf1ae27-3134-4bae-aaf4-350fb9c14da8.png" alt class="image--center mx-auto" /></p>
<p><strong>Lets check GPU and Driver Stack</strong></p>
<pre><code class="lang-bash">vainfo | grep -i av1
ffmpeg -hwaccels
ffmpeg -decoders | grep av1
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760686287550/b9d92e04-a8b4-4880-85ae-8b823b8a7a26.png" alt class="image--center mx-auto" /></p>
<p>If <code>vainfo</code> lists only Intel devices, it means the NVIDIA VAAPI driver (rarely used) isn’t active. That’s expected;</p>
<p>If you see <code>cuda</code>, <code>vulkan</code>, or <code>vaapi</code> in the list, good — the driver stack is okay.</p>
<p>Lastly, check that <code>ffmpeg</code> recognizes the NVIDIA AV1 decoder.</p>
<p><strong>Test playback directly via NVIDIA</strong></p>
<pre><code class="lang-bash">DRI_PRIME=1 mpv --hwdec=cuda --vo=gpu-next --gpu-api=opengl --gpu-context=waylandvk <span class="hljs-string">"censored-name.mkv"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760687078988/890f330e-3db2-43a9-bfe0-363aa4909380.png" alt class="image--center mx-auto" /></p>
<p>This means mpv <strong>found the NVIDIA GPU (via</strong> <code>DRI_PRIME=1</code>) but <strong>couldn’t create a rendering context under Wayland</strong> — because Wayland + NVIDIA is still finicky with OpenGL/Vulkan interop.</p>
<p><strong>Test with the safer X11 EGL path</strong></p>
<pre><code class="lang-bash">DRI_PRIME=1 mpv --hwdec=cuda --vo=gpu-next --gpu-context=x11egl <span class="hljs-string">"censored-name.mkv"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760688383361/1cea2117-b588-4751-8457-3583c0d8a2d2.png" alt class="image--center mx-auto" /></p>
<p>This forces mpv to use an XWayland bridge to talk to the NVIDIA GPU.</p>
<ul>
<li><p>mpv successfully detects the <strong>video</strong>, <strong>audio</strong>, and <strong>subtitle</strong> tracks.</p>
</li>
<li><p>The <strong>libEGL warning</strong> (<code>failed to create dri2 screen</code>) and <strong>CUDA_ERROR_INVALID_GRAPHICS_CONTEXT</strong> indicate a <strong>context mismatch</strong> — CUDA tried to access OpenGL through the wrong display backend (likely Wayland instead of X11).</p>
</li>
<li><p>The note <code>CUDA hwdec only works with OpenGL or Vulkan backends</code> explains the failure reason.</p>
</li>
<li><p>Despite that, mpv still falls back to <strong>software rendering</strong></p>
</li>
</ul>
<p><mark>Now, I am sure its a </mark> <strong><mark>context mismatch</mark></strong> <mark>issue.</mark></p>
<p><strong>Fixing GPU context mismatch</strong></p>
<pre><code class="lang-bash">__GLX_VENDOR_LIBRARY_NAME=nvidia mpv --hwdec=cuda --vo=gpu-next --gpu-context=waylandvk <span class="hljs-string">"censored-name.mkv"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760688971283/aa79b893-19c6-4c0d-a2fd-0e4535c8e486.png" alt class="image--center mx-auto" /></p>
<p>Finally It worked !! This plays the video with now errors or warnings.</p>
<p>Wayland sessions and NVIDIA drivers don’t always automatically set the correct OpenGL vendor path.<br />The variable <code>__GLX_VENDOR_LIBRARY_NAME=nvidia</code> forces MPV (and the GLX stack) to use the NVIDIA OpenGL library instead of Mesa (Intel/AMD). This fixed the “invalid OpenGL or DirectX context” errors.</p>
<hr />
<h1 id="heading-final-solution">Final Solution</h1>
<p>For convenience you can make this your default MPV configuration so you don’t have to type it each time.</p>
<pre><code class="lang-bash">vi ~/.config/mpv/mpv.conf
---Add below configurations---
hwdec=cuda
vo=gpu-next
gpu-context=waylandvk

vi ~/.config/environment.d/99-nvidia.conf
---Add below configurations---
__GLX_VENDOR_LIBRARY_NAME=nvidia

---REBOOT System---
Enjoy your media file.
</code></pre>
<p><strong>What</strong> <code>~/.config/environment.d/</code> <strong>is —</strong> This directory is part of <strong>systemd’s user environment mechanism</strong>.<br />Anything you put as <code>.conf</code> files here (with <code>KEY=value</code> pairs) gets automatically loaded <strong>into your user session environment</strong>, <em>before</em> applications start.</p>
<hr />
<h1 id="heading-conclusion">Conclusion</h1>
<p>What started as <em>“why won’t this stupid file play”</em> turned into a journey through drivers, GPU contexts, and environment tweaks — and I learned more about the Linux graphics stack in one evening than I had in months.</p>
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://ffmpeg.org/documentation.html">https://ffmpeg.org/documentation.html</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mpv-player/mpv/issues/15980">https://github.com/mpv-player/mpv/issues/15980</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mpv-player/mpv/issues/10854">https://github.com/mpv-player/mpv/issues/10854</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/mpv-player/mpv/issues/372">https://github.com/mpv-player/mpv/issues/372</a></p>
</li>
<li><p><a target="_blank" href="https://wiki.archlinux.org/title/Hardware_video_acceleration">https://wiki.archlinux.org/title/Hardware_video_acceleration</a></p>
</li>
<li><p><a target="_blank" href="https://developer.nvidia.com/video-codec-sdk">https://developer.nvidia.com/video-codec-sdk</a></p>
</li>
</ul>
<h2 id="heading-lesson-learned">Lesson Learned</h2>
<ul>
<li><p>Try to step out of the comfort box, being lazy dosen’t solve things.</p>
</li>
<li><p>Problems seems hard until its well understood.</p>
</li>
<li><p>Data Flow : MPV → FFmpeg → CUDA/NVDEC → NVIDIA GPU → Display (Wayland</p>
</li>
<li><p>Logs are the goto debugging checkpoints.</p>
</li>
<li><p>PS: This is my 1st time writing a technical article, thus open to take suggestion to improve the structure and writing.</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>