Question / Help Latency on individual media sources causing sync issue

Octopode

New Member
I am using OBS studio to take in multiple IP cameras as media sources.

Occasionally, there's a bit of lag from one (or more) of the sources, and just that source stutters for a fraction of a second. However, my issue isn't that there is occasional lag, my issue is that after every small bit of lag, the source that lagged picks up where it left off, and stream gets more and more out of sync as it goes on.

I'm looking for a way to set it up so that the media sources will just sort of "reset" to the current time once they lag. I have tried changing the buffer sizes to be larger (and much larger), but that didn't give any luck.


Code:
11:51:50.308: CPU Name: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
11:51:50.308: CPU Speed: 3292MHz
11:51:50.308: Physical Cores: 4, Logical Cores: 4
11:51:50.308: Physical Memory: 8134MB Total, 6348MB Free
11:51:50.308: Windows Version: 10.0 Build 14393 (revision: 693; 64-bit)
11:51:50.308: Running as administrator: false
11:51:50.308: Aero is Enabled (Aero is always on for windows 8 and above)
11:51:50.309: Portable mode: false
11:51:50.321: OBS 18.0.1 (64bit, windows)
11:51:50.321: ---------------------------------
11:51:50.322: ---------------------------------
11:51:50.322: audio settings reset:
11:51:50.322:     samples per sec: 44100
11:51:50.322:     speakers:        2
11:51:50.323: ---------------------------------
11:51:50.323: Initializing D3D11..
11:51:50.323: Available Video Adapters:
11:51:50.324:     Adapter 1: AMD Radeon R9 200 Series
11:51:50.324:       Dedicated VRAM: 2127720448
11:51:50.324:       Shared VRAM:    4264980480
11:51:50.324:       output 1: pos={0, 0}, size={1280, 1024}, attached=true
11:51:50.326: Loading up D3D11 on adapter AMD Radeon R9 200 Series (0)
11:51:50.333: D3D11 loaded sucessfully, feature level used: 45056
11:51:50.963: ---------------------------------
11:51:50.963: video settings reset:
11:51:50.963:     base resolution:   1920x1080
11:51:50.963:     output resolution: 1280x720
11:51:50.963:     downscale filter:  Bicubic
11:51:50.963:     fps:               20/1
11:51:50.963:     format:            NV12
11:51:50.964: Audio monitoring device:
11:51:50.964:     name: Default
11:51:50.964:     id: default
11:51:50.964: ---------------------------------
11:51:50.965: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/chrome_elf.dll' not found, loading of module failed
11:51:50.966: [CoreAudio encoder]: CoreAudio AAC encoder not installed on the system or couldn't be loaded
11:51:50.968: [AMF Encoder] Version 1.4.3.11 loaded (Compiled: 1.3.0.5, Runtime: 1.3.0.5, Library: 1;3;0;5;1.2;201611211713).
11:51:51.240: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libcef.dll' not found, loading of module failed
11:51:51.240: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libEGL.dll' not found, loading of module failed
11:51:51.240: Required module function 'obs_module_load' in module '../../obs-plugins/64bit/libGLESv2.dll' not found, loading of module failed
11:51:51.241: Failed to load 'en-US' text for module: 'obs-browser.dll'
11:51:51.241: [browser_source: 'Version: 1.29.0']
11:51:51.242: LoadLibrary failed for 'nvEncodeAPI64.dll': The specified module could not be found.
11:51:51.242:  (126)
11:51:51.324: Couldn't find VLC installation, VLC video source disabled
11:51:51.327: No blackmagic support
11:51:51.358: ---------------------------------
11:51:51.358:   Loaded Modules:
11:51:51.359:     win-wasapi.dll
11:51:51.359:     win-mf.dll
11:51:51.359:     win-dshow.dll
11:51:51.359:     win-decklink.dll
11:51:51.359:     win-capture.dll
11:51:51.359:     vlc-video.dll
11:51:51.359:     text-freetype2.dll
11:51:51.359:     rtmp-services.dll
11:51:51.359:     obs-x264.dll
11:51:51.359:     obs-vst.dll
11:51:51.359:     obs-transitions.dll
11:51:51.359:     obs-text.dll
11:51:51.359:     obs-qsv11.dll
11:51:51.359:     obs-outputs.dll
11:51:51.359:     obs-filters.dll
11:51:51.359:     obs-ffmpeg.dll
11:51:51.359:     obs-browser.dll
11:51:51.359:     image-source.dll
11:51:51.359:     frontend-tools.dll
11:51:51.359:     enc-amf.dll
11:51:51.359:     coreaudio-encoder.dll
11:51:51.359: ==== Startup complete ===============================================
11:51:51.361: All scene data cleared
11:51:51.361: ------------------------------------------------
11:51:51.383: WASAPI: Device 'Realtek Digital Output(Optical) (Realtek High Definition Audio)' initialized
11:51:51.395: WASAPI: Device 'Microphone (Blue Snowball)' initialized
11:51:51.407: [Media Source 'Sheet 1 Far Hack']: invalid audio_buffer_size 1
11:51:51.408: [Media Source 'Sheet 1 Far Hack']: settings:
11:51:51.408:     input:                   http://192.168.1.221:80/cgi/mjpg/mjpg.cgi
11:51:51.408:     input_format:          
11:51:51.408:     is_looping:              no
11:51:51.408:     is_forcing_scale:        no
11:51:51.408:     is_hw_decoding:          yes
11:51:51.408:     is_clear_on_media_end:   yes
11:51:51.408:     restart_on_activate:     yes
11:51:51.408: [Media Source 'Sheet 1 Far Hack']: advanced settings:
11:51:51.408:     audio_buffer_size:       1
11:51:51.408:     video_buffer_size:       50
11:51:51.408:     frame_drop:              AVDISCARD_DEFAULT
11:51:51.408: [Media Source 'Sheet 1 Near House']: settings:
11:51:51.408:     input:                   rtsp://admin:EYEitsky!@192.168.1.216:88/videoMain
11:51:51.408:     input_format:          
11:51:51.408:     is_looping:              no
11:51:51.408:     is_forcing_scale:        no
11:51:51.408:     is_hw_decoding:          yes
11:51:51.408:     is_clear_on_media_end:   yes
11:51:51.408:     restart_on_activate:     no
11:51:51.408: [Media Source 'Sheet 1 Near House']: advanced settings:
11:51:51.408:     audio_buffer_size:       1
11:51:51.408:     video_buffer_size:       500
11:51:51.408:     frame_drop:              AVDISCARD_DEFAULT
11:51:51.408: [Media Source 'Sheet 1 Far House']: invalid audio_buffer_size 1
11:51:51.408: [Media Source 'Sheet 1 Far House']: settings:
11:51:51.408:     input:                   rtsp://admin:EYEitsky!@192.168.1.217:88/videoMain
11:51:51.408:     input_format:          
11:51:51.408:     is_looping:              no
11:51:51.408:     is_forcing_scale:        no
11:51:51.408:     is_hw_decoding:          yes
11:51:51.408:     is_clear_on_media_end:   yes
11:51:51.408:     restart_on_activate:     no
11:51:51.408: [Media Source 'Sheet 1 Far House']: advanced settings:
11:51:51.408:     audio_buffer_size:       1
11:51:51.408:     video_buffer_size:       500
11:51:51.408:     frame_drop:              AVDISCARD_DEFAULT
11:51:51.408: [Media Source 'Sheet 1 Near Hack']: invalid audio_buffer_size 1
11:51:51.408: [Media Source 'Sheet 1 Near Hack']: settings:
11:51:51.408:     input:                   http://192.168.1.210:80/cgi/mjpg/mjpg.cgi
11:51:51.408:     input_format:          
11:51:51.408:     is_looping:              no
11:51:51.408:     is_forcing_scale:        no
11:51:51.408:     is_hw_decoding:          yes
11:51:51.408:     is_clear_on_media_end:   yes
11:51:51.408:     restart_on_activate:     yes
11:51:51.408: [Media Source 'Sheet 1 Near Hack']: advanced settings:
11:51:51.408:     audio_buffer_size:       1
11:51:51.408:     video_buffer_size:       50
11:51:51.408:     frame_drop:              AVDISCARD_DEFAULT
11:51:51.409: [Media Source 'Sheet 1 Scoreboard']: invalid audio_buffer_size 1
11:51:51.409: [Media Source 'Sheet 1 Scoreboard']: invalid audio_buffer_size 1
11:51:51.409: [Media Source 'Sheet 1 Scoreboard']: settings:
11:51:51.409:     input:                   http://192.168.1.213:80/cgi/mjpg/mjpg.cgi
11:51:51.409:     input_format:          
11:51:51.409:     is_looping:              no
11:51:51.409:     is_forcing_scale:        no
11:51:51.409:     is_hw_decoding:          yes
11:51:51.409:     is_clear_on_media_end:   yes
11:51:51.409:     restart_on_activate:     yes
11:51:51.409: [Media Source 'Sheet 1 Scoreboard']: advanced settings:
11:51:51.409:     audio_buffer_size:       1
11:51:51.409:     video_buffer_size:       1
11:51:51.409:     frame_drop:              AVDISCARD_NONE
11:51:51.414: Switched to scene 'Sheet 1'
11:51:51.414: ------------------------------------------------
11:51:51.414: Loaded scenes:
11:51:51.414: - scene 'Sheet 1':
11:51:51.414:     - source: 'Sheet 1 Scoreboard' (ffmpeg_source)
11:51:51.414:     - source: 'Sheet 1 Near House' (ffmpeg_source)
11:51:51.414:     - source: 'Sheet 1 Near Hack' (ffmpeg_source)
11:51:51.414:     - source: 'Sheet 1 Far Hack' (ffmpeg_source)
11:51:51.414:     - source: 'Sheet 1 Far House' (ffmpeg_source)
11:51:51.414:     - source: 'Logo' (image_source)
11:51:51.414: ------------------------------------------------
11:51:51.422: adding 23 milliseconds of audio buffering, total audio buffering is now 23 milliseconds
11:51:53.985: adding 348 milliseconds of audio buffering, total audio buffering is now 371 milliseconds
 

Tomasz Góral

Active Member
Hi,
a have same problems with multiple cameras connected via media source.
My solutions is add parameter FPS, if you camera have 25fps set 50fps.
This quickly empty the buffer, in default set media source don't know what a type is source (live or file), something sources do not regularly send frame e.g. 25fps is new frame every 40ms, if frame is delay 2-4ms, buffer in media source add this time to play and after few minut you see differences.
 

Octopode

New Member
That's a good idea, where do I set the FPS? I don't see an option for it. Is it in the "input format" ?

It's a live stream, btw.
 

Tomasz Góral

Active Member
I was wrong, you must add w in Input format live_flv
More info about this you found on ffmpeg.org, now my all cameras are synchronized.
 

Octopode

New Member
Tomasz thanks for your response. It looks like this did not work for me, I suppose my cameras are just not compatible with live_flv. :(
 

Octopode

New Member
The camera I am using is the Foscam R2, btw.

I have tried now using VLC to get the source, but I'm having the same issue. Is there a specific RTSP setting I need to use to force it to stay in sync? It seems like the camera's stream is refusing to drop frames from the buffer.
 

Eric Lindsey

New Member
Necroing this thread. I'm having the same issue with the same camera. My surveillance computer (which also pulls the video feed in via network) has less than 0.5s response, but I've seen OBS gather 90-120 seconds of latency. Unusable for streaming.

I use the remote feed on my surveillance computer to reposition the camera, but OBS doesn't see it for minutes. Fully reproducible, happens every time.

I don't need zero latency--I'm not streaming video games. But I do need a predictable and consistent latency that I can adjust the audio sync for.
 

Tomasz Góral

Active Member
zero latency is not possible, OBS need time to read header and prepare first frame.
If you use ffmpeg you can reduce time (e.g. probesize, analyzeduration), but OBS don't have this option, you must compile your own version with these parameters.
 
Top