Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-11-20· OpenAIAi2 WildChat-4.8M (AI2)

How to synchronize two videos in mpv? I want them to open at exactly the same time. mpv…

  1. 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

  2. Assistant

    To synchronize two videos in mpv so they start at exactly the same time, you can make use of mpv's slave mode and control the playback programmatically through the command interface. Here’s how to do it:

    Option 1: Use --idle and script to synchronize the videos

    1. Use the --pause option 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.

    2. Once both videos are opened, bring up the terminal and send the play command to both instances at the same time using a script or a single command that communicates with the instances via input-ipc-server.

      • Example with two instances and input-ipc-server (control sockets):
        mpv --pause --input-ipc-server=/tmp/mpv1 1.mkv &
        mpv --pause --input-ipc-server=/tmp/mpv2 2.mkv &
        
        Then, synchronize playback by sending play to both sockets:
        echo '{ "command": ["set_property", "pause", false] }' | socat - /tmp/mpv1 &
        echo '{ "command": ["set_property", "pause", false] }' | socat - /tmp/mpv2 &
        
        This starts playback for both videos simultaneously.

    Option 2: Use a single instance and add playback

    You can load multiple videos into the same mpv instance using playlists or the --secondary-subtitle option:

    1. Load both videos into a single mpv instance:

      mpv 1.mkv --secondary-file=2.mkv
      

      This opens the second video (2.mkv) as a secondary file (useful for comparison, such as testing subtitles/audio).

    2. Alternatively, use a playlist:

      mpv --playlist=playlist.txt
      

      Where playlist.txt contains:

      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-server approach offers precise control over multiple mpv instances.
    • If perfect synchronization is needed for comparison purposes, video editing software (like FFmpeg or professional tools) might be a better solution.