mpv-player/mpv

Upmix 2.0 to 5.1

Obegg opened this issue · 32 comments

I've noticed that many of the video and audio files I play are 2.0 but I use surround sound system of 5.1.
I was thinking if it was possible to upmix from 2.0 to 5.1 in mpv settings or user script?
All I could find about it is this, but this is for Linux and not for WIndows.

Edit: I also want it to ONLY upmix when the audio file has 2 channels, no need to upmix when the audio source is 5.1.

Note: I have no issues playing DTS-HD MA or Dolby TrueHD files that have 6 or 8 channels, those are working fine,
mpv and Windows recognize I have surround sound system.

[upmix]
profile-cond=p["audio-params/channel-count"] < 6
profile-restore=copy
audio-channels=5.1

As long as the layout is supported by your audio device, --audio-channels should work without having to mess with pan filters.

This doesn't do any upmixing, by my understanding - --audio-channels only detemines which audio channels are accepted by mpv.

If setting the layout doesn't work then you'll have to apply an audio filter.

https://ffmpeg.org/ffmpeg-filters.html#surround

[upmix]
profile-cond=p["audio-params/channel-count"] < 6
profile-restore=copy
af=surround:chl_out=5.1

If you want to control the mixing of the audio channels individually, you'll have to apply a pan filter after upmixing the amount of channels from 2 -> 6.

audio-params/channel-count is not reliable.
#11541

The issue you linked seems to just be an issue with the order in which autoprofiles are processed (after everything in your mpv.conf has been set). Adding the downmix layout to the profile itself doesn't seem to cause any issues when switching between audio tracks mid-playback.

[louder_speaking]
profile-cond=p["audio-params/channel-count"]>2
profile-restore=copy
audio-channels=stereo
af-pre=@vocal:loudnorm

[louder_speaking-alt]
profile-cond=p["audio-params/channel-count"]<=2
profile-restore=copy
audio-channels=stereo
af-remove=@vocal

Also worth noting that this autoprofile quirk isn't really an issue with the default auto-safe anyways, or if you whitelist more than one layout.

af-pre=@vocal:loudnorm

mpv gives me the error:

[csplayer] Option af-remove: item label @vocal not found.

Uhm?

The only thing that seems to be doing anything is:

[upmix]
profile-cond=p["audio-params/channel-count"] < 3
af=surround:chl_out=7.1
profile-restore=copy

Uhm?

If there is no audio filter prepended to the list then there's nothing to remove.

af=surround:chl_out=7.1

This would only make sense if the 5.1 audio is mapping to side channels, since a 7.1 upmix would output to side speakers. Does --af=surround:chl_out=5.1(side) do anything? Or better yet, --audio-channels=5.1(side)?

You could also play around with pan filters.*

af=lavfi=[pan=5.1| FL = FL | FR = FR | LFE < 0.5*FL+0.5*FR | BL=FL | BR=FR]

*not really an optimal example, this would probably be a loud upmix

I'll further explain my setup.
I use Windows, I have 6 physical speakers (so 5.1), but on Windows I have the option to use 7.1 somehow so I chose it.
Using audio-channels=5.1(side) seems to not play any stereo file, I have no idea why.
Using af=surround:chl_out=7.1 seems to work fine and upmix successfully,

My only remaining questions are:

  1. On Windows I can set up the audio as 7.1, but in actual speaker count I only have 6, so it's a 5.1 system, should I really choose 7.1 or should I choose 5.1?
  2. The only thing that seems to be doing anything is af=surround:chl_out=7.1, I'm not familiar with audio filters and those commands, is this the most optimal and useful one or there are better ones?