diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index 0370ec7591..802d36eacc 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -790,7 +790,8 @@ static void demux_close_audio(demuxer_t* demuxer) { static int demux_audio_control(demuxer_t *demuxer,int cmd, void *arg){ sh_audio_t *sh_audio=demuxer->audio->sh; - int audio_length = sh_audio->i_bps ? demuxer->movi_end / sh_audio->i_bps : 0; + int audio_length = sh_audio->i_bps && demuxer->movi_end > demuxer->movi_start ? + (demuxer->movi_end - demuxer->movi_start) / sh_audio->i_bps : 0; da_priv_t* priv = demuxer->priv; switch(cmd) {