Streaming OBS Sound and Video keep getting out of sync

Tawasquasher

New Member
I'm using an IP Camera and OBS to live stream Squash games. All good when first starting the stream but then after a few minutes the Video freezes for about half a second but the audio keeps going. Now the Video and audio are out of sync and over the next few minute theys slowly move back into sync. I think the sync of Audio and Video also drifts at times. Youtube example here. https://www.youtube.com/watch?v=INyS96MH9AQ or search Tawa Squash Court 4 on Youtube.
I stream 1080p, 50fps and about 5000kB/s. Have tried adjusting lots of OBS settings and IP Camera settings with no success. I also upgraded to a pretty grunty i7 Laptop and now processor usage is only about 2 % when streaming so not a resource issue.
Very frustrating. Any suggestions?
 

Lawrence_SoCal

Active Member
Start by following pinned post in this forum about posting an OBS log (link in my signature)
1. IP cameras run the gamut from cheap to broadcast quality (and price). there is an extent to which you get what you pay for. Cheap IP (security) cameras typically do NOT have a requirement for a consistent processing speed, jitter, latency, etc. so.. sometimes they do ok, and sometimes not. If you have an NDI camera, typically it should have plenty of 'horsepower' to have consistent video output.

Have you tried running the camera at 1080p25 and compared results with running 1080p50 in terms of AV (audio/video) sync?
Are you sure your IP camera can sustain 1080p50? If camera is capable of 1080p50, then usually not at the lower end (cheapest) of cameras. Assuming camera is 1080p50 capable, beware trying to do too much compression on camera to lower bandwidth as that could cause thermal throttling or other bottlenecks/overload in camera. Assuming wired Ethernet from camera to OBS laptop, have you tried using H.264 instead of H.265 (or vice versa)?. Sometimes mfg firmware is optimized for one codec/format, and the other(s) are less maturely optimized (ie half-assed). That will be camera make/model dependent.

Assuming that 2% CPU usage comes from OBS Stats... we'll I get it, BUT that stat is typically meaningless (in most cases, imho, unfortunately). What really matters is overall hardware resource utilization (CPU, GPU, RAM, disk, etc), which requires real-time monitoring (Task Mgr/Resource Monitor, or similar).
The problem with laptops can be thermal throttling (CPU/GPU/SSD, etc performance dropped to prevent overheating) ... and each make/model can possibly require different approaches to determining if indeed you are suffering from such

A suggestion from long ago is to make sure your audio sampling rates are consistent across sources. (check your OBS log, then go into Operating System and adjust as required). Personally, I recommend disabling unused Audio devices (ex Audio Out on HDMI monitor that NEVER has a speaker attached to it, etc)
Then there is making sure you are NOT using WiFi between camera and OBS (and preferably WiFi anywhere in data path at all). If using WiFi from camera, that could easily be the cause of your issue. Or a cheap IP camera that is not consistent in video output (resulting in varying sync).
Or you could have unexpected/background processes on laptop causing issues?
etc.
Have you tried testing and Record (not Stream) only and does sync issue exist then?
 
Last edited:

Tawasquasher

New Member
Thanks for your reply and heres what I found but hasn't solved the problem. I'm using a good quality IP Camera with ethernet connection.
Adjusted Camera 25fps. Changed between H.264 & H.265. Checked CPU usage via Task Manager and OBS is using around 10-20%.
While streaming I watched the OBS preview on the Laptop and it has no issues and is very good quality and never freezes so the IP stream from the Camera is fine. It must be when OBS is creating the stream where the problem is.
Internet speed is plenty and when running a test getting around 200Mbps upload and 150Mbps download.
Have tried dropping the stream rate down to about 3Mbps but no difference.
Here is a link from the youtube stream last night here. https://www.youtube.com/watch?v=C1SL1ZAKij4
If you look at 8:45 the Video pauses then the audio is out of sync. Go foward to about 15:00 and the video has caught up to the audio and is now OK. Again at 15:55 there is a pause and the video and audio are out of sync. This pattern continues for the whole video.
Havn't tested using the record function to see if this is OK but will do over the next few days.
Have also noted the streamed video is not as clear as viewing the IP Camera directly or watching it on the OBS preview screen. There seems to be blurry patches that move around the livestreamed video.
I just don't know what more I can try. Have googled galore but can't find what is causing this and its really frustrating.
Can anyone help please.
 

Lawrence_SoCal

Active Member
start with the first sentence of my prior post. you still haven't posted an OBS Studio log from a Recording and/or Streaming session
I will, and others may, ignore future replies/requests for help if you skip this step

You don't mention system overall CPU usage, which is the critical detail. And what else is going on in the background on that laptop? especially when that lag issues occurs?

Internet speed test are designed for data transfers where Jitter and Latency don't matter, but those are important when livestreaming. And more upload bandwidth than download... I've never seen that before...maybe you got those bandwidth values backwards (reversed)?

When streaming, you are sending, in your case, to YouTube which re-encodes (usually quite heavily) before distributing. So, you should expect local video to be of (much) higher quality than that streamed. For a low motion environment, I stream at 1080p30 7mb/s. for 1080p50 I'd be targeting closer to 10mb/s, if your available upload bandwidth support that. If not, I'd be more inclined to drop to 25fps.
 

Tawasquasher

New Member
Link to logfile.

https://obsproject.com/logs/H3UGfTEjgq1tlzRA

