mirror of https://github.com/mpv-player/mpv
core: change initial sync with --delay, video stream switch
Make A/V sync at the start of playback with nonzero --delay behave the same way as it does when seeking to the beginning later, meaning video plays from the start and audio is truncated or padded with silence to match timing. This was already the default behavior in case the streams in the file started at different times, but not if the mismatch was due to --delay. Trigger similar audio synchronization when switching to a new video stream. Previously, switching a video stream on after playing for some time in audio-only mode was buggy and caused initial desync equal to the duration of prior audio-only playback.
This commit is contained in:
parent
b255b5ad32
commit
ab6c760b3b
|
@ -2712,6 +2712,8 @@ int reinit_video_chain(struct MPContext *mpctx)
|
|||
sh_video->last_pts = MP_NOPTS_VALUE;
|
||||
sh_video->num_buffered_pts = 0;
|
||||
sh_video->next_frame_time = 0;
|
||||
mpctx->restart_playback = true;
|
||||
mpctx->delay = 0;
|
||||
|
||||
if (opts->auto_quality > 0) {
|
||||
// Auto quality option enabled
|
||||
|
@ -4837,7 +4839,6 @@ goto_enable_cache:
|
|||
mixer_setvolume(&mpctx->mixer, start_volume, start_volume);
|
||||
if (!ignore_start)
|
||||
audio_delay -= mpctx->sh_audio->stream_delay;
|
||||
mpctx->delay = -audio_delay;
|
||||
}
|
||||
|
||||
if (!mpctx->sh_audio) {
|
||||
|
|
Loading…
Reference in New Issue