How to Change mpv Subtitle Alignment and Margins?
This article provides a comprehensive guide on dynamically adjusting subtitle alignment and margins in the mpv media player. You will learn the essential keyboard shortcuts, custom input configuration mappings, and advanced scripting methods to control your subtitle layout on the fly. Whether you need to quickly shift text out of the way or permanently adjust vertical margins for ultrawide viewing, these techniques will give you precise control over your media playback experience.
Default Shortcuts for Subtitle Adjustments
Out of the box, mpv includes built-in keyboard shortcuts that allow you to adjust the vertical position of your subtitles during playback. These commands alter the subtitle margins dynamically without requiring you to restart the player or edit configuration files.
- **
Ctrl+j**: Shift subtitles down (increases the top margin). - **
Ctrl+k**: Shift subtitles up (decreases the top margin / increases the bottom margin).
Note: These default shortcuts primarily shift the text up and down along the vertical axis. If you need to change horizontal alignment or make complex margin adjustments, you will need to map custom commands.
Customizing Alignment via input.conf
To unlock full control over alignment (left, center, right, top,
bottom) and precise margin adjustments, you can map custom keys in your
input.conf file. This file is typically located in your mpv
configuration directory (~/.config/mpv/ on Linux/macOS or
%APPDATA%/mpv/ on Windows).
You can use the sub-align-x and sub-align-y
properties to change alignment, and sub-margin-y or
sub-margin-x to alter the padding dynamically.
# Change horizontal alignment dynamically
H cycle-values sub-align-x "left" "center" "right"
# Change vertical alignment dynamically
V cycle-values sub-align-y "top" "center" "bottom"
# Fine-tune vertical margins with arrow keys (Shift + Alt)
Shift+Alt+UP add sub-margin-y +5
Shift+Alt+DOWN add sub-margin-y -5
In this setup, pressing H or
V will cycle through the respective
alignment positions, while **Shift + Alt +
Up/Down Arrow** will expand or contract the vertical
margins by 5 pixels per press.
Handling Hardcoded or Advanced Subtitles (ASS/SSA)
Standard subtitle formats like SRT respond perfectly to alignment and margin commands. However, advanced subtitle formats like ASS/SSA often come with hardcoded positions, fonts, and styles embedded by the typesetter.
If your dynamic alignment and margin commands are not working, you
can force mpv to override the embedded styles by using the
sub-ass-override property.
# Toggle overriding advanced subtitle styles
Shift+O cycle-values sub-ass-override "force" "yes"
Setting sub-ass-override to force strips
the subtitle file of its custom positioning, allowing your dynamic
margins, custom fonts, and alignment settings to take effect
instantly.