### Configure playback start time Source: https://mpv.io/manual/stable Examples of using the --start option to seek to specific timestamps, percentages, or chapters. ```bash --start=+56 ``` ```bash --start=00:56 ``` ```bash --start=-56 ``` ```bash --start=-00:56 ``` ```bash --start=01:10:00 ``` ```bash --start=50% ``` ```bash --start=30 --end=40 ``` ```bash --start=-3:20 --length=10 ``` ```bash --start='#2' --end='#4' ``` -------------------------------- ### Start playlist at specific index Source: https://mpv.io/manual/stable Example of starting playback from a specific index in a playlist file. ```bash mpv playlist.m3u --playlist-start=123 ``` -------------------------------- ### Example config file for script options Source: https://mpv.io/manual/stable Configuration file format for script options. Lines starting with '#' are comments. Boolean values can be 'yes' or 'no'. ```ini # comment optionA=Hello World optionB=9999 optionC=no ``` -------------------------------- ### Example: Load File with Autocompletion Source: https://mpv.io/manual/stable This example demonstrates binding a key combination to open the console, pre-fill it with a file loading command, and set the initial cursor position for autocompletion. ```bash Ctrl+o script-message-to console type "loadfile ''" 11 ``` -------------------------------- ### Expand Path Example (Lua) Source: https://mpv.io/manual/stable Example of using `expand-path` within a Lua script to display the user's mpv configuration directory location on the OSD. ```lua mp.osd_message(mp.command_native({"expand-path", "~~home/"})) ``` -------------------------------- ### Example: Seek to Percent Position Source: https://mpv.io/manual/stable An example of using `script-message-to` to open the console and pre-fill it with a command to seek to a specific percentage. ```bash % script-message-to commands type "seek absolute-percent" 6 ``` -------------------------------- ### Run External Command - Shell Example Source: https://mpv.io/manual/stable Example of running a shell command using 'run'. Note that this example has security implications due to potential shell injection vulnerabilities. ```bash run "/bin/sh" "-c" "echo ${title} > /tmp/playing" ``` -------------------------------- ### Configure profile-restore in mpv.conf Source: https://mpv.io/manual/stable Example configuration for a profile using the copy-equal restore mode. ```ini [something] profile-restore=copy-equal vf-add=rotate=PI/2 # rotate by 90 degrees ``` -------------------------------- ### Property expansion syntax examples Source: https://mpv.io/manual/stable Syntax patterns for conditional and recursive property expansion. ```text ${NAME} ``` ```text ${NAME:STR} ``` ```text ${?NAME:STR} ``` ```text ${!NAME:STR} ``` ```text ${?NAME==VALUE:STR} ``` ```text ${!NAME==VALUE:STR} ``` ```text $$ ``` ```text $} ``` ```text $> ``` -------------------------------- ### Normalize Path Example (Lua) Source: https://mpv.io/manual/stable Example of using `normalize-path` within a Lua script to print a canonicalized path to the OSD. ```lua mp.osd_message(mp.command_native({"normalize-path", "/foo//./bar"})) ``` -------------------------------- ### Raw and formatted property examples Source: https://mpv.io/manual/stable Comparison of formatted, fixed-precision, and raw property output. ```text ${time-pos} ``` ```text ${=time-pos} ``` ```text ${avsync} ``` ```text ${>avsync} ``` ```text ${=avsync} ``` -------------------------------- ### Start mpv with IPC server Source: https://mpv.io/manual/stable Launch mpv with an IPC socket enabled for external communication. ```bash mpv file.mkv --input-ipc-server=/tmp/mpvsocket ``` -------------------------------- ### Example command-line options for script Source: https://mpv.io/manual/stable Command-line option format for script configurations. All keys must be prefixed with the script identifier, separated by hyphens. ```bash --script-opts=myscript-optionA=TEST,myscript-optionB=0,myscript-optionC=yes ``` -------------------------------- ### Example mpv Configuration File Source: https://mpv.io/manual/stable Demonstrates basic configuration options in an mpv.conf file, including setting window size, enabling hardware decoding, and customizing OSD messages. ```ini # Don't allow new windows to be larger than the screen. autofit-larger=100%x100% # Enable hardware decoding if available, =yes is implied. hwdec # Spaces don't have to be escaped. osd-playing-msg=File: ${filename} ``` -------------------------------- ### Configure input.conf for property expansion Source: https://mpv.io/manual/stable Example of using property expansion within an input.conf file to display the current filename. ```text i show-text "Filename: ${filename}" ``` -------------------------------- ### Configure watch history and watch later bindings Source: https://mpv.io/manual/stable Example input.conf configurations to enable automatic playlist creation when selecting files from history or watch later lists. ```text g-h script-binding select/select-watch-history; no-osd set autocreate-playlist filter ``` ```text g-w script-binding select/select-watch-later; no-osd set autocreate-playlist filter ``` -------------------------------- ### Bind OSC Visibility Commands Source: https://mpv.io/manual/stable Example configuration for input.conf to control OSC visibility modes using keyboard shortcuts. ```text a script-message osc-visibility never b script-message osc-visibility auto ``` -------------------------------- ### Demonstrate JSON extensions Source: https://mpv.io/manual/stable Examples of non-standard JSON syntax supported by the mpv IPC protocol. ```json { objkey = "value\x0A" } ``` ```json { "objkey": "value\n" } ``` -------------------------------- ### Start mpv with Windows named pipe Source: https://mpv.io/manual/stable Launch mpv on Windows with a named pipe for IPC. ```cmd mpv file.mkv --input-ipc-server=\\.\pipe\mpvsocket ``` -------------------------------- ### MPV Configuration Source: https://mpv.io/manual/stable Gets the configuration arguments passed to the build system. For older meson versions (< 1.1.0), a hardcoded string of arbitrary options is displayed. ```APIDOC ## GET mpv-configuration ### Description The configuration arguments that were passed to the build system. If the meson version used to compile mpv is older than 1.1.0, then a hardcoded string of a few, arbitrary options is displayed instead. ### Method GET ### Endpoint /websites/mpv_io_manual_stable/mpv-configuration ``` -------------------------------- ### Play a local file as a URL Source: https://mpv.io/manual/stable Use the file:// protocol to access a local file as a URL. Ensure the path starts with a third '/' for absolute paths. ```bash file:///path/to/your/file ``` -------------------------------- ### Adjust Playback Speed via input.conf Source: https://mpv.io/manual/stable Example configuration for input.conf to adjust playback speed by musical semi-tones using the scaletempo filter. ```text [ multiply speed 0.9438743126816935 ] multiply speed 1.059463094352953 ``` -------------------------------- ### Apply and restore profiles via command line Source: https://mpv.io/manual/stable Demonstrates the sequence of applying a profile and restoring the original state. ```text set vf vflip apply-profile something vf add hflip apply-profile something # vf == vflip,rotate=PI/2,hflip,rotate=PI/2 apply-profile something restore # vf == vflip ``` -------------------------------- ### JavaScript Scripting Example Source: https://mpv.io/manual/stable An example of a JavaScript script that leaves fullscreen mode when the player is paused. ```APIDOC ## JavaScript Example ### Description This JavaScript code demonstrates how to observe the 'pause' property and take an action (leaving fullscreen) when the player is paused. ### Code ```javascript function on_pause_change(name, value) { if (value == true) mp.set_property("fullscreen", "no"); } mp.observe_property("pause", "bool", on_pause_change); ``` ``` -------------------------------- ### Escape ASS Example (Lua) Source: https://mpv.io/manual/stable Example of using `escape-ass` within a Lua script to display text with ASS tags verbatim on the OSD. ```lua mp.osd_message(mp.command_native({"escape-ass", "foo {bar}"})) ``` -------------------------------- ### Play CD audio tracks Source: https://mpv.io/manual/stable Use the cdda:// protocol to play audio from a CD. You can specify a start and end track using --start and --end options. ```bash mpv cdda:// --start=#4 --end=#6 ``` -------------------------------- ### Basic Command Line Arguments Source: https://mpv.io/manual/stable Illustrates how command-line arguments are applied to all files when playing multiple files sequentially. All options affect all files. ```bash mpv --a file1.mkv --b file2.mkv --c ``` -------------------------------- ### GET /get_property Source: https://mpv.io/manual/stable Retrieves the value of a specified mpv property. ```APIDOC ## GET /get_property ### Description Returns the value of the given property. ### Method GET ### Request Example { "command": ["get_property", "volume"] } ### Response #### Success Response (200) - **data** (number) - The value of the property. - **error** (string) - Status of the command. #### Response Example { "data": 50.0, "error": "success" } ``` -------------------------------- ### Define Commands to Run Source: https://mpv.io/manual/stable Specify a list of commands for mpv to execute. Commands run at startup or when changed at runtime. ```bash --input-commands= ``` ```bash --input-commands="playlist-play-index 1,set ao-volume 40" ``` -------------------------------- ### GET /vf-help Source: https://mpv.io/manual/stable Retrieves parameter information for a specific filter. ```APIDOC ## GET --vf==help ### Description Prints the parameter names and value ranges for a specific filter. ### Method GET ### Endpoint --vf==help ### Parameters #### Path Parameters - **filter** (string) - Required - The name of the filter to query. ``` -------------------------------- ### GET /profiles Source: https://mpv.io/manual/stable Retrieve information about available configuration profiles. ```APIDOC ## GET /profiles ### Description Show the description and content of a specific profile. If no parameter is provided, it lists all available profiles. ### Method GET ### Endpoint --show-profile= ### Parameters #### Query Parameters - **profile** (string) - Optional - The name of the profile to inspect. ``` -------------------------------- ### GET video-frame-info Source: https://mpv.io/manual/stable Retrieves approximate information about the current video frame. ```APIDOC ## GET video-frame-info ### Description Provides approximate information about the current frame, such as picture type and interlacing status. ### Method GET ### Endpoint video-frame-info ### Response #### Success Response (200) - **picture-type** (string) - Type of picture (I, P, or B) - **interlaced** (boolean) - Whether the frame is interlaced - **tff** (boolean) - Top field first status ``` -------------------------------- ### Property Access Functions Source: https://mpv.io/manual/stable Functions for getting, setting, and deleting mpv properties. ```APIDOC ## mp.get_property(name [,def]) ### Description Returns the value of a property as a string. ### Parameters - **name** (string) - Required - Property name. - **def** (any) - Optional - Default value on error. ## mp.get_property_osd(name [,def]) ### Description Returns the property value formatted for OSD. ### Parameters - **name** (string) - Required - Property name. - **def** (string) - Optional - Default value on error (defaults to empty string). ## mp.get_property_bool(name [,def]) ### Description Returns the property value as a Boolean. ## mp.get_property_number(name [,def]) ### Description Returns the property value as a number (double float). ## mp.del_property(name) ### Description Deletes the specified property if supported. ### Parameters - **name** (string) - Required - Property name. ``` -------------------------------- ### Map Command Line Options to Configuration File Entries Source: https://mpv.io/manual/stable Table mapping common command line flag formats to their corresponding configuration file syntax. ```text Option | Configuration file entry ---|--- `--flag` | `flag` `-opt val` | `opt=val` `--opt=val` | `opt=val` `-opt "has spaces"` | `opt=has spaces` ``` -------------------------------- ### Play a raw YUV sample Source: https://mpv.io/manual/stable Demonstrates how to play a raw video file by specifying the demuxer type and dimensions. ```bash mpv sample-720x576.yuv --demuxer=rawvideo \ --demuxer-rawvideo-w=720 --demuxer-rawvideo-h=576 ``` -------------------------------- ### List All Bindable Keys Source: https://mpv.io/manual/stable Print a list of all keys that can be bound to commands. ```bash --input-keylist ``` -------------------------------- ### Current Audio Output Driver Source: https://mpv.io/manual/stable Gets the name of the current audio output driver. ```APIDOC ## current-ao ### Description Returns the name of the current audio output driver, as used with the `--ao` option. ### Method GET ### Endpoint /websites/mpv_io_manual_stable ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **current-ao** (string) - The name of the current audio output driver. #### Response Example ```json { "current-ao": "pulse" } ``` ``` -------------------------------- ### List All Bindable Commands Source: https://mpv.io/manual/stable Print a list of all commands that can be assigned to keys. ```bash --input-cmdlist ``` -------------------------------- ### Current GPU Context Source: https://mpv.io/manual/stable Gets the current GPU context of the video output driver. ```APIDOC ## current-gpu-context ### Description Returns the current GPU context of the video output driver. This is valid for `--vo=gpu` and `--vo=gpu-next`. ### Method GET ### Endpoint /websites/mpv_io_manual_stable ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **current-gpu-context** (string) - The name of the current GPU context. #### Response Example ```json { "current-gpu-context": "auto" } ``` ``` -------------------------------- ### Current Video Output Driver Source: https://mpv.io/manual/stable Gets the name of the current video output driver. ```APIDOC ## current-vo ### Description Returns the name of the current video output driver, as used with the `--vo` option. ### Method GET ### Endpoint /websites/mpv_io_manual_stable ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **current-vo** (string) - The name of the current video output driver. #### Response Example ```json { "current-vo": "gpu" } ``` ``` -------------------------------- ### Observe Property in JavaScript Source: https://mpv.io/manual/stable Example of using mp.observe_property to trigger a function when the pause state changes. ```javascript function on_pause_change(name, value) { if (value == true) mp.set_property("fullscreen", "no"); } mp.observe_property("pause", "bool", on_pause_change); ``` -------------------------------- ### List Available Scaling Filters Source: https://mpv.io/manual/stable To see a list of all available scaling filters for the `--scale` option, pass 'help' as the value. ```bash mpv --scale=help ``` -------------------------------- ### Custom Initialization (init.js) Source: https://mpv.io/manual/stable Details how to customize the JavaScript environment for all scripts using an `init.js` file. ```APIDOC ## Custom initialization ### Description mpv allows for custom initialization of the JavaScript environment before any script is loaded. This is achieved by placing an `init.js` file in the root of the mpv configuration directory. Code within this file can modify the environment for all subsequent scripts. ### Location - The file should be named `init.js`. - It must be located at the root of the mpv configuration directory (e.g., `~/.config/mpv/init.js`). ### Functionality - Code in `init.js` runs after the JavaScript environment is set up but before any user scripts are loaded. - It can be used to modify global settings, add paths to `mp.module_paths`, or define global utility functions. ### Example To add a custom directory to the module search path for all scripts: ```javascript // ~/.config/mpv/init.js mp.module_paths.push('/path/to/my/custom/modules'); ``` ### Important Note on `mp.module_paths` - Always use `mp.module_paths.push(path)` to add new search paths. - **Do not** use `mp.module_paths = [path]` as this will overwrite all existing paths, potentially breaking default module loading behavior (like `/modules`). ### Behavior - The custom `init.js` file is ignored if mpv is invoked with the `--no-config` command-line option. ### Historical Note - Before mpv version 0.34, the initialization file was named `.init.js` (with a leading dot) and located in the same directory. ``` -------------------------------- ### A-B Looping Points Source: https://mpv.io/manual/stable Sets specific start and end points for looping within a file. ```APIDOC ## --ab-loop-a=