-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--ao=dsound without --autosync=4 causing video to stutter #98
Comments
What audio output? Does it happen with --ao=null? Does it happen with --no-audio? Setting that value as default for autosync might not be a bad idea, but I'll have to see whether it can have bad effects on perfectly working audio outputs, or what's the cause in your case. |
mpv 64-bit git-0e07189 Issue occurs: Issue does not occur: There is also a separate issue, where vsync can be way off and stutter constantly no matter what the setting depending on when exactly during a screen refresh process mpv presents its first video frame after playback start or seek. If you re-seek once or twice, it will often resolve it. This secondary issue isn't unique to mpv, other dumb renderers on Windows (i.e. Haali renderer) which don't have special vsync correction logic also have this issue. |
Did this problem exist on mplayer2 too, or is it a regression? Basically, it would mean that either the ao_dsound and ao_openal outputs are broken, or that audio on windows doesn't provide a viable time source for some reason.
How exactly does this happen? The playloop should take vsync timing into account, as long as vsync actually blocks. So, if there is an offset between intended presentation time and actual presentation time, it should be compensated quickly. On the other hand, it appears modern video drivers don't like blocking on buffer swapping anymore, so this mechanism breaks often. (Actual vsync aware timing is available on vo_vdpau only.) |
The need to use --autosync=4 also exists with mplayer2.
Possibilities include:
The accepted solutions on Windows are usually a combination of, Reclock (replaces jittery audio clock, syncs system clock, speeds up or slows down playback rate exactly match vsync if possible, resamples audio to keep sync with playback rate changes), a video renderer which performs managed vsync presentation, and fullscreen exclusive mode which is often more reliable than windowed mode. madVR also has its vsync adaptive blending (smooth motion frame rate conversion) to display frames on an optimal timeline, and eliminate judder. Though before you can worry about judder, you first need to eliminate potential causes of arbitrary stuttering. Maybe you could do something to delay playback a few millisecond and make a best effort to ensure at least the first frame is aligned with monitor refresh. Otherwise you'd need some way to actually detect this occasional constant stutter problem, and automatically correct it during playback. From my testing, setting --mc to a value greater than 0 (disabled) just makes the stuttering problems worse. Yet another oddity I've noticed is that mpv seem to have a higher tendency to stutter on Windows when using the --quite or --really-quite switches to silence console output. Does disabling console output make mpv "sleep" more often and/or query multimedia timers less often between workloads? |
By the way, the default value for --mc can't be set from command line (using --mc simply overwrites it). By default it's 0.1 * duration of the video frame.
No. All what should happen is that mpv writes less often to the terminal. |
I'll go back and edit my posts then. I've been using both --autosync=4 & --mc=0 all along in my config file to fix the stuttering. I didn't realize that 0 wasn't the default value for --mc. |
The --autosync option is not completely sane, so I'll wait for the outcome of your tests.
Editing is bad. It's hard to see what changed, or that somebody changed something at all. Those who mainly use e-mail to communicate on the issue tracker won't see the edited replies. Better make new posts. |
What did you need me to test? As far as my edits, I essentially just changed every post with --autosync=4 only to --autosync=4 --mc=0 because using both together are what fixed the stuttering and initially prompted me to create this issue report. Used alone, neither completely resolve the issue. |
Sorry about that, accidentally hit Close instead of Comment.
I do have the somewhat bad habit of posting too quickly and then going back to re-edit, adding anything I forgot. I'll try to get into the habit of creating more new posts, if you don't check the issue tracker directly very often. |
OK. Did you try with --softsleep too? This should help if the sleep function. (mpv just uses the Sleep() function, with --softsleep it will do active waiting for up to 11 ms to avoid timer resolution issues with Sleep. Although we do request 1 ms resolution with timeBeginPeriod.) |
Yes, --softsleep was one of the switches I initially tested, but it didn't help at all. |
Well, I find it rather strange that this helps. --mc=0 actually disables the logic to time against vsync. Together with --autosync=4, it assumes that the decoded audio and video are perfectly in sync, but corrects the timing by 1/4 of the difference between video time and actually played audio time, or something like this. I think in theory higher values of --mc might help you. How is it with --no-audio, by the way? In that mode there's no synchronization at all, and it should strictly time according to video PTS (with no consideration for vsync). Anyway, I think it's better for now not to enable these options by default (even if they help sometimes), and wait until we get something like syncing audio to video instead. |
As mentioned in above, the issue does not occur with --no-audio, and using values of --mc >0 continue to make the stuttering an order of magnitude worse with audio enabled.
Okay. Were you ever able to personally confirm if this strange behavior was Windows OS specific? All I know is that mpv was unbearable to use from all the stuttering until I changed these options, but if it doesn't work for everyone, I would agree that it wouldn't make sense to make this the default setting. It's just unfortunate that mpv is essentially broken out-of-box on my Windows 7 computers.
LAV Audio may have something like this in its Auto A/V Sync correction. |
Currently I don't have access to a real windows where I could actually test this (it would require getting some test media there too...)
From what I know about the mpc-hc world, this is what reclock is doing. |
Reclock is a combination of audio resampling + replacing the reference clock & actively reducing clock jitter + speed-up/slow-down playback to match refresh rate. The thing about Reclock, is that its designed for refresh rates which are a multiple of the movie framerate, as well as things like PAL->NTSC. If the refresh rate isn't a near multiple of the movie frame rate, all the corrections it performs are disabled. That LAV Audio thing is something completely different, more about fixing decoded audio jitter and ensuring sync is maintained with the video timestamps. Not vsync related at all. |
You mean that jitter stuff in CLAVAudio::Deliver? Looks pretty simple, not sure if not something similar is hidden somewhere in the mplayer code. Possible that it isn't, though. On the other hand, sync is never adjusted abruptly, so some jittering shouldn't have such a big impact IMO. But it also depends how big the jitter is. Have you tested with a raw audio source? |
Yes, its the code which makes use of the following functions to adaptively correct jitter and re-sync when needed: m_bUpdateTimeCache In some ways I doubt that lacking something like this could in any way be related to the stuttering problem in mpv, but who knows.
If you are talking about LAV Audio "Auto A/V Sync", it is automatically disabled for audio-only sources I believe. |
Does it happen with |
Try how large you can make the value passed to With The change applied without Also, try the following patch: http://sprunge.us/MANS (it also doesn't change behavior). Play a few seconds of video with |
As mentioned in #98 (comment) the issue does not occur with After further testing (lachs0r's 2015-01-29 Win32 build), I'm unsure how much Occasionally I'll see stuttering with
wasapi wasn't implemented when I originally opened this issue, so it's possible that this Issue may primarily be caused by audio clock variation in I'm also noticing that overriding I'll see if I can try your patches this weekend, assuming I don't have any trouble updating my cross-compile VM to mpv's new waf build system. Last time I built mpv myself was over 6 months ago. |
You can use this: https://github.com/lachs0r/mingw-w64-cmake Notice the prebuilt VM image that has all the build dependencies preinstalled. With that, you can get binaries with the same configuration as those on my |
Thanks, I'll look into that later. A little bit eariler, I already ended up using rossy's MSYS2 guide from https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md#native-compilation-with-msys2 which seemed to go smoothly for compiling a quick dynamic mpv build on Windows. |
patch1 console logs: |
patch2 dump-stats logs: |
Looks to me like
Maybe the coarse playback position reporting of dsound is really a problem, wasapi on the other hand looks pretty much perfect. Can you try running with: |
|
So, is ao_null or --no-audio in any way smoother than ao_wasapi? (With no additional options.) |
Only this, which I've now been able to confirm also occurs occasionally with The apparent 'broken-delay' stuttering (the problem I originally opened this issue for) I believe only affects |
I don't think we'll ever bother to fix ao_dsound. It's more likely that we'll just remove it. |
I've been doing some testing on couple Windows 7 x64 computers (nvidia & ati gpu), and notice that the opengl and direct3d_shaders output drivers stutter frequently with autosync=0, the default value. In both cases using a low value of autosync=4 along with --mc=0 resolved the issue.
Has anybody else noticed this?
Would there be any merit for mpv to enable ---autosync=4 and --mc=0 by default?
The text was updated successfully, but these errors were encountered: