{"id":13835340,"url":"https://github.com/wis/mpvSockets","last_synced_at":"2025-07-10T07:31:39.982Z","repository":{"id":173925252,"uuid":"177715115","full_name":"wis/mpvSockets","owner":"wis","description":"creates one IPC socket per mpv instance","archived":false,"fork":false,"pushed_at":"2024-02-13T13:03:58.000Z","size":6,"stargazers_count":74,"open_issues_count":3,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-20T20:39:06.729Z","etag":null,"topics":["mpv"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-03-26T04:30:55.000Z","updated_at":"2024-09-25T19:48:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"72c39fcb-422c-474d-b65c-41097856f54b","html_url":"https://github.com/wis/mpvSockets","commit_stats":null,"previous_names":["wis/mpvsockets"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wis/mpvSockets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wis%2FmpvSockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wis%2FmpvSockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wis%2FmpvSockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wis%2FmpvSockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wis","download_url":"https://codeload.github.com/wis/mpvSockets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wis%2FmpvSockets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264545167,"owners_count":23625404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mpv"],"created_at":"2024-08-04T14:00:59.882Z","updated_at":"2025-07-10T07:31:39.690Z","avatar_url":"https://github.com/wis.png","language":"Lua","funding_links":[],"categories":["Input","Lua"],"sub_categories":[],"readme":"# mpvSockets\ncreates a socket for each instance of mpv started, name of the socket is based on the process ID of the mpv instance.\n\ndangling sockets for crashed or killed mpv processes is an issue, i'm not sure if this script should handle/remove them or the clients/users, or both.\n\n# Installation\nDownload the single script file to your mpv-scripts-directory\n## Linux / unixes:\n``` bash\nyour_mpv_config_dir_path=\"$HOME/.config/mpv\";\ncurl \"https://raw.githubusercontent.com/wis/mpvSockets/master/mpvSockets.lua\" --create-dirs -o \"$your_mpv_config_dir_path/scripts/mpvSockets.lua\"\n```\n\n## Windows (untested)\npowershell:\n``` powershell\nInvoke-WebRequest -OutFile \"$env:LOCALAPPDATA\\mpv\\scripts\\mpvSockets.lua\" \"https://raw.githubusercontent.com/wis/mpvSockets/master/mpvSockets.lua\"\n```\n\n# Usage, with Mpv's [JSON IPC](https://github.com/mpv-player/mpv/blob/master/DOCS/man/ipc.rst)\n## Linux / unixes (unix sockets):\na script that pauses all running mpv instances:\nbash:\n``` bash\n#!/bin/bash\nfor i in $(ls /tmp/mpvSockets/*); do\n\techo '{ \"command\": [\"set_property\", \"pause\", true] }' | socat - \"$i\";\ndone\n# Socat  is  a  command  line based utility that establishes two bidirec-tional byte streams  and\t transfers  data  between  them.\n# available on Linux and FreeBSD, propably most unixes. you can also use \n```\n\n## Windows (named pipes):\nquote from https://mpv.io/manual/stable/#command-prompt-example\n\u003e Unfortunately, it's not as easy to test the IPC protocol on Windows, since Windows ports of socat (in Cygwin and MSYS2) don't understand named pipes. In the absence of a simple tool to send and receive from bidirectional pipes, the echo command can be used to send commands, but not receive replies from the command prompt.\n\u003e\n\u003e Assuming mpv was started with:\n\u003e\n\u003e `mpv file.mkv --input-ipc-server=\\\\.\\pipe\\mpvsocket`\n\u003e You can send commands from a command prompt:\n\u003e\n\u003e `echo show-text ${playback-time} \u003e\\\\.\\pipe\\mpvsocket`\nTo be able to simultaneously read and write from the IPC pipe, like on Linux, it's necessary to write an external program that uses overlapped file I/O (or some wrapper like .NET's NamedPipeClientStream.)\n\npowershell client writer and reader (untested):\n``` powershell\n# socat.ps1\n# usage: socat.ps1 \u003cPipe-name\u003e \u003cMessage\u003e\n$sockedName = args[0]\n$message = args[1]\n\n$npipeClient = new-object System.IO.Pipes.NamedPipeClientStream('.', $socketName, [System.IO.Pipes.PipeDirection]::InOut, [System.IO.Pipes.PipeOptions]::None, [System.Security.Principal.TokenImpersonationLevel]::Impersonation)\n\n$pipeReader = $pipeWriter = $null\ntry {\n    $npipeClient.Connect()\n    $pipeReader = new-object System.IO.StreamReader($npipeClient)\n    $pipeWriter = new-object System.IO.StreamWriter($npipeClient)\n    $pipeWriter.AutoFlush = $true\n\n    $pipeWriter.WriteLine($message)\n\n    while (($data = $pipeReader.ReadLine()) -ne $null) {\n      $data\n    }\n}\ncatch {\n    \"An error occurred that could not be resolved.\"\n}\nfinally {\n    $npipeClient.Dispose()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwis%2FmpvSockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwis%2FmpvSockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwis%2FmpvSockets/lists"}