Bug Report Audio sync fine until 2 min in, then a second behind

wrice4

Member
Okay! Thanks, I will try 15k for bitrate and buffer size, crf =18, and cpu preset to veryfast and see how that does! Thanks for the continuous help Jim.
 
Interestingly enough, I have an AverMedia LGP and the same thing is happening. I've found a personal solution that works great, and in fact leads me closer to what I think is the problematic component in general.

I've been recording hours and hours straight of GTA V on my LGP recently and noticed I had to restart the device's stream to re-sync my audio. Starting out, my audio would ~always~ be a few milliseconds behind the video. Five minutes in, there would be about a half-second of audio lag. Thirty minutes into streaming I'd have to reset the device stream (change a video setting; close dialog; reset setting; close dialog again) to get the audio more or less back in sync. Still, the audio would always start behind the video by a fraction of a second.

I started trying to fix this by playing with the video buffering and giving it different values. Eventually I got the audio and video to sync upon starting, but strangely the audio lag would be more pronounced. The lag happened like before, but at nearly double the rate of offset so that I'd have to restart the video feed every ten or fifteen minutes.

I killed that buffering option and started thinking that somehow the issue was a discrepancy in framerates, as in the audio was running the equivalent sample rate of 59.94 fps while the video might have been 60 fps (NTSC versus raw PC mode framerates). This would explain things as the audio would be running a tad slower and thus would become offset more and more over a longer period of time. Unfortunately I have no way of regulating individual audio and video stream framerates on my device, nor does OBS's device capture node allow for this (only allows a master FPS change from what I can tell).

So my solution came down to a similar issue I've had with the audio-only directshow device plugin. When using the extra audio source plugin I noticed that no matter what I'd have a delay of about 500 ms on any audio grabbed by that plugin, and that the audio would similarly stretch out over time to become more and more offset. The interesting part is that I could use an audio source physically connected to the same sound card set as my primary audio device in Windows (which also handles audio via directshow since Vista if memory serves) and I'd have a 500 ms delay. That leads me to think that the issue isn't in directshow or directx itself, but in the coding of the plugin (a numerical error or 0-instead-of-1 mistake, perhaps).

So my solution? I took the analog output of my LGP and plugged it into my line-in on my Creative card. Then I looped the line-in into the main audio via the 'listen to this device' option built into Windows. Now I record my game audio as well as desktop audio via my primary sound device, through the main audio input option of OBS (Desktop Audio Device). The end result is that there's perfect sync on the audio (no inherent delay) and the sync never offsets over time.

Ideally I'd like to keep my audio seperate, in case I want to mute the game and not my desktop for instance.

Anyway, the issue seems to be in the capture device module of OBS alone, as well as the similar extra audio device plugin. It seems to me like the audio is simply sampling slower than requested and expected. I can't tell why but adding video buffering also causes issues, which leads me to believe the issue is happening in the buffering of the audio rather than the capturing of it and it's negative effect is only multiplied the more you try to buffer.

Perhaps this could also be a discrepancy in sample rates of the stream versus the capture device? Twitch requires that I stream with an audio bitrate of 160 Kbps while my LGP can only come close to that at 128 or 192 Kbps. Could the issue be in trying to resample the audio down to 160 Kbps from a higher-bitrate source?

I apologize for not listing a system report sheet with my info. In trying to fix the issue one of my steps was a clean install of OBS, and all my log files were deleted. I'm about to start a stream now though, so I can post a log if you guys need it.


EDIT: Twitch also allows certain audio bitrates below 160 and 128 is one of them. I'll try streaming with 128 Kbps on both the stream and the LGP and see if that fixes things. I'll report back if anything changes or not.

SECOND EDIT: Okay, I'm about an hour into my stream and there's no audio offset. It looks like when using a Video Capture or Audio Capture module you need to make sure the devices in question have matching audio bitrates to your stream. Ideally OBS would resample the bitrate for you, but for now it appears not to be handling that too well.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
Holy moley that was a detailed and insightful post. You're basically confirming the same thing paibox has been saying about the audio with the plugin - there definitely is something wrong, he had the suspicion that it was the resampling library, but I'm not entirely convinced because it's the best resampling library out there.

