Can I Use mpv to Record Desktop Screen or Webcam?
While mpv is primarily celebrated as a lightweight,
highly customizable media player, it is also capable of capturing both
your desktop screen and webcam input. By leveraging its powerful
underlying framework—specifically its integration with
FFmpeg and system capture utilities like
gdigrab on Windows or v4l2 (Video4Linux2) and
x11grab on Linux—mpv can double as a recording or streaming
tool. This article provides a quick guide on how to configure and
execute commands to capture your desktop or webcam feed directly through
the mpv player.
Recording Your Desktop Screen
To capture your screen using mpv, you need to instruct the player to open a device input stream rather than a traditional media file. The exact command depends entirely on your operating system.
On Windows
Windows utilizes the gdigrab device driver to capture
desktop graphics. You can run the following command in your command
prompt or PowerShell:
mpv av://gdigrab:desktop --profile=low-latency
On Linux (X11)
Linux users running an X11 display server can use the
x11grab virtual input device. To open your current display
screen, use:
mpv av://x11grab::0.0
Note: If you wish to save the stream directly to a file instead of just previewing it live on your screen, you can append the
--stream-record=output.mp4flag to your command.
Capturing Webcam Input
Accessing your webcam follows a similar logic but points to your system’s video capture hardware instead of the display buffer.
On Windows
Windows handles webcam devices via dshow (DirectShow).
First, you may need to know your webcam’s exact name, but you can often
trigger the default camera using:
mpv av://dshow:video="Integrated Camera"
On Linux
Linux systems map webcams to device nodes, typically found under
/dev/video*. You can stream your webcam directly using the
Video4Linux2 (v4l2) driver:
mpv tv:// --tv-device=/dev/video0
Important Limitations to Keep in Mind
While using mpv for these tasks is highly efficient for quick previews or lightweight captures, it does come with a few notable drawbacks compared to dedicated software like OBS Studio:
- Audio Configuration: Capturing synchronized system audio or microphone input simultaneously requires complex, advanced command-line arguments combining multiple input streams.
- No GUI Controls: There are no visual buttons to pause, crop, or adjust resolution on the fly; everything must be predefined in your terminal command.
- Performance: Because it relies on basic FFmpeg hooks, it may not be as hardware-optimized for high-framerate gaming capture as native tools.