How to use the command 'mpv' (with examples)

How to use the command 'mpv' (with examples)

The mpv command is an audio/video player based on MPlayer. It allows you to play audio or video files from a URL or local file. You can also perform various operations like jumping forward or backward, changing playback speed, taking screenshots, and displaying webcam or other video input device output.

Use case 1: Play a video or audio from a URL or file

Code:

mpv url|path/to/file

Motivation: You can use this command to play a video or audio file from a specified URL or local file. It is useful when you want to watch a video or listen to an audio file without launching a dedicated multimedia player.

Explanation:

  • mpv: Invokes the mpv command.
  • url|path/to/file: Specifies the URL or path to the video or audio file you want to play.

Example output: The specified video or audio file will start playing in the mpv player.

Use case 2: Jump backward/forward 5 seconds

Code:

LEFT <or> RIGHT

Motivation: When watching a video and you want to go back or forward by a few seconds, you can use this command. It allows you to quickly navigate to a specific part of the video without manually dragging the slider.

Explanation:

  • LEFT: Jumps backward by 5 seconds.
  • RIGHT: Jumps forward by 5 seconds.

Example output: The video currently playing in mpv will jump backward or forward by 5 seconds, depending on the key used.

Use case 3: Jump backward/forward 1 minute

Code:

DOWN <or> UP

Motivation: Similar to the previous use case, this command lets you navigate within a video, but instead of seconds, it allows you to jump backward or forward by 1 minute. This can be helpful when you want to quickly skip to a different section of a longer video.

Explanation:

  • DOWN: Jumps backward by 1 minute.
  • UP: Jumps forward by 1 minute.

Example output: The video currently playing in mpv will jump backward or forward by 1 minute, based on whether the DOWN or UP key is pressed.

Use case 4: Decrease or increase playback speed by 10%

Code:

[ <or> ]

Motivation: If you want to speed up or slow down the playback of a video or audio file, you can use this command. It allows you to adjust the playback speed by decreasing or increasing it by 10% increments.

Explanation:

  • [: Decreases the playback speed by 10%.
  • ]: Increases the playback speed by 10%.

Example output: The video or audio currently playing in mpv will be played slower or faster, depending on whether [ or ] is pressed, respectively.

Use case 5: Take a screenshot of the current frame

Code:

s

Motivation: When you come across a specific frame in a video that you want to capture, you can use this command to take a screenshot. It allows you to save the current frame as an image file for further reference or sharing.

Explanation:

  • s: Captures a screenshot of the current frame.

Example output: A screenshot of the current frame in the video playing in mpv will be saved as ./mpv-shotNNNN.jpg, where NNNN represents a sequentially assigned number.

Use case 6: Play a file at a specified speed

Code:

mpv --speed 0.01..100 path/to/file

Motivation: This command is useful when you want to play a video or audio file at a speed other than the default 1x. You can specify a speed between 0.01 (1% of the normal speed) and 100 (100% of the normal speed).

Explanation:

  • mpv: Invokes the mpv command.
  • --speed: Specifies the playback speed as a percentage.
  • 0.01..100: Defines the desired speed range. Choose any value between 0.01 and 100.
  • path/to/file: Specifies the path to the video or audio file you want to play.

Example output: The specified video or audio file will start playing in mpv at the specified speed.

Use case 7: Play a file using a profile defined in the mpv.conf file

Code:

mpv --profile profile_name path/to/file

Motivation: If you have multiple profiles defined in your mpv.conf configuration file, you can use this command to specify a particular profile for playing a video or audio file. Profiles allow you to customize various settings like video output, audio preferences, and more.

Explanation:

  • mpv: Invokes the mpv command.
  • --profile: Specifies the name of the profile you want to use.
  • profile_name: The name of the profile defined in the mpv.conf file.
  • path/to/file: Specifies the path to the video or audio file you want to play.

Example output: The specified video or audio file will start playing in mpv using the settings defined in the specified profile.

Use case 8: Display the output of webcam or other video input device

Code:

mpv /dev/video0

Motivation: This command is useful when you want to view the output of a webcam or any other video input device directly within the mpv player. It allows you to monitor live video sources without using any additional software.

Explanation:

  • mpv: Invokes the mpv command.
  • /dev/video0: Specifies the path to the webcam or video input device.

Example output: The live video feed from the specified webcam or video input device will be displayed in the mpv player.

Related Posts

How to use the command 'flex' (with examples)

How to use the command 'flex' (with examples)

Flex is a command-line tool used for generating lexical analyzers based on the ’lex’ specification.

Read More
How to use the command 'mamba repoquery' (with examples)

How to use the command 'mamba repoquery' (with examples)

The ‘mamba repoquery’ command is a powerful tool for querying conda and mamba package repositories and package dependencies.

Read More
Using the networksetup command (with examples)

Using the networksetup command (with examples)

The networksetup command is a powerful tool for managing network settings on a macOS system.

Read More