From 213a224eec05cbd86b06abbdd843f2e252658b37 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 17 Sep 2012 19:01:07 +0300 Subject: [PATCH] commands: playback speed: adjust video timing after change When changing playback speed, adjust timing state with the goal of keeping video playback as smooth as possible. This avoids some undesirable video jumps and pauses that occurred previously, but makes some audio issues more apparent. The most obvious audio issue is that if you reduce playback speed suddenly, then audio will be missing for a while, especially if audio output buffers are long. Suppose two seconds of audio are in AO buffers, and you change speed from 8 to 1. The already buffered audio contains the audio for the next 2 * 8 = 16 seconds in compressed form. Thus audio will continue playing at high speed for the next 2 seconds, and then there will be 14 seconds of silence as the audio corresponding to that part was already consumed. There is no simple fix for this: nicer behavior would require keeping a copy of the original normal-speed audio and then after a speed change re-filtering it and replacing the existing buffers with the result. --- command.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/command.c b/command.c index dae8edcffe..a190cdd1c1 100644 --- a/command.c +++ b/command.c @@ -299,8 +299,14 @@ static int mp_property_playback_speed(m_option_t *prop, int action, (action == M_PROPERTY_STEP_DOWN ? -1 : 1); set: M_PROPERTY_CLAMP(prop, opts->playback_speed); + if (opts->playback_speed == orig_speed) + return M_PROPERTY_OK; // Adjust time until next frame flip for nosound mode mpctx->time_frame *= orig_speed / opts->playback_speed; + if (mpctx->sh_audio) { + double a = ao_get_delay(mpctx->ao); + mpctx->delay += (opts->playback_speed - orig_speed) * a; + } reinit_audio_chain(mpctx); return M_PROPERTY_OK; } -- 2.11.4.GIT