Solved audio popping recording with obs studio

im getting really bad audio popping recording with obs studio on freebsd 14 on wayland
the issue happens when recording the display and the mic at the same time, using either pulse audio,
sndio audio or recording the audio with sox and the video with obs

i have had a simmilar issue on my old macbook air with 4 gig of ram which didnt have enough memory
to record the screen and mic at the same time

im using a dell xps with 16 gig of ram and nvidia gpu and using nvenc encoding which only use 4% of the cpu
so it not an issue with the machine not having enough memory

heres an example of the audio popping in a video

emacs org mode video link handler to open videos with mpv



freebsd set up

freebsd version: freebsd 14 p4

computer: dell xps 15 2019 with an nvidia gpu with 16 gig of ram

desktop enviornment: wayfire wlroots wayland compositor


login_conf

my user is in the video group

set :memorylocked=unlimited: in ~/.login_conf
Code:
me:\
  :charset=UTF-8:\
  :lang=en_GB.UTF-8:\
  :setenv=LC_COLLATE=C:\
  :memorylocked=unlimited:

run cap_mkdb ~/.login_conf

Code:
cap_mkdb ~/.login_conf

i have also tried setting :memorylocked=unlimited: in the default /etc/login_conf

changed from the default


Code:
default:\
    :memorylocked=64K:\

to

Code:
default:\
    :memorylocked=unlimited:\

run cap_mkdb on /etc/login_conf

Code:
sudo cap_mkdb /etc/login_conf

the audio popping happens even with memorylocked=unlimited set

i have nvenc encoding set up and obs only uses about 4% cpu when recording

obs studio has two ways to capture the screen on wlroots wayland compisitors
dmabuf and scpy and both have the same issue with audio pops when recording the mic,
either using pulse audio or sndio to record the mic

both wayfire and hikari wayland wlroots compisitors have the audio popping issue
so its not the desktop

i have also tried all the different video codecs and settings in obs studio and thats not the problem
i get the audio popping when recording the mic with sox and the video with obs

recording permutations

1 - recording the screen with dmabuf or scpy and the audio with pulse or sndio results in audio pops

2 - recording the screen with obs using dmabuf or scpy and the audio with sox results in audio pops

3 - recording the mic with obs studio and not the screen doesnt create any audio pops

4 - recording the mic with sox and not recording the screen with obs doesnt create any audio pops

the issue only occurs when recording both the screen and the mic with either sndio or pulse audio

this leads me to think based on previous experience with obs studio that its some type of memory or audio buffer issue

i have used obs studio on this machine using ubuntu, nixos and fedora without any audio issues

possible solutions

some thoughts on possible solutions to the audio popping issue with obs studio

1 - its a memory limit issue

i have tried setting :memorylocked=unlimited: for me in ~/.login_conf
and default in /etc/login_conf

i note that in /etc/groups sndio is listed

Code:
_sndio:*:702:

i thought the default group in /etc/login_conf would apply to the audio
but do i need to another entry in the system login_conf for _sndio audio and set memorylocked=unlimited:

Code:
_sndio:\
    :memorylocked=unlimited:

2 - its an audio buffer size issue

is there an audio buffer size that need to have its size increased

3 - i need to build a custom kernel

i need to build a custom kernel and enable realtime audio or reduce the latency somehow

if anyone has an idea what the issue might be and could point me in the right direction that would be great

when i google for "freebsd obs" i just get my forum posts and youtube videos in the results
so im not having much luck finding any pointers online

the audio popping is so bad the only work around would be to be to record the audio and video serperatly
and then join them with ffmpeg which is a bit of a pain

sysctl output

Code:
sysctl dev.pcm

sysctl output for dev.pcm