I think it may be related to the way directshow handles audio. Either way, I'm sorry that you've had to resort to a workaround like that. Directshow is a nightmare, and the directshow code is a nightmare. I'm going to end up completely refactoring it to the extent to where it's pretty much a rewrite.

With the buffering option there really shouldn't be audio sync errors with this, but at the same time I have a suspicion it's the rate in which the audio comes in combined with a few other changes I made way back when to the audio system. Ugh, such a nightmare, but I'm going to get in HD PVR 2 and other devices in the process, so it's not a total loss.
 

wrice4

Member
Thanks for that write up! I am glad I am not the only one that has experience this. I could not find another case like mins so I figured my pc was just acting weird after the first couple of minutes, but it seems you have found a solution. The only problem is, I use a blue snowball, which is a usb mic. So I can't plug it into my card like you can and "reroute" it so to say. I know nothing about OBS code or detailed information about the settings so I am really in the dark. Jim, has of course, tried to help me many times on this and maybe yall have found a solution. I just spend hours recording like you mentioned, and then get back and the recording is trash because the audio is offset so much, and so I just delete it.

Jim, I owned the pvr 2, and then sold it and got the elgato. The initial setup was a piece of cake, plug and play, but took me 3.5 hours to get the software to work. It kept force closing, freezing, and would never work for me. I tried it on 3 different pc's. I even downloaded different software for it to work with, that was compatible. I finally got so mad I sold it and bought the elgato the next day. In my opinion, the elgato blows away the pvr 2, but some will disagree, and I can understand.

Anyways, do you think there is a simple fix for me with the audio sync, even though I have a usb mic? Also, do you play GTA V on xbox or ps3? If xbox you can add my name. "The H0lder" <---the 0 is a zero, not the letter.
 

wrice4

Member
carbonFibreOptik said:
Ideally I'd like to keep my audio seperate, in case I want to mute the game and not my desktop for instance.

How do you do that? For instance, when i record my fifa games, the music that is on the game, (before a match), is copyrighted and I can not monetize it because its not my personal music, but in game sound affects are fine. How would I seperate the audio from the recording so that I can mute the game audio until the match starts? Or would I have to do 2 seperate recordings to do that since OBS creates the file under 1 audio source.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
Yea, you're not the only one to experience this with the capture devices. If your device has any configuration settings dialog, try to set the device to use the same sampling rate that OBS is set to (for example, if OBS is set to 44.1khz, make the device use 44.1khz. Or make OBS use 48khz if the device is set to 48khz even). That often fixes the problem for these devices (according to paibox).

In the meantime I'm going to have to hurry up with the new codebase so I can get this stuff fixed sooner.
 
Just doing my duty to help improve what's already the best streaming software out there, Jim. Besides, I'm a technical director so it's what I do. :3

Oh, and don't worry about my workaround, as there was an audio quality issue I was fixing simultaneously while using the newer method. USB power adds static interference (6-7 Db in my case!) to most devices and it's easiest to pick up in the analog audio ports. I effectively got rid of that by plugging the S/PDIF optical from my 360 into a nice Rotel RSP-1068 pre-amp, then downmixed the 5.1 into Dolby Headphone over analog out (and into my sound card). It's an elaborate setup, but it lets me play in 5.1 (using optical output to an Astro Mixamp) while still downmixing at full audio quality to my stream. I can also swap between PC, GameCube, NES, etc. at the push of a button and never have to reconnect wires. Multiple fixes to multiple problems.

Anyway wrice4, for cases like FIFA and all I'd recommend actually lowering the music volume in the game options to zero to avoid copyright issues. That said, the music is already technically licensed by the game publisher and any derivative works using those licenses are allowed to use the music as well, until the owner of the track complains anyway. Currently it's a topic under debate as it's only become an issue recently due to game streaming, but there's no law countering the existing derivative works clause. The only thing you should avoid though is manually playing a music track contained in the game (like in an opening title or something, outside of gameplay). It's only considered legal if the game itself loaded the song, not you.

