Obs-studio: Linux: JACK audio source not routed to program out

Created on 5 Sep 2020  路  17Comments  路  Source: obsproject/obs-studio

Platform

Operating system and version: openSUSE Tumbleweed 20200819
OBS Studio version: git master ace0faebd804a1d2c70e9cc6509df3bc61f79591
jack2 git of Aug 14

Expected Behavior

JACK audio sources should be audible on the recording output.

Current Behavior

They are not.

Steps to Reproduce

  1. Starting with a clean new session (.config/obs-studio deleted), I'm adding a JACK audio source to a scene and switch it to Program Out.
  2. I connect a signal on the JACK side. The OBS audio mixer shows the signal is there.

No audio on the output.

Additional information

If I activate monitoring of the JACK input source and bring up the "Desktop Audio" fader, the signal is heard in the mix. But this confuses monitor settings and should not be necessary. It might however explain why previous problem reports re JACK sources have been so inconclusive, with users and testers rarely being able to reproduce the problem, since this monitor signal path might be activated without the user noticing it (oh the smartness of pulseaudio...)

This issue might be related to forum post https://obsproject.com/forum/threads/jack-obs-no-sound.123527/#post-474222 and its corresponding issue ticket #3021. The reporting user's setup is more complex, but is consistent with the behaviour I'm seeing.

Most helpful comment

The jack thread will run with realtime scheduling (effected by the jack server, not by OBS code), and so it is important that it never block:
~> ps -eLo rtprio,cls,pri,nice,pid,wchan,cmd - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5175 - obs <...> 40 FF 80 - 5175 - obs
The last one is the jack thread, as you can see it runs in the SCHED_FIFO scheduling class with a realtime priority set by the jack daemon (40 in my case, i.e. below Linux hardware handlers, but it might well be higher).
So the thread even has the potential to starve out kernel drivers, and that spells potential deadlock.

As to your comment of my audio being "more than 1s out of sync", the issue is not with my system. PCM devices have no notion of presentation time or any other sort of timestamp. OBS probably gets the notion of presentation time from pulseaudio, but that is basically a made-up value.

JACK devices will not have that, and that means that if the JACK plugin (or the ALSA input, same thing there) works for anyone, it's probably by coincidence.

It would work if all devices were controlled by pulseaudio, but that is not an option for studio environments. The main reason is latency, but also that pulse trades ease of use and cleverness for a lack of determinism that can be quite disruptive in complex settings, so pro users tend to disable pulse altogether or bridge pulseaudio into jack, with jack retaining ultimate control of timing (or rather, the hardware dictating that).

