mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Investigate support for spatial audio on Apple platforms

Open rcombs opened this issue 4 years ago • 14 comments

This would require switching to AVSampleBufferAudioRenderer for audio playout. Might be tricky to account for the resulting latency.

rcombs avatar Sep 29 '21 20:09 rcombs

VLC added it, the patch doesn't seems to be overkill to add

https://code.videolan.org/videolan/vlc/-/merge_requests/786/diffs?commit_id=744248f5ee6e2ffa205e2282036f9450025bc80f

skrew avatar Nov 01 '21 01:11 skrew

please! :-)

richtong avatar Jan 08 '22 03:01 richtong

Oh, it looks like we wouldn't actually need AVSampleBufferAudioRenderer; we can just call [AVAudioSessionPortDescription setSupportsMultichannelContent] when spatialAudioEnabled is set by the system.

rcombs avatar Jan 08 '22 04:01 rcombs

That VLC patch is nonsense.

setSupportsMultichannelContent should be called unconditionally.

Spatial audio only works with AVSBAR.

tmm1 avatar Jan 09 '22 17:01 tmm1

Any other train of thoughts on the subject or is it just hopeless?

linust avatar Feb 02 '22 20:02 linust

Any other train of thoughts on the subject or is it just hopeless?

It sounds really easy, you could try to do it

tbodt avatar Feb 02 '22 21:02 tbodt

Any other train of thoughts on the subject or is it just hopeless?

It sounds really easy, you could try to do it

No need to be snarky. I'm genuinely curious if this has a reasonable feasibility or if the nature of the current architecture makes Spatial Audio support on mpv as likely as (stable) Raid5 on BTRFS. Sometimes it's just a not-bloody-likely-mate situation.

linust avatar Feb 02 '22 21:02 linust

As mentioned several times above, this is possible only if mpv adds an audio driver that uses the AVSBAR api.

tmm1 avatar Feb 02 '22 21:02 tmm1

I started to write an AVSBAR driver a few years ago: https://gist.github.com/tmm1/eaf6a982f967d92516915abff6794ead

I ran into a lot of bugs though, and the mpv internals around audio have changed significantly since then.

I also found that AVSBAR is incredibly buggy. For example if you use it with AirPlay speakers it is barely usable: https://github.com/tmm1/avsbartest

tmm1 avatar Feb 07 '22 23:02 tmm1

Another approach that may or may not work: feed raw audio into AVPlayer using the CAFF format (https://developer.apple.com/library/archive/documentation/MusicAudio/Reference/CAFSpec/CAF_spec/CAF_spec.html)

I spiked a driver here, but didn't have time to investigate all the strange bugs: https://github.com/tmm1/mpv-player/commit/96460cf102e1be0c5ace516571477cfcfbc254fe

tmm1 avatar Feb 07 '22 23:02 tmm1

One observation - when the iOS video player nPlayer is switched to Picture in Picture mode, it uses QuickTime to decode, at which the spatial audio is enabled by default (if the video supports it) Screen Shot 2022-08-17 at 9 27 26 PM

KrisCris avatar Aug 18 '22 02:08 KrisCris

I hope you'll add support for Spatial Audio soon. It's the only missing piece in making MPV/IINA perfect.

byGits avatar Sep 07 '22 11:09 byGits

I started to write an AVSBAR driver a few years ago: https://gist.github.com/tmm1/eaf6a982f967d92516915abff6794ead

I ran into a lot of bugs though, and the mpv internals around audio have changed significantly since then.

I also found that AVSBAR is incredibly buggy. For example if you use it with AirPlay speakers it is barely usable: https://github.com/tmm1/avsbartest

@tmm1 I have used AVSBAR in my code and I think waiting for few seconds after first enqueuing when connected to AirPlay speakers is acceptable. Does it trouble much? Or are there other bugs with AVSBAR?

ghost avatar Oct 27 '22 10:10 ghost

I don't remember all the issues now. Some may be fixed in newer iOS, and other may not matter for your application.

tmm1 avatar Oct 27 '22 16:10 tmm1

Just wanted to +1 this, as Infuse is currently the only player that supports spatial audio (I pay for it just for that reason). I'd like to switch to IINA for its HDR support and general awesomeness, but the lack of spatial audio is holding me back.

Is the code referenced just above in KSPlayer a helpful model? The commit it references is: https://github.com/kingslay/KSPlayer/commit/cf56d1cf662931c68eea93552a6f5db59388be8b

mjbaldwin avatar Feb 25 '23 17:02 mjbaldwin

abandonware

ArtemBernatskyy avatar Jun 06 '23 22:06 ArtemBernatskyy

Any update on this?

brownknightrises23 avatar Jun 19 '23 12:06 brownknightrises23

Any update on this? Thanks

fsafq41 avatar Oct 29 '23 23:10 fsafq41

@fsafq41 PR https://github.com/mpv-player/mpv/pull/11955 getting merged is seems key for mpv spatial audio support. Looks like it's waiting for a review by an mpv committer but not sure 🤷‍♀️

(though possibly a different approach using something like the VLC patch is enough)

varenc avatar Nov 28 '23 23:11 varenc

VLC added it, the patch doesn't seems to be overkill to add

code.videolan.org/videolan/vlc/-/merge_requests/786/diffs?commit_id=744248f5ee6e2ffa205e2282036f9450025bc80f

VLC does not support Spatial Audio

ShlomoCode avatar Jan 14 '24 13:01 ShlomoCode

added with #11955.

Akemi avatar Apr 01 '24 20:04 Akemi