You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mpv step forward is fast but step back is slow #4019
. Step forward. Pressing once will pause, every consecutive press will play one frame and then go into pause mode again.
, Step backward. Pressing once will pause, every consecutive press will play one frame in reverse and then go into pause mode again.
Step forward is faster but step backward is slow. Because i am using some lua scripts to trim video.
how to make both work easily.
If i re encode the video to mjpeg format then it its vert smooth
Reacted by Charles Huber, Mateen Ulhaq, Tama47, MithicSpirit, Erik Bročko, BeztDonkey and Underscore
Djvview has the option of caching decoded frames in memory, is this possible with mpv? Maybe with a user specifiable RAM cache, like djvview? I use mpv for previewing renders and so on, the ability to smoothly play backwards would be really useful.
wow u dev guys r0ck ~ what u write here and in man page !!
with play-dir hack, and tuning the demuxer options,
got it to work with 4K HEVC x265 smooth backwards playback,
video synced with reverse audio, using cpu or gpu decode : -)
I don't know why this has so many positive reactions, doesn't look like it did anything. Doesn't mpv use a cache already? Increasing the cache size doesn't do anything. Depending on the video, stepping back , continues to take on second or more, yet stepping forwards is instant. seek -0.05 exact is just as slow too. These configurations don't change that mpv still does what @/Mia-0 said at the start of the thread, mpv has to decode forwards since the last keyframe to find the frame just one frame ago.
I would prefer if mpv could have a small cache of previous frames.
Reacted by Felix, Lily, Michael Curry and CHEN Xiaosong
with the options i mentioned, it works for me on most video files to go any direction one frame. there is even a hotkey for playing backwards. and that works instantly u can go back and forth in video in any playback speed. if its 4k and x265 one needs a GPU that supports that decoding. in my simple setup mpv can play most video files any speed and any direction. even with reverse sound and pretty instant no delay. hook up a usb playstation controller to controll it, and it is the coolest media player ever. have to experiment with tuning these options to your system though ;)
with the options i mentioned, it works for me on most video files to go any direction one frame. there is even a hotkey for playing backwards. and that works instantly u can go back and forth in video in any playback speed.
Those sets of options don't do anything for me. This might depend on the video codec and mpv configuration. I will test with a sample video and report back. Meanwhile I came up with a funny hack:
, cycle-values play-dir - +
. frame-step
Reacted by Lucas De Angelis, Michal Kundrat, ImmortalZypther, hasezoey, halter42, Tama47, Eric Park, godhand19 and Vinci
ah yes with ur file Buck Bunny single step back is about half the framerate of single frame forward.
but what works for me as a hack is, switching to reverse playback mode, and then single step forward :)
That's a great hack, it works like a charm, thanks! However, I think the . frame-step might be unnecessary? I've tried with and without it and there's no difference, I'm not sure I understand why it's used here.
That's a great hack, it works like a charm, thanks! However, I think the . frame-step might be unnecessary? I've tried with and without it and there's no difference, I'm not sure I understand why it's used here.
Yeah . frame-step is the default already, I just included it as a reminder.
Those sets of options don't do anything for me. This might depend on the video codec and mpv configuration. I will test with a sample video and report back. Meanwhile I came up with a funny hack:
, cycle-values play-dir - +
. frame-step
This is cute, but is it possible to create a faster keybind to only step back one frame by switching the direction, doing a frame-step, then switching direction again?
I tried , set play-dir -; frame-step; set play-dir +, but it does not work as expected.
prolonged or too much playback on play-direction backward can sometimes cause reversal frame queue overflow
i've read that increasing video-reversal-buffer or demuxer-max-back-bytes helps but it can still occur every now and then
it's prone to audio-video desync
it takes two inputs to properly begin stepping frames after changing play-direction (i never understood why) but it's better than waiting 20 seconds just to go back 5 frames
in case you want to observe this, add a line to your osd-status-msg to display video frame count like so:
nvenc_h264_1080p_Q25.mp4
despite the small problems, it's more than enough for my use case, i hope this helps(:
@nucspl Hi, the solution for me is to not use the scripts forward seeking and just leave it at default, and only keybind the backward seeking to the script. This way you don't have to press the key twice. Awesome script, thank you :)
sorry to necro this but i got really annoyed by the slow , backstepping that i made a script to "fix" it
backstep.lua
input.conf changes
there's just a few issues:
prolonged or too much playback on play-direction backward can sometimes cause reversal frame queue overflow
i've read that increasing video-reversal-buffer or demuxer-max-back-bytes helps but it can still occur every now and then
it's prone to audio-video desync
it takes two inputs to properly begin stepping frames after changing play-direction (i never understood why) but it's better than waiting 20 seconds just to go back 5 frames
in case you want to observe this, add a line to your osd-status-msg to display video frame count like so:
nvenc_h264_1080p_Q25.mp4
despite the small problems, it's more than enough for my use case, i hope this helps(:
I used to use a script then reverted to using the mpv input file and playdir which worked much better. I will try your script and see what how well it works in comparison. Well worth the necro if it works. Even if it doesn't, it's definitely something that I hope one day can be improved :)
--play-direction=<forward|+|backward|->
Control the playback direction (default: forward). Setting backward will attempt to play the file in reverse direction, with decreasing playback time. If this is set on playback starts, playback will start from the end of the file. If this is changed at during playback, a hr-seek will be issued to change the direction.
It then goes on to explain why backward playback will usually be slow and always be problematic.
@nucspl Hi, the solution for me is to not use the scripts forward seeking and just leave it at default, and only keybind the backward seeking to the script. This way you don't have to press the key twice. Awesome script, thank you :)
mpv seek
sorry to necro this but i got really annoyed by the slow , backstepping that i made a script to "fix" it
backstep.lua
input.conf changes
there's just a few issues:
prolonged or too much playback on play-direction backward can sometimes cause reversal frame queue overflow
i've read that increasing video-reversal-buffer or demuxer-max-back-bytes helps but it can still occur every now and then
it's prone to audio-video desync
it takes two inputs to properly begin stepping frames after changing play-direction (i never understood why) but it's better than waiting 20 seconds just to go back 5 frames
in case you want to observe this, add a line to your osd-status-msg to display video frame count like so:
nvenc_h264_1080p_Q25.mp4
despite the small problems, it's more than enough for my use case, i hope this helps(:
I used to use a script then reverted to using the mpv input file and playdir which worked much better. I will try your script and see what how well it works in comparison. Well worth the necro if it works. Even if it doesn't, it's definitely something that I hope one day can be improved :)
I've just tried it and it's very smooth. But I still prefer playdir because I don't want to have to hold down the key all the time. So I'm modifying to play continuously in reverse to compare and since it's basically using the same mechanism, the results are the same. I'm also running through the SVP frame interpolation software. Without that, playdirection works perfectly well. With SVP both playdir and you script which uses playdir perform the same. But when holding down the key, that seems to get around the issue.
Activity
stibinator commentedon Sep 20, 2017
Playing back prores (all I-frame) shows the same behaviour.
stibinator commentedon Sep 20, 2017
Djvview has the option of caching decoded frames in memory, is this possible with mpv? Maybe with a user specifiable RAM cache, like djvview? I use mpv for previewing renders and so on, the ability to smoothly play backwards would be really useful.
http://djv.sourceforge.net/
TheSneakySniper commentedon Dec 18, 2020
--demuxer-seekable-cache=yes --cache=yes --demuxer-max-back-bytes=10000M --hr-seek=yes --demuxer-cache-wait=yeskanehekili commentedon Dec 30, 2021
In addition to the tip above I could seek precisely in mts streams using the --hr-seek-deumuxer-offset=1.5 option solved it.
metavolution commentedon Feb 26, 2022
wow u dev guys r0ck ~ what u write here and in man page !!
with play-dir hack, and tuning the demuxer options,
got it to work with 4K HEVC x265 smooth backwards playback,
video synced with reverse audio, using cpu or gpu decode : -)
best video player feature ever ; -)
cache=yes
demuxer-readahead-secs=60
demuxer-seekable-cache=yes
demuxer-max-bytes=1000MiB
video-reversal-buffer=500MiB
audio-reversal-buffer=200MiB
demuxer-max-back-bytes=700MiB
hwdec-extra-frames=256
demuxer-cache-wait=yes
#hr-seek=yes
#demuxer-backward-playback-step=
what might be nonsensical in the above config?
thx 4 all the code
ntevenhere commentedon Nov 5, 2022
I don't know why this has so many positive reactions, doesn't look like it did anything. Doesn't mpv use a cache already? Increasing the cache size doesn't do anything. Depending on the video, stepping back
,continues to take on second or more, yet stepping forwards is instant.seek -0.05 exactis just as slow too. These configurations don't change that mpv still does what @/Mia-0 said at the start of the thread, mpv has to decode forwards since the last keyframe to find the frame just one frame ago.I would prefer if mpv could have a small cache of previous frames.
metavolution commentedon Nov 5, 2022
with the options i mentioned, it works for me on most video files to go any direction one frame. there is even a hotkey for playing backwards. and that works instantly u can go back and forth in video in any playback speed. if its 4k and x265 one needs a GPU that supports that decoding. in my simple setup mpv can play most video files any speed and any direction. even with reverse sound and pretty instant no delay. hook up a usb playstation controller to controll it, and it is the coolest media player ever. have to experiment with tuning these options to your system though ;)
ntevenhere commentedon Nov 6, 2022
Those sets of options don't do anything for me. This might depend on the video codec and mpv configuration. I will test with a sample video and report back. Meanwhile I came up with a funny hack:
2 remaining items
metavolution commentedon Nov 8, 2022
ah yes with ur file Buck Bunny single step back is about half the framerate of single frame forward.
but what works for me as a hack is, switching to reverse playback mode, and then single step forward :)
lucas-deangelis commentedon Dec 9, 2022
That's a great hack, it works like a charm, thanks! However, I think the
. frame-stepmight be unnecessary? I've tried with and without it and there's no difference, I'm not sure I understand why it's used here.ntevenhere commentedon Mar 14, 2023
Yeah
. frame-stepis the default already, I just included it as a reminder.Update step-back keybind
All3xJ commentedon Nov 6, 2023
I fixed by uncommenting the
RIGHT seek 5andLEFT seek -5lines in input.confand also by adding
hr-seek=yesin mpv.confprez commentedon Jul 4, 2024
This is cute, but is it possible to create a faster keybind to only step back one frame by switching the direction, doing a frame-step, then switching direction again?
I tried
, set play-dir -; frame-step; set play-dir +, but it does not work as expected.richardpl commentedon Jul 4, 2024
play-dir - need to cache frames in memory, and changing direction of play probably kills previous state.
nucspl commentedon Nov 12, 2024
sorry to necro this but i got really annoyed by the slow
,backstepping that i made a script to "fix" itbackstep.lua
input.conf changes
there's just a few issues:
play-direction backwardcan sometimes cause reversal frame queue overflowvideo-reversal-bufferordemuxer-max-back-byteshelps but it can still occur every now and thenplay-direction(i never understood why) but it's better than waiting 20 seconds just to go back 5 framesosd-status-msgto display video frame count like so:nvenc_h264_1080p_Q25.mp4
despite the small problems, it's more than enough for my use case, i hope this helps(:
geextahslex commentedon Nov 14, 2024
@nucspl Awesome script, thank you :)
netExtra commentedon Nov 14, 2024
I used to use a script then reverted to using the mpv input file and playdir which worked much better. I will try your script and see what how well it works in comparison. Well worth the necro if it works. Even if it doesn't, it's definitely something that I hope one day can be improved :)
geextahslex commentedon Nov 14, 2024
@netExtra what do you mean by playdir?
netExtra commentedon Nov 14, 2024
From the mpv manual
--play-direction=<forward|+|backward|->
Control the playback direction (default: forward). Setting backward will attempt to play the file in reverse direction, with decreasing playback time. If this is set on playback starts, playback will start from the end of the file. If this is changed at during playback, a hr-seek will be issued to change the direction.
It then goes on to explain why backward playback will usually be slow and always be problematic.
netExtra commentedon Nov 14, 2024
I've just tried it and it's very smooth. But I still prefer playdir because I don't want to have to hold down the key all the time. So I'm modifying to play continuously in reverse to compare and since it's basically using the same mechanism, the results are the same. I'm also running through the SVP frame interpolation software. Without that, playdirection works perfectly well. With SVP both playdir and you script which uses playdir perform the same. But when holding down the key, that seems to get around the issue.
geextahslex commentedon Nov 14, 2024
How do you keybind it?
LonelyFarts commentedon Jun 7, 2025
I find this to be nice. Then you can still step back 1 frame if you need to.
/ cycle-values play-dir - +
. frame-step
One thing I wouldn't mind would be if MPV would use as many resources as it needs. My computer is barely jogging while MPV is lagging.