How to synchronize two videos in mpv? I want them to open at exactly the same time. mpv…
- User
How to synchronize two videos in mpv? I want them to open at exactly the same time. mpv 1.mkv & mpv 2.mkv & works ok, but not perfect
- Assistant
To synchronize two videos in
mpvso they start at exactly the same time, you can make use ofmpv's slave mode and control the playback programmatically through the command interface. Here’s how to do it:Option 1: Use
--idleandscriptto synchronize the videos-
Use the
--pauseoption to open the videos in paused mode:mpv --pause 1.mkv & mpv --pause 2.mkv &This ensures both videos are loaded but not playing yet.
-
Once both videos are opened, bring up the terminal and send the
playcommand to both instances at the same time using a script or a single command that communicates with the instances viainput-ipc-server.- Example with two instances and
input-ipc-server(control sockets):
Then, synchronize playback by sendingmpv --pause --input-ipc-server=/tmp/mpv1 1.mkv & mpv --pause --input-ipc-server=/tmp/mpv2 2.mkv &playto both sockets:
This starts playback for both videos simultaneously.echo '{ "command": ["set_property", "pause", false] }' | socat - /tmp/mpv1 & echo '{ "command": ["set_property", "pause", false] }' | socat - /tmp/mpv2 &
- Example with two instances and
Option 2: Use a single instance and
addplaybackYou can load multiple videos into the same
mpvinstance using playlists or the--secondary-subtitleoption:-
Load both videos into a single
mpvinstance:mpv 1.mkv --secondary-file=2.mkvThis opens the second video (
2.mkv) as a secondary file (useful for comparison, such as testing subtitles/audio). -
Alternatively, use a playlist:
mpv --playlist=playlist.txtWhere
playlist.txtcontains:1.mkv 2.mkv
In this setup, controlling both videos simultaneously is easier because they are part of the same instance.
Notes
- The
input-ipc-serverapproach offers precise control over multiplempvinstances. - If perfect synchronization is needed for comparison purposes, video editing software (like FFmpeg or professional tools) might be a better solution.
-