Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: Latency reduction when using audio/video player as input
#1
Hello all,

I changed my setup and do not use anymore an amp with many inputs.
I am trying to play movies from bluray player through the Rpi and moode, as a source selector. The idea is also to allow to apply DSP for movies.
For that, I use a SPDIF input with moode (with a Komplete Audio 6 Mk2 audio interface), following the tutorial from https://www.bitlab.nl/page_id=1103

It works well, however, I get a latency close to 2 seconds compared to the frames!
My bluray player allows to adjust the A/V sync up to 500ms only.
Do you know ways to reduce the latency?

Thank for your help.

best
Reply
#2
Forgot to mention that I tried to reduce the latency in alsa input conf.
My .conf file is currently like this (already tuned period and buffer, for very small latency reduction, still between 1.5s and 2s):

pcm_slave.komplete {
pcm "hw:1,0,0"
format S32_LE
channels 6
rate 48000
period_time 0
period_size 256
buffer_time 0
buffer_size 512
}

pcm.spdifinput {
type dsnoop
ipc_key 12375
slave komplete
bindings.0 4
bindings.1 5
}
Reply
#3
Is the 2 seconds latency already with all DSP options turned off (No CamilladDSP enabled) and no loopback use ?
Reply
#4
Hi,

Yes, loopback is off, CamillaDSP is off, Parametric EQ is off, Graphic EQ is off.
Reply
#5
Rectification after more tries:

- with no buffer and period specific params, latency is about 1.2s (2s was exagerated, I now use a specific video for sync test)
- with buffer and period specific params, latency is about 1s
- with configure>Audio>Output mode>Direct (hw) instead of Default (plughw), no buffer and period specific params, latency is about 1s
- with output mode set to direct (hw), plus buffer and period specific params, latency is about 1s also
Reply
#6
Hi,

I tried to see if changes in /etc/mdp.conf would help (while using default output (i.e. plughw)).
Tried parameters buffer_time, audio_buffer_size, and buffer_before_play, but they made no difference.
Reply
#7
I am lost, I tried to activate CamillaDSP with flat correction to see if it adds latency, and I don't see noticeable difference.
Where comes the latency from? What is the audio flow in moodeaudio please?
Reply
#8
There is no built in audio capture feature in moOde so I can't speak to that flow but wrt to the default MPD audio flow with no DSP or Loopback it looks like below.

MPD -> ALSA COPY -> plughw or hw -> device

This flow is implemented in the file below.

Code:
/etc/alsa/conf.d/_audioout.conf

If you want to bypass the ALSA COPY part for testing then manually edit /etc/mpd.conf and set device to ""plughw:N,0" or "hw:N,0" where N is the card number of your output device then restart MPD via systemd. 

Code:
# mpd.conf
.
.
audio_output {
type "alsa"
name "ALSA Default"
device "_audioout"
mixer_type "hardware"
mixer_control "Digital"
mixer_device "hw:0"
mixer_index "0"
dop "no"
stop_dsd_silence "no"
thesycon_dsd_workaround "no"
}

# Restart
sudo systemctl restart mpd

Note: Don't make any changes to MPD ir ALSA settings in the WebUI because they will overwrite manual changes to mpd.conf.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#9
Hello,

thanks, but no success with suggested test.
Changed also _audioout.conf to change "copy" plug to "empty" with no more success (I guess it is equivalent to suggested change also).
Tried also commenting bluetooth and http outputs from mpd.conf, and it does not change anything.

Now I put back everything as its original values, and I tried to play directly with alsa the spdif input from alsa, command :
Code:
sudo arecord -Dspdifinput -traw -c2 -fS32_LE -r48000 | aplay -D_audioout -traw -c2 -fS32_LE -r48000

And this way I get a near perfect sync with video, without any other intermediate software (but some overruns print, need to tune buffer periods I guess).
So the latency might comes from MPD, what do you think?
Reply
#10
(01-15-2023, 02:58 PM)jiemdev Wrote: Hello,

thanks, but no success with suggested test.
Changed also _audioout.conf to change "copy" plug to "empty" with no more success (I guess it is equivalent to suggested change also).
Tried also commenting bluetooth and http outputs from mpd.conf, and it does not change anything.

Now I put back everything as its original values, and I tried to play directly with alsa the spdif input from alsa, command :
Code:
sudo arecord -Dspdifinput -traw -c2 -fS32_LE -r48000 | aplay -D_audioout -traw -c2 -fS32_LE -r48000

And this way I get a near perfect sync with video, without any other intermediate software (but some overruns print, need to tune buffer periods I guess).
So the latency might comes from MPD, what do you think?

Try turning on verbose logging in MPD config and see if there is anything suspicious in the log.

Code:
cat /var/log/mpd/log

How is the audio device connected to the Pi?
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: