Stream over LAN - high latency with "Custom Output (FFmpeg)" vs using OBS Virtual Camera + standalone FFmpeg

Fred_

New Member
Hello! Been trying to send a video feed from my computer to my partner's computer, so we can stream two gameplay feeds in one stream. I recently realized that i could start the OBS virtual camera, capture->encode->stream it with ffmpeg, like so:

./ffmpeg.exe -f dshow -i video="OBS Virtual Camera" -vcodec libx264 -preset faster -crf 19 -tune zerolatency -f mpegts udp://192.168.COMPUTER.IP:SOME_PORT

And it actually works great! The only downside is that there's no sound, which makes sense, it's just a "camera".

Later i found the advanced recording options in OBS, and there's a built-in FFmpeg, seems handy! Set it up to stream and... well, it works... but the latency is sky-high now. Streaming the virtual camera with standalone FFmpeg had a latency of 0.5s or so, but streaming with OBS's FFmpeg settings is anything between 4-10 seconds!

Why is it like that? Is there some parameter i can add or change to get closer to the virtual camera mode's latency?
 

mason_o3h

New Member
I had a similar issue: I'm trying to play an SRT network stream in OBS through a Media Source through a source stream and OBS on different machines within a LAN. I've done encoding-side tweaking and ffplay on the destination machine which together gives us <100ms latency. But using the same ffplay parameters in the FFmpeg Options in the Media Source in OBS yields the same ~500ms latency that you're observing. We had thought that there was some minimum latency observable in OBS that blocked it from achieving less than ~500ms (we had been noticing the Laptop webcam source was yielding ~100ms, so there's some latency lower-bound baked into some of the canvas presentation elements). However, we tried a test using VDO.ninja (https://vdo.ninja/) and using the browser source in OBS, and this yielded near-zero latency, even if the browser source was on an OBS machine outside of the LAN. (Notable that VDO.ninja is peer-to-peer WebRTC, so there isn't a currently-supported path for Media Source using this as a network stream.)

We also noticed that playing the original SRT stream as a Network Stream in VLC yielded near-identical ~500-600ms latency when played within the LAN, so we had a briefly-held working theory that this was a VLC issue within OBS rather than an ffmpeg parameter issue. However, interactions with the OBS devs on Discord clarified that the Media Source is implemented using ffmpeg and there's no connection to VLC at all.

At this point we're still blocked but investigating the ~500ms issue you're observing, and am curious to see if you get any further on that. The fact that ffplay gives <100ms latency using identical playback params indicates that this isn't a LAN or bandwidth issue.
 

Fred_

New Member
Well nevermind 500ms, I can't go below 4 seconds unless i go the virtual camera -> ffmpeg route.

These are the settings i used in OBS. I realize they're not identical to the ffmpeg command line method i used for the virtual camera, but I can't see what the problem is.

Untitled.png
 

rockbottom

Active Member
Nature of the beast, RTMP has a buffer that must fill before playback can start. But, lowering your Keyframe Interval may help some since playback will start when the player hooks to a keyframe.
 

Fred_

New Member
Hmm, alright! I guess that's something i can't change in OBS? I guess my feed will have to go the virtual camera route and no audio for now then. Didn't think including audio would be such a hassle...
 

rockbottom

Active Member
The lowest I could get RTMP down to was 3 seconds & that was with the Keyframe Interval @ 1 second. Custom FFMPEG Output > MistServer > VLC
 
Top