Dolby TrueHD passthrough - modified mpv build

Dolby TrueHD passthrough - modified mpv build


As some of you may have noticed, passing through Dolby TrueHD content can be hit or miss - some files work, others won’t - this build tries to fix this under specific circumstances.

Why is the current mpv lib broken?

Well, 3 years ago I opened a bug report on the FFmpeg bug tracker site°1 because I noticed a bug with the passthrough logic. When playing back movie files containing a TrueHD track that exceeds a bitrate of 11mbit the player would stop or crash. Time has passed and the issue was “fixed” - well playing back files with a bitrate over 11mbit works fine now but other issues have been introduced by this - which makes TrueHD passthrough nearly unusable. To name two, scrubbing does not work reliably - audio stops when skipping inside the file… Or playing back a file that stems from a source where seamless branching was needed, audio will stop when it hits such a spot.

To address this, I opened a new bug report on the FFmpeg bug track site°2, but nobody seems to care…


How is this fixed?

There are two types of fixes:

  1. Actual fix
    This fix incorporates a code change made by @gbooker02 to possibly fix the TrueHD passthrough problem.
    The code change can be found here =>
    Potential TrueHD FFmpeg Passthrough Fix · GitHub
    The rest of the(/libavformat/spdifenc.c) file is kept up-to-date so it stays compatible with upstream FFmpeg. The total modified spdifenc.c file can be found here => FFmpeg/libavformat/spdifenc.c at master-3 · mitzsch/FFmpeg · GitHub

  2. Revert to the original TrueHD logic
    All I have done here is revert these truehd-related commits, and keep the rest of the file(/libavformat/spdifenc.c) up-to-date - so it stays compatible with upstream FFmpeg.
    The modified “original TrueHD logic” spdifenc.c file can be found here:
    FFmpeg/libavformat/spdifenc.c at master-2 · mitzsch/FFmpeg · GitHub


What does not work with this build?

  1. Actual fix build
    This build may show some weird behavior with seamless branching files on some receivers. (dropouts…)

  2. Revert to the original TrueHD logic
    Files with a TrueHD bitrate over 11mbit will not work, playback will be stuck.


Where to find the builds?

Modified mpv builds with the actual TrueHD fix can be found here:

Note: This repo only contains “actual TrueHD fix” releases.
If you need builds with the “reverted TrueHD logic” write me a PM and I will send you a build. I build them for myself, as I mainly use them.


How to install?

Follow this guide => HTPC Tips and Tricks - #3 by gbooker02


CAVE!

With every update of Plex HTPC the libmpv-2.dll gets overwritten and needs to be replaced again.
The user @Harze2k wrote a PowerShell script to automate this process. It checks for updates and replaces the libmpv-2.dll if necessary.
It can be found here => Script to automatically check/update both plex htpc and mitzsch's mpv with TrueHD support


Note about HDR - breaking change!

Starting with build 2025-07-30 17:57 ( Release 2025-07-30 17:57 · mitzsch/mpv-winbuild · GitHub ) the libmpv-2.dll now includes the newly introduced “–target-colorspace-hint-mode” option. This defaults to mpv doing the tonemapping and not the display (= no metadata passthrough). To restore the old behavior, add target-colorspace-hint-mode=source to your mpv.conf!


Linked sites:
°1 Making sure you're not a bot!
°2 Making sure you're not a bot!

Have fun with proper TrueHD playback!

4 Likes

Updated modified build:
mpv-dev-x86_64-v3-20220824-git-89cab5c
mpv-dev-x86_64-v3-20220824-git-89cab5c-old-truehd-spdifenc.zip (29,4 MB)

1 Like

Updated modified build:
mpv-dev-x86_64-v3-20221014-git-59fc8ee
mpv-dev-x86_64-v3-20221014-git-59fc8ee-old-truehd-spdifenc.zip (29,6 MB)

3 Likes

###EDIT: Somehow I messed up the merge of the linked github commit and therefore the UI overlay will not work. I will provide a new build soon!

Updated modified build:
mpv-dev-x86_64-v3-20221108-git-2e5d0d6

https://drive.google.com/file/d/10LDOZgA9QZJ0nnDSGDapy00FnhspOh8l/view?usp=sharing
Use links in newer posts

(This time I can only provide the build via google drive because of file size limitations)

1 Like

###I hope this time it works…

Updated modified build:
mpv-dev-x86_64-v3-20221108-git-1e9a2cb

https://drive.google.com/file/d/1s81f_UU3PpND8hQXp384-oRAXZVkIhdT/view?usp=share_link

2 Likes

I have noticed that quite a lot. multiple skips are required to get the audio back. :frowning:

What is odd is I’ve only ever seen this back when I used a computer with HDMI 2.0 ports but an AVR that was HDMI 1.4. Before I upgraded the computer I used one that was HDMI 1.4 and it worked fine. After I upgraded the AVR to one that does HDMI 2.1, it worked fine with the new computer. Though at least it worked that much in Windows which couldn’t be said for Linux when the computer/AVR was HDMI 2.0/1.4.