Total CPU usage between 20 & 30 %.

Snip of speed attached showing upload higher than download.

Have tried 25fps which is not very good as a squash ball moves very fast so appears very jittery at the lower frame rate but didn't make a difference to the sync issue. I stream at 8mb/s and Video quality pretty good.

Just had a tornament over the last few days I streamed but not very good as about 80% of the time the video and audio were out of sync so not really very good viewing.

Not sure what else I can try?
 

Attachments

  • Squash Internet speed.JPG
    Squash Internet speed.JPG
    70.7 KB · Views: 8

Tawasquasher

New Member
Did some more testing and found this in the log at exactly the time the video paused for a few hundred milliseconds.

14:38:04.409: warning: Found EOI before any SOF, ignoring
14:38:04.409: fatal: No JPEG data found in image
14:38:04.409: Error decoding video
14:38:04.424: [rtmp stream: 'adv_stream'] User stopped the stream
14:38:04.424: [rtmp stream: 'adv_stream'] Socket send buffer is 1048576 bytes
14:38:04.424: Output 'adv_stream': stopping
14:38:04.424: Output 'adv_stream': Total frames output: 32928
14:38:04.424: Output 'adv_stream': Total drawn frames: 33002
14:38:04.430: ==== Streaming Stop ================================================
14:38:04.441: warning: Found EOI before any SOF, ignoring
14:38:04.441: fatal: No JPEG data found in image
14:38:04.441: Error decoding video
 

konsolenritter

Active Member
Aside of the issues with your log (audio rate mismatch, iGPU,...) take into account, that you get frames from the camera via rtsp. The camera shoots and sends its frames based on its own clock. Even if the camera proofs to deliver the right number of frames per second, this will slightly differ from the internal framerate of OBS (or each other receiving side), which is determined by the host and its cpu/gpu. Its like two clocks: over time they will differ. Your experience is mirrored by other people on the net with other viewers like VLC (freezing while increasing buffering each couple of minutes).

Its a generic issue with decoupled systems. Sounds great to have a camera delivering by IP. But that method has its own drawbacks as you can see. Thats why production sites and studios do have a house clock which drives the sample clock of all equipment.

You seem to have additional usb capture working at 60fps. Please clean up your system to have straight concordance allover your system. Then start to experience with "buffering on", "buffering off" and so on, if available for your media source in question.
 

Lawrence_SoCal

Active Member
That log doesn't show the end of recording/streaming session :(
that log also shows WiFi... so am I understanding correctly that you have an Ethernet connected camera and your Internet connection is WiFi?

in part, that is why I mentioned testing by Recording only (not Streaming)

That is a 5 generation old Ultra-low power (U in CPU model) laptop CPU designed for battery life, not computationally demanding real-time video compositing. Have you looked into determining whether your laptop is thermally throttling? each make/model of laptop can be different... no easy/obvious way in Windows OS that I'm aware of... so you have to do your own research on this.. and it is important/relevant to your use case
 

Tawasquasher

New Member
Have now tested a recording and have exactly the same Video/Audio sync issue as with livestream so can rule out any issues with the Wi-Fi connection.
Also have changed the Video Capture device to 50fps but have now actually removed it for testing purposes as not required and also wanted to eliminate it as a cause of the problem.
Monitored the CPU usage via task manager while streaming and never over about 30% so shouldn't be a problem. OBS is the only app running on the Laptop while streaming.Have attached another link to a logfile with end session included.
https://obsproject.com/logs/yMF1Jj8xOvRud3QO
Have checked settings in the Camera and can't find anywhere to set clocking to lock to the Laptop other than the time which I have changed but still no better.Can't find any buffering on/off options either. Camera is a Provision ISR model DI-340IPE-MVF.
Have attached a youtube example here of a recent livestream. The first Video pause occurs at 7m 51s.
Really feeling like I want be able to find a solution other than trying a different streaming software or swapping out the IP Camera for one with an HDMI output and use a capture card which I do on another court using OBS and have no problems.
Any other suggestion would be greatly appreciated.
 

Tawasquasher

New Member
I'm really at my wits end. Had a brainwave and thought I'd use 2 PC's so I could use a capture card. One PC using VLC and streaming the IP Camera and set to fullscreen. Took the HDMI output from this PC and connected to the input of a Video capture card and the mic connected to the mic input of the capture card. Connected the capure card usb connection to my PC to be used for streaming and selected Video capture device as the input. Was a lot better but still about every 10 minutes Video and audio on the stream would jump out of sync and take about 30 seconds to get back in sync. Then I was checking a livestream and noted the Video was about 5 seconds behind the audio so had to add a 5 secong offset in OBS to correct this but can't be doing this all the time so think I'll have to give up and tell people who want watch live squash just to turn of the bloody sound.
 

Lawrence_SoCal

Active Member
The Provision ISR model DI-340IPE-MVF is a lower-end security camera, for which consistent frame processing is NOT a requirement. so don't assume the video output is stable, especially at 50fps
And granted at only 30% CPU utilization I'd hope your system isn't thermal throttling... but unless you learn the specific monitoring technique required for your model laptop (I'm not aware of a consistent detection method across vendors/models) you can't KNOW your laptop isn't slowing down periodically for thermal reasons
and the obvious issues rockbottom mentioned
 

PaiSand

Active Member
Clearly you need to click on the Analyze button when uploading the log file.

Wi-fi isn't reliable enough.
 
Top