Please don't take my comments the wrong way, I'm totally in awe of OBS and I would like to contribute in a constructive way. But I guess the problem is that the audio and video worlds literally run at different clocks with completely different precision requirements. Also, while you guys are basically saving my ass right now by making OBS cross-platform (which enables me to do a complex project next week that couldn't be done on Linux alone), it also means that you have to deal with three fundamentally different audio architectures...

Please reopen this bug and let's gather more information on the underlying issues. I will also file a bug about the jack plugin eventually, once I've fully understood the issues, and hopefully suggest a patch to fix it.

All 17 comments

Using the same OBS session as above, I quickly cross-checked with an ALSA input (of the same device). It behaves as expected, e.g. as long as the source fader is up, the audio is heard in the recording output.

02:04:22 PM.031: CPU Name: AMD Ryzen 9 3950X 16-Core Processor
02:04:22 PM.032: CPU Speed: 3499.771MHz
02:04:22 PM.032: Physical Cores: 16, Logical Cores: 32
02:04:22 PM.032: Physical Memory: 64230MB Total, 56736MB Free
02:04:22 PM.032: Kernel Version: Linux 5.8.0-1-default
02:04:22 PM.032: Distribution: "openSUSE Tumbleweed" "20200819"
02:04:22 PM.033: Window System: X11.0, Vendor: The X.Org Foundation, Version: 1.20.8
02:04:22 PM.034: Portable mode: false
02:04:22 PM.115: OBS 26.0.0-rc1-36-gace0faeb-modified (linux)
02:04:22 PM.115: ---------------------------------
02:04:22 PM.335: ---------------------------------
02:04:22 PM.335: audio settings reset:
02:04:22 PM.335:    samples per sec: 48000
02:04:22 PM.335:    speakers:        2
02:04:22 PM.338: ---------------------------------
02:04:22 PM.338: Initializing OpenGL...
02:04:22 PM.534: Loading up OpenGL on adapter X.Org Radeon RX 560 Series (POLARIS11, DRM 3.38.0, 5.8.0-1-default, LLVM 10.0.0)
02:04:22 PM.534: OpenGL loaded successfully, version 4.6 (Core Profile) Mesa 20.1.4, shading language 4.60
02:04:22 PM.549: ---------------------------------
02:04:22 PM.549: video settings reset:
02:04:22 PM.549:    base resolution:   1920x1080
02:04:22 PM.549:    output resolution: 1280x720
02:04:22 PM.549:    downscale filter:  Bicubic
02:04:22 PM.549:    fps:               30/1
02:04:22 PM.549:    format:            NV12
02:04:22 PM.549:    YUV mode:          sRGB/Partial
02:04:22 PM.549: NV12 texture support not available
02:04:22 PM.551: Audio monitoring device:
02:04:22 PM.551:    name: Default
02:04:22 PM.551:    id: default
02:04:22 PM.551: ---------------------------------
02:04:22 PM.552: Failed to load 'en-US' text for module: 'decklink-ouput-ui.so'
02:04:22 PM.652: Decklink API Compiled version 10.11.4
02:04:22 PM.652: Decklink API Installed version 11.6
02:04:22 PM.655: [obs-browser]: Version 2.8.6
02:04:22 PM.658: [obs-ndi] hello ! (version 4.9.1)
02:04:22 PM.658: [obs-ndi] Trying ''
02:04:22 PM.658: [obs-ndi] Trying '/usr/lib'
02:04:22 PM.658: [obs-ndi] Trying '/usr/local/lib'
02:04:22 PM.658: [obs-ndi] Found NDI library at '/usr/local/lib/libndi.so.4'
02:04:22 PM.659: [obs-ndi] NDI runtime loaded successfully
02:04:22 PM.659: [obs-ndi] NDI library initialized successfully (NDI SDK LINUX 00:05:02 Apr  1 2020 4.5.1)
02:04:22 PM.746: VLC found, VLC video source enabled
02:04:22 PM.746: ---------------------------------
02:04:22 PM.746:   Loaded Modules:
02:04:22 PM.746:     vlc-video.so
02:04:22 PM.746:     v4l2sink.so
02:04:22 PM.746:     text-freetype2.so
02:04:22 PM.746:     rtmp-services.so
02:04:22 PM.746:     obs-x264.so
02:04:22 PM.746:     obs-vst.so
02:04:22 PM.746:     obs-transitions.so
02:04:22 PM.746:     obs-outputs.so
02:04:22 PM.746:     obs-ndi.so
02:04:22 PM.747:     obs-libfdk.so
02:04:22 PM.747:     obs-filters.so
02:04:22 PM.747:     obs-ffmpeg.so
02:04:22 PM.747:     obs-browser.so
02:04:22 PM.747:     linux-v4l2.so
02:04:22 PM.747:     linux-pulseaudio.so
02:04:22 PM.747:     linux-jack.so
02:04:22 PM.747:     linux-decklink.so
02:04:22 PM.747:     linux-capture.so
02:04:22 PM.747:     linux-alsa.so
02:04:22 PM.747:     image-source.so
02:04:22 PM.747:     frontend-tools.so
02:04:22 PM.747:     decklink-ouput-ui.so
02:04:22 PM.747: ---------------------------------
02:04:22 PM.747: os_dlopen(../obs-plugins/obs-browser->../obs-plugins/obs-browser.so): ../obs-plugins/obs-browser.so: cannot open shared object file: No such file or directory
02:04:22 PM.747: 
02:04:22 PM.747: ==== Startup complete ===============================================
02:04:22 PM.756: No scene file found, creating default scene
02:04:22 PM.756: All scene data cleared
02:04:22 PM.756: ------------------------------------------------
02:04:22 PM.759: pulse-input: Server name: 'pulseaudio 13.0-rebootstrapped'
02:04:22 PM.760: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
02:04:22 PM.760: pulse-input: Started recording from 'alsa_output.pci-0000_34_00.4.analog-stereo.monitor'
02:04:22 PM.760: Switched to scene 'Scene'
02:04:22 PM.760: Failed to glob scene collections
02:04:23 PM.662: adding 42 milliseconds of audio buffering, total audio buffering is now 42 milliseconds (source: Desktop Audio)
02:04:23 PM.662: 
02:04:23 PM.686: [ffmpeg] [AVIOContext @ 0x7f5c1c009900] Statistics: 386 bytes read, 0 seeks
02:06:45 PM.689: Settings changed (outputs)
02:06:45 PM.689: ------------------------------------------------
02:06:54 PM.667: Using muxer settings: 
02:06:54 PM.667:    content=video/ts
02:06:54 PM.711: Invalid muxer settings: 
02:06:54 PM.711:    content=video/ts
02:06:54 PM.974: ==== Recording Start ===============================================
02:07:44 PM.662: v4l2-input: Start capture from 
02:07:44 PM.662: v4l2-input: Unable to open device
02:07:44 PM.662: v4l2-input: Initialization failed
02:07:44 PM.663: User added source 'usbcam' (v4l2_input) to scene 'Scene'
02:07:44 PM.665: v4l2-input: /dev/video1 seems to not support video capture
02:07:44 PM.665: v4l2-input: Found device 'Trust Full HD Webcam: Trust Ful' at /dev/video0
02:07:44 PM.667: v4l2-input: /dev/video1 seems to not support video capture
02:07:44 PM.667: v4l2-input: Found device 'Trust Full HD Webcam: Trust Ful' at /dev/video0
02:07:44 PM.667: v4l2-input: Found input 'Camera 1' (Index 0)
02:07:44 PM.685: v4l2-input: Start capture from /dev/video0
02:07:44 PM.690: v4l2-controls: setting default for Power Line Frequency to 1
02:07:44 PM.690: v4l2-input: Input: 0
02:07:44 PM.690: v4l2-input: Selected video format not supported
02:07:44 PM.690: v4l2-input: Initialization failed
02:07:44 PM.708: v4l2-controls: setting default for Exposure, Auto to 3
02:07:44 PM.732: v4l2-input: Pixelformat: Motion-JPEG (unavailable)
02:07:44 PM.732: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
02:07:44 PM.732: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
02:07:44 PM.732: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
02:07:44 PM.732: v4l2-input: Pixelformat: YU12 (Emulated) (available)
02:07:44 PM.732: v4l2-input: Pixelformat: YV12 (Emulated) (available)
02:07:44 PM.732: v4l2-input: Stepwise and Continuous framesizes are currently hardcoded
02:07:44 PM.733: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
02:07:44 PM.734: v4l2-input: Pixelformat: Motion-JPEG (unavailable)
02:07:44 PM.734: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
02:07:44 PM.734: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
02:07:44 PM.734: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
02:07:44 PM.734: v4l2-input: Pixelformat: YU12 (Emulated) (available)
02:07:44 PM.734: v4l2-input: Pixelformat: YV12 (Emulated) (available)
02:07:44 PM.734: v4l2-input: Stepwise and Continuous framesizes are currently hardcoded
02:07:44 PM.734: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
02:07:44 PM.736: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
02:07:44 PM.804: v4l2-input: Start capture from /dev/video0
02:07:44 PM.805: v4l2-input: Input: 0
02:07:44 PM.822: v4l2-input: Resolution: 1920x1080
02:07:44 PM.822: v4l2-input: Pixelformat: VYUY
02:07:44 PM.822: v4l2-input: Linesize: 3840 Bytes
02:07:44 PM.822: v4l2-input: Framerate: 5.00 fps
02:07:49 PM.318: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
02:07:49 PM.471: v4l2-input: Stopped capture after 21 frames
02:07:49 PM.493: v4l2-input: Start capture from /dev/video0
02:07:49 PM.494: v4l2-input: Input: 0
02:07:49 PM.502: v4l2-input: Resolution: 1920x1080
02:07:49 PM.502: v4l2-input: Pixelformat: 21UY
02:07:49 PM.502: v4l2-input: Linesize: 1920 Bytes
02:07:49 PM.502: v4l2-input: Framerate: 30.00 fps
02:07:54 PM.397: v4l2-input: Stopped capture after 138 frames
02:07:54 PM.422: v4l2-input: Start capture from /dev/video0
02:07:54 PM.422: v4l2-input: Input: 0
02:07:54 PM.430: v4l2-input: Resolution: 1920x1080
02:07:54 PM.430: v4l2-input: Pixelformat: 21UY
02:07:54 PM.430: v4l2-input: Linesize: 1920 Bytes
02:07:54 PM.439: v4l2-input: Framerate: 25.00 fps
02:07:56 PM.765: v4l2-input: Stopped capture after 56 frames
02:07:56 PM.789: v4l2-input: Start capture from /dev/video0
02:07:56 PM.790: v4l2-input: Input: 0
02:07:56 PM.798: v4l2-input: Resolution: 1920x1080
02:07:56 PM.798: v4l2-input: Pixelformat: 21UY
02:07:56 PM.798: v4l2-input: Linesize: 1920 Bytes
02:07:56 PM.807: v4l2-input: Framerate: 25.00 fps
02:07:58 PM.640: v4l2-input: /dev/video1 seems to not support video capture
02:07:58 PM.640: v4l2-input: Found device 'Trust Full HD Webcam: Trust Ful' at /dev/video0
02:07:58 PM.640: v4l2-input: Found input 'Camera 1' (Index 0)
02:07:58 PM.640: v4l2-controls: setting default for Power Line Frequency to 1
02:07:58 PM.640: v4l2-controls: setting default for Exposure, Auto to 3
02:07:58 PM.640: v4l2-input: Pixelformat: Motion-JPEG (unavailable)
02:07:58 PM.640: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
02:07:58 PM.640: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
02:07:58 PM.640: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
02:07:58 PM.640: v4l2-input: Pixelformat: YU12 (Emulated) (available)
02:07:58 PM.640: v4l2-input: Pixelformat: YV12 (Emulated) (available)
02:07:58 PM.641: v4l2-input: Pixelformat: Motion-JPEG (unavailable)
02:07:58 PM.641: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
02:07:58 PM.641: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
02:07:58 PM.641: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
02:07:58 PM.641: v4l2-input: Pixelformat: YU12 (Emulated) (available)
02:07:58 PM.641: v4l2-input: Pixelformat: YV12 (Emulated) (available)
02:08:23 PM.224: Output 'adv_ffmpeg_output': stopping
02:08:23 PM.224: Output 'adv_ffmpeg_output': Total frames output: 2655
02:08:23 PM.224: Output 'adv_ffmpeg_output': Total drawn frames: 2646 (2657 attempted)
02:08:23 PM.224: Output 'adv_ffmpeg_output': Number of lagged frames due to rendering lag/stalls: 11 (0.4%)
02:08:23 PM.224: ==== Recording Stop ================================================
02:08:36 PM.552: ---------------------------------
02:08:36 PM.552: video settings reset:
02:08:36 PM.552:    base resolution:   1920x1080
02:08:36 PM.552:    output resolution: 1920x1080
02:08:36 PM.552:    downscale filter:  Bicubic
02:08:36 PM.552:    fps:               25/1
02:08:36 PM.552:    format:            NV12
02:08:36 PM.552:    YUV mode:          sRGB/Partial
02:08:36 PM.552: NV12 texture support not available
02:08:36 PM.784: Settings changed (video)
02:08:36 PM.784: ------------------------------------------------
02:08:39 PM.414: Using muxer settings: 
02:08:39 PM.414:    content=video/ts
02:08:39 PM.453: Invalid muxer settings: 
02:08:39 PM.453:    content=video/ts
02:08:39 PM.561: ==== Recording Start ===============================================
02:09:40 PM.628: Settings changed (outputs)
02:09:40 PM.628: ------------------------------------------------
02:09:43 PM.296: Output 'adv_ffmpeg_output': stopping
02:09:43 PM.296: Output 'adv_ffmpeg_output': Total frames output: 1595
02:09:43 PM.296: Output 'adv_ffmpeg_output': Total drawn frames: 1597
02:09:43 PM.296: ==== Recording Stop ================================================
02:09:44 PM.877: Using muxer settings: 
02:09:44 PM.877:    content="video/ts"
02:09:44 PM.916: Invalid muxer settings: 
02:09:44 PM.916:    content="video/ts"
02:09:45 PM.005: ==== Recording Start ===============================================
02:10:44 PM.764: Output 'adv_ffmpeg_output': stopping
02:10:44 PM.765: Output 'adv_ffmpeg_output': Total frames output: 1495
02:10:44 PM.765: Output 'adv_ffmpeg_output': Total drawn frames: 1498
02:10:44 PM.765: ==== Recording Stop ================================================
02:10:56 PM.040: Settings changed (outputs)
02:10:56 PM.040: ------------------------------------------------
02:10:58 PM.266: Using muxer settings: 
02:10:58 PM.266:    content_type=video/m2ts
02:10:58 PM.266:    ice_genre=Live event
02:10:58 PM.266:    ice_name=vdt Live!
02:10:58 PM.266:    ice_description=A test stream for the upcoming vdt Live! event starting Oct. 7
02:10:58 PM.395: ==== Recording Start ===============================================
02:11:30 PM.497: User added source 'JACK Input Client' (jack_output_capture) to scene 'Scene'
02:11:30 PM.521: Max audio buffering reached!
02:11:30 PM.521: adding 917 milliseconds of audio buffering, total audio buffering is now 960 milliseconds (source: JACK Input Client)
02:11:30 PM.521: 
02:11:42 PM.505: Switched to Preview/Program mode
02:11:42 PM.505: ------------------------------------------------
02:14:30 PM.652: pulse-am: Server name: 'pulseaudio 13.0-rebootstrapped'
02:14:30 PM.652: pulse-am: Audio format: s16le, 44100 Hz, 2 channels
02:14:30 PM.652: pulse-am: Started Monitoring in 'alsa_output.pci-0000_34_00.4.analog-stereo.monitor'
02:14:30 PM.652: User changed audio monitoring for source 'JACK Input Client' to: monitor only
02:19:36 PM.566: pulse-am: Stopped Monitoring in 'alsa_output.pci-0000_34_00.4.analog-stereo.monitor'
02:19:36 PM.566: pulse-am: Got 114713 packets with 13490233 frames
02:19:36 PM.567: User changed audio monitoring for source 'JACK Input Client' to: none
02:21:23 PM.821: User Removed source 'JACK Input Client' (jack_output_capture) from scene 'Scene'
02:22:03 PM.799: alsa-input: Failed to open 'default': Invalid argument
02:22:03 PM.802: User added source 'Audio Capture Device (ALSA)' (alsa_input_capture) to scene 'Scene'
02:22:04 PM.799: alsa-input: Failed to open 'default': Invalid argument
02:22:06 PM.399: alsa-input: Failed to open 'default': Invalid argument
02:22:07 PM.399: alsa-input: Failed to open 'default': Invalid argument
02:22:08 PM.672: alsa-input: PCM 'front:CARD=Webcam,DEV=0' rate set to 48000
02:22:08 PM.672: alsa-input: PCM 'front:CARD=Webcam,DEV=0' channels set to 2
02:22:44 PM.147: User Removed source 'Audio Capture Device (ALSA)' (alsa_input_capture) from scene 'Scene'
02:22:55 PM.983: pulse-input: Server name: 'pulseaudio 13.0-rebootstrapped'
02:22:55 PM.983: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
02:22:55 PM.983: pulse-input: Started recording from 'auto_null.monitor'
02:22:55 PM.986: User added source 'Audio Input Capture (PulseAudio)' (pulse_input_capture) to scene 'Scene'
02:22:55 PM.989: pulse-input: Stopped recording from 'default'
02:22:55 PM.989: pulse-input: Got 0 packets with 0 frames
02:22:55 PM.989: pulse-input: Server name: 'pulseaudio 13.0-rebootstrapped'
02:22:55 PM.989: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
02:22:55 PM.989: pulse-input: Started recording from 'auto_null.monitor'
02:23:00 PM.014: pulse-input: Stopped recording from 'default'
02:23:00 PM.014: pulse-input: Got 162 packets with 178362 frames
02:23:00 PM.015: pulse-input: Server name: 'pulseaudio 13.0-rebootstrapped'
02:23:00 PM.015: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
02:23:00 PM.015: pulse-input: Started recording from 'auto_null.monitor'
02:23:28 PM.381: pulse-input: Stopped recording from 'default'
02:23:28 PM.381: pulse-input: Got 1136 packets with 1250736 frames
02:23:28 PM.381: pulse-input: Server name: 'pulseaudio 13.0-rebootstrapped'
02:23:28 PM.381: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
02:23:28 PM.381: pulse-input: Started recording from 'auto_null.monitor'
02:23:31 PM.412: pulse-input: Stopped recording from 'default'
02:23:31 PM.413: pulse-input: Got 121 packets with 133221 frames
02:23:31 PM.413: pulse-input: Server name: 'pulseaudio 13.0-rebootstrapped'
02:23:31 PM.413: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
02:23:31 PM.413: pulse-input: Started recording from 'auto_null.monitor'
02:23:34 PM.295: User Removed source 'Audio Input Capture (PulseAudio)' (pulse_input_capture) from scene 'Scene'
02:24:02 PM.452: User added source 'Audio Input Capture (PulseAudio)' (pulse_input_capture) to scene 'Scene'
02:24:14 PM.230: User Removed source 'Audio Input Capture (PulseAudio)' (pulse_input_capture) from scene 'Scene'

This has been an issue for years. I've reported it and so have others. It will be closed because...

02:11:30 PM.497: User added source 'JACK Input Client' (jack_output_capture) to scene 'Scene'
02:11:30 PM.521: Max audio buffering reached!

It's an OBS issue but whatcha gonna do? Stick with Pulseaudio-Jack bridge for interfacing with OBS. OBS is the only Jack aware application we don't use, well, with Jack.

At the very least it shouldn't fail silently.

As stated

02:11:30 PM.497: User added source 'JACK Input Client' (jack_output_capture) to scene 'Scene'
02:11:30 PM.521: Max audio buffering reached!

Your audio chain is out of sync so OBS will drop the desynced audio once it reaches its max buffering. Its recommended you figure out why your audio chain is out of sync.

Any idea what pulseaudio-module-jack does to put the Jack stream "in sync"?

Genuinely curious since I run jackd in synchronous mode between 5 computers in the studio.

@kkartaltepe, first of all, can you point me to any documentation (or source files) where I can learn how OBS deals with audio streams running on different sample clocks?

The root of the problem (I guess) is that you cannot configure OBS' audio outputs (if there is, please educate me - for now I haven't even figured out how to use native alsa, as only pulseaudio seems to work), and that I'm basically running two non-synchronized audio clocks: the 48000 Hz oscillator from my mainboard soundcard (which I'm using to monitor via pulseaudio), and the 48000 Hz oscillator of my RME HDSP MADI card (the JACK universe that all my audio gear is wired to).
Unfortunately, there is no way to sync those. But that also means that the JACK inputs should work for nobody, unless they are very lucky (i.e. their clocks are magically the same).
But the sync error cannot completely explain what I'm seeing, because while I don't get JACK inputs into the recording chain, I can turn on JACK input monitoring, and then, when I also bring up the default "Desktop Audio" fader, I magically do hear jack audio on my recording output (at the cost of rendering monitoring unusable for its real purpose). Is this pulseaudio taking care of timing mismatches? Or just using huuuge buffers? Can you explain what's going on here?

Ideally, to make OBS suitable for professional audio, we'd want to be able to

  • use JACK Audio input sources
  • configure the monitor outputs to be JACK outputs, guaranteed to be sample-synchronous with the JACK input sources
  • be sure that all other audio sources (and all of OBS for that matter) receive their clock from JACK via callbacks, or else resample adaptively, on-the-fly.
  • extra points for jack hookup points from all media sources, so that sound can be run on an external mixer such as Ardour if necessary.

Given that OBS can run on CoreAudio on the Mac, I would guess that it is already callback-based, i.e. it is the audio daemon telling OBS when to read or write incoming or outgoing audio buffers rather than OBS telling some hardware to flush buffers. So it should already be compatible to JACK on a fundamental level. Correct me if I'm wrong.

I have failed to find information on how OBS deals with different source and sink timings, and I think this is crucial for users to understand. I'd be willing to write some user-level documentation on this as I go, if you can point me in the right direction. The same issue will come up with NDI btw. Is there some audio-specific developer forum that I might join to get answers to those questions (and maybe point out some general underlying sync issues that might need to be addressed)?

https://obsproject.com/docs/backend-design.html#general-audio-pipeline-overview is the documentation on the audio pipeline.

If you are interested in the implementation of the jack plugin you can review its source in plugins/linux-jack

