How to use the mpv geometry option on startup?
The --geometry option in the mpv media player allows
users to control the initial size and position of the player window when
it launches. By using specific coordinate and percentage syntaxes, you
can force mpv to open at a precise resolution, snap to specific corners
of your screen, or maintain a consistent window size across different
media files. This article explains how the geometry syntax works,
provides practical examples for common configurations, and details how
to make these window adjustments permanent.
Understanding the Geometry Syntax
The --geometry option relies on a standard X11 window
geometry string format, though it is fully supported across Windows,
macOS, and Linux. The standard syntax follows a specific structure:
--geometry=[[width][xheight]][[+|-]xplus[[+|-]yplus]]
- Width and Height: Defined in either absolute pixels
(e.g.,
1280x720) or as a percentage of your overall screen size (e.g.,50%x50%). - X and Y Offsets: Defined by a plus (
+) or minus (-) sign followed by a pixel value or percentage. A plus sign measures the distance from the top or left edge of the screen, while a minus sign measures the distance from the bottom or right edge.
Common Position and Size Examples
Because the syntax can be dense, looking at standard configurations is often the easiest way to find the setup you need.
| Desired Behavior | Command Line Example |
|---|---|
| Set specific resolution (1080p width, automatic height) | mpv --geometry=1920 video.mp4 |
| Set exact width and height | mpv --geometry=1280x720 video.mp4 |
| Position in top-right corner (maintain original video size) | mpv --geometry=-0+0 video.mp4 |
| Position in bottom-left corner (maintain original video size) | mpv --geometry=+0-0 video.mp4 |
| Set size to half the screen and center it | mpv --geometry=50%x50% video.mp4 |
| Set size to 25% screen width and snap to bottom-right | mpv --geometry=25%-0-0 video.mp4 |
Making the Window Configuration Permanent
If you do not want to type the geometry flag every time you open a video from the terminal, you can save your preferences directly into the mpv configuration file.
To do this, locate your mpv.conf file. On Linux and
macOS, this is typically found in ~/.config/mpv/mpv.conf.
On Windows, it is usually located in
%APPDATA%\mpv\mpv.conf. Open the file in a text editor and
add your preferred geometry setting on a new line without the leading
dashes. For example, to make mpv always open as a 800-pixel wide window
in the top-right corner of your screen, add the following line to the
file:
geometry=800-0+0