A/V desync when switching audio tracks
I'm seeing an A/V desync when switching audio tracks. Is there a way to avoid this (maybe seeking in the audio track when a switch happens)?
The desync should be rather minimal, and should recover rather quickly (somewhat depends on audio out buffers).
We could do a seek on track switching to restore it perfectly, but I'd rather avoid triggering a seek, but I'd rather like to avoid implicitly initiating seeks on such an operation.
I was seeing half second delays (well, A-V was .610 or so). Manually seeking back then forward fixed it.
Problem is that it would depend on the computer and video you're playing.
Well, I'm not sure what to do. Personally, I would prefer to leave it as is, because it's actually somewhat more robust, and also faster.
So, while I do not want a seek, we could still handle synchronization somehow. If audio comes too early, we could cut it. If audio comes too late, we could insert silence. Especially the silence thing might be annoying for users, though. What do you think?
It might be fine. It being slightly off might hit something akin to the uncanny valley. I wonder if switching A/V tracks could pause playback, switch the stream, then restore the pause state. I'll test if the desync happens currently when paused when I'm in front of a real keyboard again.
Nope, pausing doesn't prevent the desync.
Sounds like a trival job for a lua script. Is this still a problem?
Yes, if the audio buffers are large enough. I don't see how to fix this with a Lua script.
well, not properly, but just rebind the audio track switching to seek back and forth afterwards.
never mind, a much simpler solution for mathstuf would be to put in his input.conf
SHARP cycle aid; seek 5; seek -5
Not sure if that would actually do the seek though or do it in the same way that solves the problem manually. It wouldn't somehow detect and nullify the noop would it? Anyway, I'm not seeing any problem with alsa, wasapi, or wasapi=exclusive on a 02:42:00 flim. Is this a pulse thing?
Fixed.
Fixed how? @kevmitch's suggestion? Also, yes I use pulse.
If an audio track is enabled, the code for initial audio sync is run, which means no desync can happen (unless such a desync also happens on normal playback start, which means the audio output is behaving strangely/buggy). mpv has been doing this for a while, not sure when.
Also, a recent change makes audio stream switching relatively instant because it gets audio packets earlier.
Also, a recent change makes audio stream switching relatively instant because it gets audio packets earlier.
That was f9f2e1cc4e80a66793249651b74d83c1c8f3a8d4. Isn't done for most file formats.