Thank you very much, that is extremely helpful. At first glance, I see that the jack plugin is not realtime safe (mutex locking is not guaranteed to finish within bounded time)... a year or so ago, I fixed this problem for shairport-sync, but that whole thing was a lot simpler, I guess. Will look at it. There is also a lot of locking going on in do_audio_output and friends. libjack comes with a really nice implementation of a lock-free ringbuffer, which might be useful for core OBS as well.

OBS is not intended to be run with realtime scheduling, and the jack plugin is probably the least of your worries if you were trying to make it "realtime safe". Realtime scheduling is also not needed to maintain the very coarse 1s sync required by obs.

While im sure there are improvements that could be made to OBSs performance, I find it unlikely that a little bit of locking in OBS is the reason your audio is more than 1s out of sync. If I were you i would look at why the timestamps for your samples are so far out of sync with what OBS expects.

The jack thread will run with realtime scheduling (effected by the jack server, not by OBS code), and so it is important that it never block:
~> ps -eLo rtprio,cls,pri,nice,pid,wchan,cmd - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5170 - /usr/bin/xfce4-terminal -x obs - TS 19 0 5175 - obs <...> 40 FF 80 - 5175 - obs
The last one is the jack thread, as you can see it runs in the SCHED_FIFO scheduling class with a realtime priority set by the jack daemon (40 in my case, i.e. below Linux hardware handlers, but it might well be higher).
So the thread even has the potential to starve out kernel drivers, and that spells potential deadlock.

As to your comment of my audio being "more than 1s out of sync", the issue is not with my system. PCM devices have no notion of presentation time or any other sort of timestamp. OBS probably gets the notion of presentation time from pulseaudio, but that is basically a made-up value.

JACK devices will not have that, and that means that if the JACK plugin (or the ALSA input, same thing there) works for anyone, it's probably by coincidence.

It would work if all devices were controlled by pulseaudio, but that is not an option for studio environments. The main reason is latency, but also that pulse trades ease of use and cleverness for a lack of determinism that can be quite disruptive in complex settings, so pro users tend to disable pulse altogether or bridge pulseaudio into jack, with jack retaining ultimate control of timing (or rather, the hardware dictating that).

Please don't take my comments the wrong way, I'm totally in awe of OBS and I would like to contribute in a constructive way. But I guess the problem is that the audio and video worlds literally run at different clocks with completely different precision requirements. Also, while you guys are basically saving my ass right now by making OBS cross-platform (which enables me to do a complex project next week that couldn't be done on Linux alone), it also means that you have to deal with three fundamentally different audio architectures...

Please reopen this bug and let's gather more information on the underlying issues. I will also file a bug about the jack plugin eventually, once I've fully understood the issues, and hopefully suggest a patch to fix it.

Bugs are only left open if they are confirmed a bug in OBS. You are free to research and update this bug if you want, but it still doesnt seem to be a bug in OBS in my experience. If you have compelling evidence or a patch that fixes it we can of course reopen the bug.

Another great way to try and get this bug opened would be to provide replication steps in software. If it really isnt an issue with your hardware it should be possible to construct such a setup.

Ran into this exact issue yesterday (Max audio buffering reached!) for a livestreamed concert. The sound meters were flashing like they should, but no audio in stream. If I knew the JACK source was broken/unstable I wouldn鈥檛 have used it. We did a test stream before the real thing and it had sound.

We had a prestream scene without the jack source, playing a looping video. Then when I switched to the main source with cameras, no sound, but JACK source showed input in the mixer. Restarted obs, reconnected the jack plugs, still no sound. Muted jack source and added an audio device globally (Settings > Audio), which fixed it.

The reason I wanted to use JACK was because I recorded a multitrack recording in the background. JACK reported zero xruns.

again, please provide replication steps instead of saying "me too".

again, please provide replication steps instead of saying "me too".

Alright.

  1. Launch jack: jackd -S -R -P 70 -t 1000 -d alsa -r 48000 -p 128 -n 3
  2. Open OBS and create 5 Jack channels to record & set them appropriately in advance mixer.
  3. Connect the outputs to the corresponding inputs with Catia.
  4. Tap that record button, fam.
  5. Get 5 tracks without audio.

I suggest trying this with something more complex than a stereo pair in / out when trying to replicate.

I made a video showing this issue in another report some time back. Out of all the Jack aware application I run in the studio OBS is the only one exhibiting this issue.

The hack it to use pulseaudio-module-jack and route it that way.

It would be nice if it did not fail silently since it gives every indication that it is working until you check the audio after the recording. People have lost data due to that.

I cannot start jack with the options specified. -S seems invalid though its listed in the man page, and I removed the priority related options for my environment.

Your video shows (fails to show but it is implied) that everything has overrun already on all channels before you even began recording, which suggests devices issues as I have been saying. Since you are also recording directly from the device, something I dont have access either.

I have configured OBS to a similar setup by recording from ardour and cannot replicate this. Again please provide replication steps that __do not__ involve a potentially poorly behaved device

Jack settings (Cadence):
Screenshot from 2020-11-15 16-26-17

Tried to replicate the issue today with the same setup and hardware, but was unable to. Here are the three logfiles (stream started at 18:54:53) from the time of the concert: https://gist.github.com/daniel-j/7255d429e805c7388336166c0965f5cb (3 log files, in the end I fixed it by adding Jack Source as a global audio device in OBS thru pulseaudio)

Log from today, no audio issues: https://gist.github.com/daniel-j/3817f2146153529021ecb1b308457506

I can't replicate the issue with @LGCW's steps.

Hardware used: Behringer X32 Compact, running in 32x32 mode (JACK uses this, first two input channels was main stream mix, connected to OBS Jack source). Blackmagic Design ATEM Mini Pro for video input. I had a NDI source in a scene, but the iPad I had planned to use as a wireless camera was never used during the concert.

Was this page helpful?
0 / 5 - 0 ratings