Repository navigation
vlc-video: Reorder 5.1 and 7.1 audio into libobs channel order - #252
Merged
Merged
Conversation
libVLC's audio callbacks hand over interleaved samples in VLC's own channel order (L R [SL SR] RL RR C LFE). vlc_source passes them to libobs unchanged, but libobs reads 5.1 as FL FR FC LFE RL RR and 7.1 as FL FR FC LFE RL RR SL SR. With 5.1, centre and LFE play from the rear speakers and the rear channels from centre and LFE; with 7.1 the same happens between the side speakers and centre and LFE. The test adds a stub reorder helper and checks it directly for 1 to 6 and 8 channels, then plays generated 5.1 (back and side) and 7.1 WAV files (each channel at its own level) through the real vlc_source module with OBS in 7.1 and checks which file channel arrives on each libobs channel. The end-to-end cases skip without a display or libVLC, and the test then exits with 77 so ctest reports it as skipped. Reported upstream in obsproject/obs-studio#12579 by Ezriilc; pkviet confirmed the cause in obsproject/obs-studio#12601. Refs obs-rust#251. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
libVLC delivers interleaved audio in VLC's channel order (L R [SL SR] RL RR C LFE), which vlc_source passed straight to libobs. libobs reads 5.1 as FL FR FC LFE RL RR and 7.1 as FL FR FC LFE RL RR SL SR, so centre and LFE came out of the rear (or side) speakers and the other way round. Rearrange each frame in place into libobs order before output. Mono, stereo and 2.1 already match and are left alone. Media Source is unaffected; it already gets FFmpeg's layout. Upstream obsproject/obs-studio#12579, reported by Ezriilc. Based on pkviet's analysis in obsproject/obs-studio#12601, which solved it with a swresample channel matrix and a new libobs API; this version swaps the samples directly in the plugin, needs no libobs change and also covers a 5.1 file while OBS runs in 7.1. Fixes obs-rust#251. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=6c1aad0be6bc706359a56d75b20b9c23add752bd secs=124 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791745839,"gate":"rust/all/fmt","host":"linux-x86_64","key":"1d3acb98659f6443fde178ea74825f96bafb7a85263bbf395c45948c4afa90e4","lane":"lint","parents":["ea6e28c30170a5e31c2900c9ec9f47293b2e240d"],"secs":48,"stamp":"a6a844110455113ffb6ef7a3722650fb","tree":"6c1aad0be6bc706359a56d75b20b9c23add752bd","v":1,"via":"run"} Ci-Attestation: {"at":1791745839,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"1d3acb98659f6443fde178ea74825f96bafb7a85263bbf395c45948c4afa90e4","lane":"lint","parents":["ea6e28c30170a5e31c2900c9ec9f47293b2e240d"],"secs":48,"stamp":"b585886c7c2eca3a7b2b993faa6b5139","tree":"6c1aad0be6bc706359a56d75b20b9c23add752bd","v":1,"via":"run"} Ci-Attestation: {"at":1791745839,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"76d24570f164ae7b64ddb3cdd5d976a0e410ac3411eeba034d584bc6dbd179b1","lane":"rust-test","parents":["ea6e28c30170a5e31c2900c9ec9f47293b2e240d"],"secs":29,"stamp":"6d9cf424907a2b36f26468e4ca764b7d","tree":"6c1aad0be6bc706359a56d75b20b9c23add752bd","v":1,"via":"run"} Ci-Attestation: {"at":1791745839,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"07a0c65db4f4a485f47a3a8114de1f624c97fe5ced2e8b319a1c790120c79b84","lane":"tier2-linux","parents":["ea6e28c30170a5e31c2900c9ec9f47293b2e240d"],"secs":46,"stamp":"8865df6b91d62f96e7e5551e139c6c82","tree":"6c1aad0be6bc706359a56d75b20b9c23add752bd","v":1,"via":"run"}
zackees
force-pushed
the
fix/12579-vlc-surround-order
branch
from
October 11, 2026 19:10
783beee to
2e1bbcc
Compare
Member
|
Verified locally, rebased onto master and stamped.
Non-blocking: under Xvfb without libVLC, the |
This was referenced Oct 11, 2026
Closed
zackees
pushed a commit
that referenced
this pull request
Oct 11, 2026
…odule With ENABLE_VLC=OFF, add_core_module() leaves a dummy custom target named vlc-video behind. The registration only checked TARGET vlc-video, so it still evaluated $<TARGET_FILE:vlc-video> and CMake's generate step failed: any unit-test build without the VLC plugin stopped configuring after #252. Check that vlc-video is a MODULE_LIBRARY before registering the test. Fixes #253. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
VLC Video Source played 5.1 and 7.1 audio through the wrong speakers. With this change every channel arrives where libobs expects it.
libVLC's audio callbacks deliver interleaved samples in VLC's channel order, L R [SL SR] RL RR C LFE, and
vlcs_audio_play()(plugins/vlc-video/vlc-video-source.c:474) handed them to libobs unchanged. libobs reads 5.1 as FL FR FC LFE RL RR and 7.1 as FL FR FC LFE RL RR SL SR, so centre and LFE played from the rear (5.1) or side (7.1) speakers and the other way round.test: VLC source must deliver 5.1 and 7.1 in libobs channel order (RED):test_vlc_channel_orderchecks a stub reorder helper for 1 to 6 and 8 channels, then plays generated 5.1 back, 5.1 side and 7.1 WAV files (each channel at its own level) through the realvlc_sourcemodule with OBS in 7.1 and identifies each libobs channel by its level. 5 of 6 cases fail on this commit. The end-to-end cases skip without libVLC or a display, and the test then exits 77 so ctest reports it as skipped.vlc-video: Reorder 5.1 and 7.1 audio into libobs channel order: a small header,vlc-audio-order.h, reorders each frame in place with a fixed table for 6 and 8 channels. Other channel counts are untouched. All 6 cases pass.libVLC's amem output always delivers interleaved S16 in a layout fixed by the channel count, so a static table is exact. VLC converts 5.1 side sources to its 5.1 layout before the callback, which is why one table covers both. A 5.1 file while OBS runs in 7.1 is covered too.
Motivation and Context
Fixes #251 (upstream obsproject/obs-studio#12579, reported by Ezriilc)
Why this one: surround media plays with the wrong speakers, and the report has clear test files from Ezriilc and theking2. pkviet confirmed and analysed the misordering upstream. His fix (obsproject/obs-studio#12601) rematrixed through swresample and needed new libobs API, which he described as too narrow; it was closed unmerged. This version swaps samples in the plugin, with no libobs change and no extra resampler.
How Has This Been Tested?
Automated:
test_vlc_channel_orderfails 5 of 6 at the RED commit and passes 6 of 6 at the GREEN commit, 10 of 10 repeated runs, in both the C build and theENABLE_RUST_LIBOBS=ONbuild. The full ctest suite passes in both (85 of 85). Without libVLC the test reports as skipped and the unit cases still run. All runs used libVLC 3.0.23 on Linux, under a private Xvfb with software GL. clang-format and gersemi are clean.Not tested:
Types of changes
Checklist:
🤖 Generated with Claude Code