Oh, and re-routing the usb mic can be done by telling windows to 'listen' to the mic through another device. This can be done by right-clicking the mic in the Windows 'Recording devices' panel of the Sound dialog, clicking properties, clicking the 'Listen' tab in the new dialog, then clicking 'Listen to this device' and selecting what output device to play through. If you're clever you can mix the mic into another recorded device (maybe recording your Stereo Mix device as the OBS mic and mixing your mic into that). Virtual Audio Cable and similar software products also allow you to manually route devices around, but that's a bit more complicated and tends to introduce its own lag.

Oh and regards to the HD PVR 2, I know a lot of friends that use it and it's horrible to decode. Most people end up recording from the preview window via window-region capture. The issue is the decoding of the video stream and transmuxing of the output into a virtual webcam (similarly to how DXtory behaves), which competing devices do via official software. Even though my LGP has such software, the decoding itself eats up almost 20-25% of my top-end core i5, so it's not worth it for something like PC game capture. Console capture is great though, as I'm hitting maybe 50% or so consistently with OBS 32-bit and my LGP.

I'm not saying that you should give up on trying to get the HD PVR 2 running, Jim. Quite contrary, I'd love it if you built a decoder module that worked with USB devices in general. Somehow I think you'd end up making a more efficient decoder than the official LGP Stream Engine or Elgato decoder, at least based on your history with OBS updates. Hell, you might even allow me to use my LGP in 64-bit (the Stream Engine output is a 32-bit device, the LGP itself is 64) and get that extra 5% CPU it generally allows me. I'm rooting for you on that front, and on behalf of my two friends that hate their HD PVRs.
 

wrice4

Member
Glad this thread is being brought back to life. Thanks for the tips both of yall. I did two recordings yesterday and it was perfectly fine. It usually messes up about 90% of the time, but yesterday was a good day, haha. I will double check my sound settings to make sure they are both at the same level.

I did get my monetization turned off on a lot of my fifa games because of the music from the game, like you mentioned. So what I have done now is not start recording til the game actually starts so the only sound that is being recorded from the game is the sound affects, no music. Whats your youtube channel name and I will check out your recordings?

Also, what are your local recording settings? At the moment, mine are:
bitrate - 15k
buffer - 15k
cpu preset - veryfast
crf-18

Do you use the game capture source, or video capture source for the xbox recording device? Also, should I try using my blue snowball as my webcam mic or disable the webcam mic and put the snowball under audio in general settings (which is where it is at the moment)

I know I have both my elgato and webcams "use buffering" checked. With my settings my pc usage runs around 40-70%. I have not recorded any GTA V yet though. I know when I was recording GTA IV, I had to have 2 completely different sources for fifa and gta, because the gta sound had to be offset by a couple of seconds, and the fifa gameplay didnt.

If I need to check, uncheck, or change any settings on my end I am happy to do so. Just let me know what ya'll think. Thanks again for the constant help and I enjoy using OBS.

Also, how come when i click mute on the game audio, it does nothing, not even if I move the slider all the way to the left.
 

wrice4

Member
Update for me:

I went into the elgato settings and the audio that it records at is 44.1, 224 kbps....now OBS does not have a 224 kbps, I think the numbers beside that are 192 and 254 or something like that. My audio was on 122, (I dont know the exact numbers but around there), so I bumped it up as close the the 224 as recommended, so I changed it to 192 kbps. I also upgraded to the newest firmware, which i think is .571 that was released a couple days ago.

So far I have had no audio issues with my recordings. I will keep you updated, but hopefully this fixes it.

Quick question: I have been doing a lot of research because my youtube channel has monetization enabled, but my gaming videos keep getting rejected. The only way I am able to monetize a gameplay video is if I am partnered with a network or have a individual license, am i correct? I have tried everything else, giving credit to the game maker, muting the audio....etc.... my videos get disabled for monetization everytime I upload a GTA V or Fifa 14 video.
 
Top