- Home /
Audio lag with video player after seek?
I'm switching the video on a VideoPlayer object by setting a new URL and calling videoplayer.prepare(). After the prepare is complete I set the video players time variable to skip to a predetermined point. When I do this the video plays at the correct time but the corresponding audio is about one second behind. This error does not occur when I do not modify the time variable (i.e. if the video begins playback from the beginning, it seems to sync up ok). I'm assuming this is a bug, but I'd like to know if anybody has encountered this problem and if there is a workaround I could try.
Answer by Snafuu · Oct 14, 2017 at 02:39 PM
I still haven't fixed this issue, but after more testing it seems that certain file formats/codecs synchronize their audio better than others (after seek). Right now I'm only using MP4s (H.264), but the MP4s I re-export with custom settings seem to perform better than the one's I ripped straight off YouTube.
Another variable that could be affecting the sync quality is the length of the videos, as the edited/re-exported clips tend to be shorter than direct rips.
EDIT: I'm closing this question. I found out this is indeed a bug: https://issuetracker.unity3d.com/issues/setting-videoplayer-dot-frame-from-code-offsets-audio
It's been around for a while so hopefully it will be fixed soon :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612140958im_/https://answers.unity.com/themes/thub/images/avi.jpg)