### Example: Play DVD with Specified Device Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst An example demonstrating how to play a DVD using the mpv command and specifying the DVD device path. ```bash mpv dvd:// --dvd-device=/path/to/dvd/ ``` -------------------------------- ### Example: Play Blu-ray with Specified Device Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst An example demonstrating how to play a Blu-ray disc using the mpv command and specifying the Blu-ray device path. ```bash mpv bd:// --bluray-device=/path/to/bd/ ``` -------------------------------- ### Input Configuration Example for Displaying Filename Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/input.rst This example demonstrates how to use property expansion in input.conf to display the current filename when a key is pressed. ```input.conf i show-text "Filename: ${filename}" ``` -------------------------------- ### Seeking and Playback Duration Examples Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Demonstrates various ways to specify start and end times, durations, and chapter ranges for playback. ```bash --start=+56 --start=00:56 ``` ```bash --start=-56 --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' ``` -------------------------------- ### Configure, Compile, and Install mpv with Meson Source: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md Set up the build directory, compile the mpv project, and optionally install the compiled binaries using Meson commands. This process builds mpv within the MSYS2 environment. ```bash # Set up the build directory with the desired configuration meson setup build -Dlibmpv=true --prefix=$MSYSTEM_PREFIX # Compile meson compile -C build # Optionally, install the compiled binaries meson install -C build ``` -------------------------------- ### Input Get Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/javascript.rst Gets input configuration. ```javascript mp.input.get(obj) ``` -------------------------------- ### Get Volume Property Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst This example demonstrates how to retrieve the current volume property using the 'get_property' command. The expected reply contains the volume value. ```json { "command": ["get_property", "volume"] } ``` ```json { "data": 50.0, "error": "success" } ``` -------------------------------- ### VapourSynth Example Script Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/vf.rst An example VapourSynth script that adds borders to the video. The script must read from the 'video_in' variable and pass through timestamps. ```python import vapoursynth as vs from vapoursynth import core core.std.AddBorders(video_in, 10, 10, 20, 20).set_output() ``` -------------------------------- ### Starting MPV in Input Test Mode Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/input.rst Command to start MPV in input test mode, which displays key bindings and their associated commands on the OSD without executing them. ```bash mpv --input-test --force-window --idle ``` -------------------------------- ### Example: Overlay Volume Meter on Video Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Combines audio processing with video overlay. This example splits audio track 1, displays its volume, and overlays it onto video track 1. The 'asplit' filter is used to duplicate the audio stream for separate processing. ```shell --lavfi-complex='[aid1] asplit [t1] [ao] ; [t1] showvolume [t2] ; [vid1] [t2] overlay [vo]' ``` -------------------------------- ### Upscaling with Sharpen5 Method Source: https://github.com/mpv-player/mpv/wiki/Upscaling Example of using the 'sharpen5' scale option in mpv. ```bash mpv --no-config --pause rose.png --geometry=560x368 -vo opengl-hq:dither-depth=8:scale=sharpen5 ``` -------------------------------- ### Observe Volume Property Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst This example shows how to observe changes to the 'volume' property. An event of type 'property-change' will be generated upon modification. Keep the IPC connection open for observation to work. ```json { "command": ["observe_property", 1, "volume"] } ``` ```json { "error": "success" } ``` ```json { "event": "property-change", "id": 1, "data": 52.0, "name": "volume" } ``` -------------------------------- ### Upscaling with Lanczos and Antiringing Source: https://github.com/mpv-player/mpv/wiki/Upscaling Example of using 'lanczos' with antiringing enabled in mpv. ```bash mpv --no-config --pause rose.png --geometry=560x368 -vo opengl-hq:dither-depth=8:scale=lanczos:scale-antiring=1 ``` -------------------------------- ### Install mpv Dependencies with Meson Wrap Source: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md Use these commands to update the Meson WrapDB database and install specific dependencies for mpv. This ensures up-to-date versions of required libraries. ```bash meson wrap update-db meson wrap install expat meson wrap install harfbuzz meson wrap install libpng meson wrap install zlib ``` -------------------------------- ### Upscaling with Sharpen3 Method Source: https://github.com/mpv-player/mpv/wiki/Upscaling Example of using the 'sharpen3' scale option in mpv. ```bash mpv --no-config --pause rose.png --geometry=560x368 -vo opengl-hq:dither-depth=8:scale=sharpen3 ``` -------------------------------- ### Upscaling with Spline36 and Antiringing Source: https://github.com/mpv-player/mpv/wiki/Upscaling Example of using 'spline36' with antiringing enabled in mpv. ```bash mpv --no-config --pause rose.png --geometry=560x368 -vo opengl-hq:dither-depth=8:scale=spline36:scale-antiring=1 ``` -------------------------------- ### Set Playlist Start Index Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Specifies which file in the playlist to begin playback with. ```bash --playlist-start=auto ``` ```bash --playlist-start=index ``` -------------------------------- ### Audio Pitch Shifting Examples Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Illustrates how to adjust the audio pitch up or down using specific multipliers. ```bash --pitch=2 ``` ```bash --pitch=0.5 ``` ```bash --pitch=1.498307 ``` ```bash --pitch=0.667420 ``` ```bash --pitch=1.059463 ``` ```bash --pitch=0.943874 ``` -------------------------------- ### Specify audio filters Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Example of how to specify a list of audio filters to apply to the audio stream. ```bash --af= ``` -------------------------------- ### Get Volume Property as String Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst This example shows how to retrieve the volume property as a string using 'get_property_string'. The data field in the reply will always be a string. ```json { "command": ["get_property_string", "volume"] } ``` ```json { "data": "50.000000", "error": "success" } ``` -------------------------------- ### Get playback time using socat Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst Example of sending a JSON command to get the playback time from mpv via a Unix socket using socat. ```bash > echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpvsocket {"data":190.482000,"error":"success"} ``` -------------------------------- ### mpv Command Line Example with Per-File Options Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Demonstrates how to apply options to specific files in a playlist using '--{' and '--}'. Options between '--{' and '--}' apply to all subsequent files until '--}' is encountered. ```bash mpv --a file1.mkv --b --\{ --c file2.mkv --d file3.mkv --e --\} file4.mkv --f ``` -------------------------------- ### mpv Command Line Example with Basic Options Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Illustrates how command-line options affect all files in a playlist when playing multiple files sequentially. ```bash mpv --a file1.mkv --b file2.mkv --c ``` -------------------------------- ### Play Specific DVD Tracks Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Plays a range of tracks from a DVD, starting from track 4 and ending after track 6. This example demonstrates using --start and --end options for track selection. ```bash mpv cdda:// --start=#4 --end=#6 ``` -------------------------------- ### Example mpv Configuration File Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Demonstrates basic mpv configuration options like autofit, hardware decoding, and custom 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} ``` -------------------------------- ### Print Custom Message After Starting Playback Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Prints a custom string after playback begins, with support for property expansion. For example, to print the filename, use '--term-playing-msg=\'file: ${filename}\''. ```bash --term-playing-msg= ``` -------------------------------- ### Geometry Examples Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Illustrates various ways to set window geometry using pixel and percentage values, including positioning and workspace selection. ```bash 50:40 ``` ```bash 50%:50% ``` ```bash 100%:100% ``` ```bash 50% ``` ```bash 50%x50% ``` ```bash 50%+10+10/2 ``` -------------------------------- ### Example OSD Overlay Usage Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/lua.rst Demonstrates creating, setting data for, and updating an OSD overlay with ASS event formatting. ```lua ov = mp.create_osd_overlay("ass-events") ov.data = "{\an5}{\b1}hello world!" ov:update() ``` -------------------------------- ### Example for ALSA audio device selection Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Demonstrates how to specify an ALSA audio device in mpv, contrasting it with the older MPlayer syntax. ```bash --audio-device=alsa/dmix:default ``` -------------------------------- ### Scaletempo filter with speed multiplier example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/af.rst Example of multiplying speed by a factor of 1.059463094352953 for semi-tone adjustment. Note: This loses sync with video. ```input.conf multiply speed 1.059463094352953 ``` -------------------------------- ### Example: Scale window size with --window-scale Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Sets the video window to be half the size of the video's native resolution. This option is applied before other size-related options like --autofit. ```shell --window-scale=0.5 ``` -------------------------------- ### Scaletempo filter with speed multiplier example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/af.rst Example of multiplying speed by a factor of 0.9438743126816935 for semi-tone adjustment. Note: This loses sync with video. ```input.conf multiply speed 0.9438743126816935 ``` -------------------------------- ### Example: Profile Restore with copy-equal Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Demonstrates using 'profile-restore=copy-equal' to manage video filters. Options are restored only if they match the profile's effective value. ```ini [something] profile-restore=copy-equal vf-add=rotate=PI/2 # rotate by 90 degrees ``` -------------------------------- ### Command Line Options to Configuration File Mapping Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Illustrates how common command line options translate to entries in mpv configuration files. ```text ======================= ======================== Option Configuration file entry ======================= ======================== ``--flag`` ``flag`` ``-opt val`` ``opt=val`` ``--opt=val`` ``opt=val`` ``-opt "has spaces"`` ``opt=has spaces`` ======================= ``` -------------------------------- ### Set Pause Property Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst This example demonstrates setting the 'pause' property to true using the 'set_property' command. The reply indicates success or failure. ```json { "command": ["set_property", "pause", true] } ``` ```json { "error": "success" } ``` -------------------------------- ### GLSL Shader Hook Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Example of a custom GLSL hook structure, including metadata and a basic hook function. This syntax is not stable and may change. ```glsl //!METADATA ARGS... //!METADATA ARGS... vec4 hook() { ... return something; } //!METADATA ARGS... //!METADATA ARGS... ... ``` -------------------------------- ### Example: Loading ASS Styles from File Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Loads all SSA/ASS styles from a specified file to be used for rendering text subtitles. The file syntax matches the [V4 Styles] / [V4+ Styles] section of SSA/ASS. ```bash --sub-ass-styles=my_styles.ass ``` -------------------------------- ### Example: Play Raw YUV Video Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Demonstrates how to play a raw YUV video file by specifying its dimensions and demuxer type. Ensure the file path and dimensions match your video source. ```bash mpv sample-720x576.yuv --demuxer=rawvideo \ --demuxer-rawvideo-w=720 --demuxer-rawvideo-h=576 ``` -------------------------------- ### Observe Volume Property as String Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst This example demonstrates observing the 'volume' property and receiving its value as a string. An event of type 'property-change' will be generated upon modification. ```json { "command": ["observe_property_string", 1, "volume"] } ``` -------------------------------- ### EDL URI Syntax Example Source: https://github.com/mpv-player/mpv/blob/master/DOCS/edl-mpv.rst An example of an inline EDL data URI. Semicolons are used to separate entries instead of line breaks for convenience within a URI. ```URI edl://f1.mkv,length=5,start=10;f2.mkv,30,20;f3.mkv ``` -------------------------------- ### Example: Set minimum window size with --autofit-smaller Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Ensures the window is at least 500 pixels wide and 500 pixels high. The actual size may be larger to maintain the video's aspect ratio. ```shell 500x500 ``` -------------------------------- ### Update and Install Subproject Wraps Source: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md Update the subprojects database and install specific dependency wraps for mpv. This ensures that the correct versions of external libraries are used for the build. ```bash # Update the subprojects database from Meson's WrapDB. meson wrap update-db # Explicitly download wraps as nested projects may have older versions of them. meson wrap install expat Meson wrap install harfbuzz Meson wrap install libpng Meson wrap install zlib ``` -------------------------------- ### Example: Reset Multiple Options on Next File Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Resets 'fullscreen' and 'speed' settings when switching to the next file. ```bash --reset-on-next-file=fullscreen,speed ``` -------------------------------- ### Run Commands on Startup Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Sets a list of commands to be executed by mpv after audio and video playback are about to begin. If mpv is in idle mode with no file loaded, the commands run immediately. ```bash --input-commands="playlist-play-index 1,set ao-volume 40" ``` -------------------------------- ### Configure and Build mpv for Windows Source: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md Set up the Meson build environment for cross-compilation and build the mpv executable. This command creates statically linked, portable binaries. ```bash meson setup -Ddefault_library=static -Dprefer_static=true \ -Dc_link_args='-static' -Dcpp_link_args='-static' \ --cross-file cross-file.txt build ninja -C build mpv.exe mpv.com ``` -------------------------------- ### Install MSYS2 Build Dependencies Source: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md Install essential build tools and dependencies for mpv using the MSYS2 package manager 'pacboy'. This includes Python, Meson, and common libraries. ```bash # Install pacboy and git pacman -S pactoys git # Install MSYS2 build dependencies and a MinGW-w64 compiler pacboy -S python pkgconf cc meson # Install key dependencies. libass and lcms2 are also included as dependencies # of ffmpeg. pacboy -S ffmpeg libjpeg-turbo libplacebo luajit vulkan-headers ``` -------------------------------- ### Use Profiles Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Applies specified profiles. Use '--profile=help' to display a list of defined profiles. ```bash --profile= ``` -------------------------------- ### Example mpv Config File with Profiles Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/mpv.rst Shows how to define and use profiles in mpv configuration files for different playback needs, including network and low-latency settings. ```ini # normal top-level option fullscreen=yes # a profile that can be enabled with --profile=big-cache [big-cache] cache=yes demuxer-max-bytes=512MiB demuxer-readahead-secs=20 [network] profile-desc="profile for content over network" force-window=immediate # you can also include other profiles profile=big-cache [reduce-judder] video-sync=display-resample interpolation=yes # using a profile again extends it [network] demuxer-max-back-bytes=512MiB # reference a builtin profile profile=low-latency ``` -------------------------------- ### Enable Additional mpv Features Source: https://github.com/mpv-player/mpv/blob/master/DOCS/compile-windows.md Add these arguments to the Meson setup command to enable specific features and their dependencies. Meson will automatically download and build them. ```bash -Dlua=enabled -Djavascript=enabled -Dlcms2=enabled -Dlibplacebo:lcms=enabled ``` -------------------------------- ### MPEG-4 Part 10 (AVC/H.264) Encoding to MP4 Source: https://github.com/mpv-player/mpv/blob/master/DOCS/encoding.rst Example command for encoding to MP4 container using H.264 video and AAC audio. Similar to the MKV example but targets the MP4 format. ```bash mpv infile --o=outfile.mp4 --ovc=libx264 --ovcopts=preset=medium,crf=23,profile=baseline --oac=aac --oacopts=b=128k ``` -------------------------------- ### Expand Path Example in Lua Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/input.rst Demonstrates using the 'expand-path' command 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/"})) ``` -------------------------------- ### Initial Audio Synchronization Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Controls whether mpv synchronizes audio to video at the start of playback or after seeking by default. Disabling this option allows immediate start of both streams even if timestamps differ. ```bash --initial-audio-sync= ``` -------------------------------- ### Example: Reset All Options on Next File Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Attempts to reset all settings that were changed during playback when switching to the next file. ```bash --reset-on-next-file=all ``` -------------------------------- ### Example: Autofit window to screen dimensions with aspect ratio Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Limits the window size to be no wider than 70% of the screen width and no higher than 60% of the screen height, while respecting the video's aspect ratio. This ensures the window fits within screen boundaries. ```shell 70%x60% ``` -------------------------------- ### Get Time in Milliseconds Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/javascript.rst Returns the current time in milliseconds. ```javascript mp.get_time_ms() ``` -------------------------------- ### Basic Key Bindings in input.conf Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/input.rst Example of mapping keys to commands in the input.conf file. The 's' key takes a screenshot, and the left arrow key seeks forward by 15 seconds. ```input.conf s screenshot # take a screenshot with the s key LEFT seek 15 # map the left-arrow key to seeking forward by 15 seconds ``` -------------------------------- ### Get Environment Variable Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/javascript.rst Retrieves the value of a specified environment variable. ```javascript mp.utils.getenv(name) ``` -------------------------------- ### Get Process ID Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/javascript.rst Retrieves the process ID of the MPV player. ```javascript mp.utils.getpid() ``` -------------------------------- ### Example: Set window width to 1000 pixels Source: https://github.com/mpv-player/mpv/blob/master/DOCS/man/options.rst Forces the window width to a specific pixel value (1000 pixels) while preserving the video's aspect ratio. This is useful for consistent window sizing. ```shell 1000 ```