This sounds like a different issue. Was there anything printed in the logs? With this issue here you see many lines stating this =>

[ffmpeg] spdif: Unusual frame timing: 40872 => 18920, 40 samples/frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature that has not been implemented.
[ffmpeg] spdif: If you want to help, upload a sample of this file to https://streams.videolan.org/upload/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)

Could be a different issue as I didn’t see anything printed in the logs during those instances.

I examined my logs and I see something similar to you but I don’t recall any audio drops during that time.

Also when skipping multiple times inside the file? Sometimes it works but the next skip will break the audio… I hope it’s not like the issue we had with DTS-HD HRA passthrough where it worked only on some AVRs but not on others, because of different implementations made by the manufacturer. (In the end, there was an mpv fix)

1 Like

I don’t get audio drops when seeking around in the file. I did with my old AVR but as I stated I think that was an HDMI 1.4 thing with it.

Onkyo TX-SR393 here.

With TrueHD audiotracks I frequently lose audio when skipping - and at least one more skip is needed to get audio back.

With MediaPortal I did not have that issue, Kodie suffered from it quite heavily.

Plex HTPC has the problem too:

  • after a skip it takes at least 1 second for the audio to return
  • with every skip there is a 1 in 3 chance I dont get any audio after the skip
  • when here is no audio after a skip I must skip again to get it back.

with the modified mpv from @Mitzsch

  • audio comes back much faster after a skip
  • audio never drops out after a skip
1 Like

@Mitzsch It would be helpful for us if you could link the exact diff you use for this along with a link to a specific sample file that you know causes the issue (preferably a short one).

Sure!

I hope it’s fine if I just upload my modified spdifenc.c file. I´m maintaining it offline so, unfortunately, no github repo with a nice diff view.

You can basically use every TrueHD file you have or use a sample from over here => Samples - Official Kodi Wiki
I have also sent you a short extract (11s) from a movie via pm that also exhibits this issue just by being played. It stems from a bluray where the theatrical cut and the director cut were on the same disc and therefore the rip needed seamless branching.

spdifenc.zip (6,0 KB)

Have you tried my build? If yes, have you noticed different behavior?

1 Like

Can you please share one of your Plex HTPC logs where the issue is present? Let’s see if it shows the error message unusual frame timing.

It´s also interesting that you also see the issue in Kodi, as they have fixed it a long time ago.

For Mediaportal I have no idea why it works correctly, maybe they use LavFilters. (They also include a fix) If they would use upstream FFmpeg, it would probably show the same issue we have with mpv/Plex HTPC.

Will do, should have time for this tomorrow.

I had that issue constantly with Kodi, but I switched to Plex almost 2 years ago.
The build I used was also not the latest due to compatibility issues with the skin I liked - so I suppose my build did not have that fix.
I could try to grab the latest Kodie version and see if it works with that now.

Yeah, MediaPortal ships with LAVf as default codecs for video&audio and has its own “MediaPortal AudioRenderer”.

Here is the log.
Resumed the movie → audio played
skip → no audio
skip → no audio
skip → audio is back
Plex HTPC.log (1.7 MB)

After the skip I do see the error @Mitzsch mentioned

Nov 21, 2022 22:13:38.052 [6780] WARN - [MPVEngine/mpv] ffmpeg: spdif: Unusual frame timing: 18864 => 53180, 40 samples/frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.

Current Kodi v20 does not have this issue.

Below is the audio data from the movie.

Audio #1
ID                                       : 2
ID in the original source medium         : 4353 (0x1101)
Format                                   : MLP FBA 16-ch
Format/Info                              : Meridian Lossless Packing FBA with 16-channel presentation
Commercial name                          : Dolby TrueHD with Dolby Atmos
Codec ID                                 : A_TRUEHD
Duration                                 : 2 h 10 min
Bit rate mode                            : Variable
Bit rate                                 : 4 187 kb/s
Maximum bit rate                         : 7 197 kb/s
Channel(s)                               : 8 channels
Channel layout                           : L R C LFE Ls Rs Lb Rb
Sampling rate                            : 48.0 kHz
Frame rate                               : 1 200.000 FPS (40 SPF)
Compression mode                         : Lossless
Stream size                              : 3.81 GiB (5%)
Title                                    : Deutsch 7.1 TrueHD
Language                                 : German
Default                                  : Yes
Forced                                   : No
Original source medium                   : Blu-ray
Number of dynamic objects                : 11
Bed channel count                        : 1 channel
Bed channel configuration                : LFE

Thanks for providing the log! I just looked through it and it shows exactly what I would have expected. So you also suffer from the exact same issue I have encountered.

1 Like

New build:
mpv-dev-x86_64-v3-20221126-git-e97e0e4

The build above might be broken due to an FFmpeg issue. Use this build instead =>
mpv-dev-x86_64-v3-20221126-git-e97e0e4

@gbooker02
Have you been able to take a look at the uploaded spdifenc.c file and my provided sample?