How to Loop a Video Segment in MPV?
This article provides a quick guide on how to continuously loop a specific segment of a video using the mpv media player. You will learn the precise keyboard shortcuts required to set the start and end points for an A-B loop, how to clear the loop, and how to configure permanent loops using the player’s configuration file or command-line interface.
Setting an A-B Loop with Keyboard Shortcuts
The most efficient way to loop a specific segment of a video in mpv is by using the built-in A-B loop feature. This allows you to dynamically set the start and end times while the video is playing.
- Set the Start Point (A): Press
Shift + L(or capitalizedL) at the exact moment you want the loop to begin. You will see an on-screen message indicating that the start point has been set. - Set the End Point (B): Press
Shift + La second time at the moment you want the loop to end. The video will immediately jump back to point A and loop the segment continuously. - Clear the Loop: Press
Shift + La third time to clear the loop points and resume normal playback.
Using the Command Line for Precise Looping
If you already know the exact timestamps you want to loop before opening the video, you can launch mpv from your terminal or command prompt with specific flags.
Use the --ab-loop-a and --ab-loop-b options
to define the segment. Timestamps can be formatted in seconds or in
HH:MM:SS format.
mpv --ab-loop-a=00:01:20 --ab-loop-b=00:01:45 video.mp4In this example, mpv will open video.mp4 and
automatically loop the segment between 1 minute 20 seconds and 1 minute
45 seconds.
Infinite Playback for Entire Files
If your goal is to loop the entire video file indefinitely rather
than a specific internal segment, you can use a different flag entirely.
Run the file from the command line with the --loop-file
option:
mpv --loop-file=inf video.mp4To make entire-file looping the default behavior for every video you
open, you can add loop-file=inf to your
mpv.conf configuration file.