Code:
dev.pcm.3.feedback_rate: 0
dev.pcm.3.mixer.mute_1.desc:
dev.pcm.3.mixer.mute_1.max: 1
dev.pcm.3.mixer.mute_1.min: 0
dev.pcm.3.mixer.mute_1.val: 0
dev.pcm.3.mixer.vol_0_1.desc:
dev.pcm.3.mixer.vol_0_1.max: 3584
dev.pcm.3.mixer.vol_0_1.min: -2048
dev.pcm.3.mixer.vol_0_1.val: -640
dev.pcm.3.mixer.vol_0_0.desc:
dev.pcm.3.mixer.vol_0_0.max: 3584
dev.pcm.3.mixer.vol_0_0.min: -2048
dev.pcm.3.mixer.vol_0_0.val: -640
dev.pcm.3.mode: 5
dev.pcm.3.bitperfect: 0
dev.pcm.3.buffersize: 0
dev.pcm.3.rec.vchanformat: s16le:2.0
dev.pcm.3.rec.vchanrate: 48000
dev.pcm.3.rec.vchanmode: fixed
dev.pcm.3.rec.vchans: 1
dev.pcm.3.hwvol_mixer: vol
dev.pcm.3.hwvol_step: 5
dev.pcm.3.%parent: uaudio0
dev.pcm.3.%pnpinfo:
dev.pcm.3.%location:
dev.pcm.3.%driver: pcm
dev.pcm.3.%desc: USB audio
dev.pcm.2.mode: 3
dev.pcm.2.bitperfect: 0
dev.pcm.2.buffersize: 65536
dev.pcm.2.play.vchanformat: s16le:2.0
dev.pcm.2.play.vchanrate: 48000
dev.pcm.2.play.vchanmode: passthrough
dev.pcm.2.play.vchans: 1
dev.pcm.2.play.32bit: 24
dev.pcm.2.%parent: hdaa1
dev.pcm.2.%pnpinfo:
dev.pcm.2.%location: nid=3
dev.pcm.2.%driver: pcm
dev.pcm.2.%desc: Intel Kaby Lake (HDMI/DP 8ch)
dev.pcm.1.mode: 3
dev.pcm.1.bitperfect: 0
dev.pcm.1.buffersize: 65536
dev.pcm.1.play.vchanformat: s16le:2.0
dev.pcm.1.play.vchanrate: 48000
dev.pcm.1.play.vchanmode: fixed
dev.pcm.1.play.vchans: 2
dev.pcm.1.play.32bit: 24
dev.pcm.1.%parent: hdaa0
dev.pcm.1.%pnpinfo:
dev.pcm.1.%location: nid=33
dev.pcm.1.%driver: pcm
dev.pcm.1.%desc: Realtek ALC298 (Left Analog Headphones)
dev.pcm.0.mode: 7
dev.pcm.0.bitperfect: 0
dev.pcm.0.buffersize: 65536
dev.pcm.0.rec.vchanformat: s16le:2.0
dev.pcm.0.rec.vchanrate: 48000
dev.pcm.0.rec.vchanmode: fixed
dev.pcm.0.rec.vchans: 1
dev.pcm.0.rec.autosrc: 2
dev.pcm.0.rec.32bit: 24
dev.pcm.0.play.vchanformat: s16le:2.0
dev.pcm.0.play.vchanrate: 48000
dev.pcm.0.play.vchanmode: fixed
dev.pcm.0.play.vchans: 1
dev.pcm.0.play.32bit: 24
dev.pcm.0.%parent: hdaa0
dev.pcm.0.%pnpinfo:
dev.pcm.0.%location: nid=23,18
dev.pcm.0.%driver: pcm
dev.pcm.0.%desc: Realtek ALC298 (Internal Analog)
dev.pcm.%parent:

sysctl output for hw.snd

Code:
sysctl hw.snd

Code:
hw.snd.maxautovchans: 16
hw.snd.default_unit: 1
hw.snd.version: 2009061500/amd64
hw.snd.default_auto: 1
hw.snd.verbose: 0
hw.snd.vpc_mixer_bypass: 1
hw.snd.feeder_rate_quality: 1
hw.snd.feeder_rate_round: 25
hw.snd.feeder_rate_max: 2016000
hw.snd.feeder_rate_min: 1
hw.snd.feeder_rate_polyphase_max: 183040
hw.snd.feeder_rate_presets: 100:8:0.85 100:36:0.92 100:164:0.97
hw.snd.feeder_eq_exact_rate: 0
hw.snd.feeder_eq_presets: PEQ:16000,0.2500,62,0.2500:-9,9,1.0:44100,48000,88200,96000,176400,192000
hw.snd.basename_clone: 1
hw.snd.compat_linux_mmap: 0
hw.snd.syncdelay: -1
hw.snd.usefrags: 0
hw.snd.vpc_reset: 0
hw.snd.vpc_0db: 45
hw.snd.vpc_autoreset: 0
hw.snd.timeout: 5
hw.snd.latency_profile: 1
hw.snd.latency: 2
hw.snd.report_soft_matrix: 1
hw.snd.report_soft_formats: 1


freebsd dotfiles

freebsd root dotfiles


freebsd dotfiles



looking at sysctl hw.snd

Code:
hw.snd.latency_profile: 1
hw.snd.latency: 2

from the snd man page

Code:
       hw.snd.latency
           Configure  the  buffering  latency.   Only affects applications
           that do not explicitly request  blocksize  /  fragments.      This
           tunable       provides    finer      granularity      than       the
           hw.snd.latency_profile tunable.    Possible values    range  between
           0 (lowest latency) and 10 (highest latency).

       hw.snd.latency_profile
           Define  sets  of     buffering  latency  conversion    tables for the
           hw.snd.latency tunable.    A value    of 0 will use a     low  and  ag-
           gressive    latency    profile    which can result in possible underruns
           if  the application cannot keep up with a rapid irq rate, espe-
           cially during high workload.  The default value is 1, which  is
           considered a moderate/safe latency profile.

i see mentions of a mentions of audio buffer underruns if the latency is set to low
so maybe i need to set increase the latency level

tried increasing the latency to 4 and then 10 but still get audio pops

Code:
sudo syscyl hw.snd.latency=10
 
I have tracked down the issue that is causing the audio popping with obs studio
the issue only happens when recording the screen on some wlroots based compositors like wayfire and hikari

i just built the dwl wayland compositor and did a test recording and no audio pops

it wasnt totally wasted time as i got into dwl and realtime audio for jack
 
Back
Top