Reputation: 13
I'm trying to use mpv's API. I have followed this: https://mpv.io/manual/master/#json-ipc
mpv /path/to/file.mkv --input-ipc-server=/tmp/mpvsocket
.echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpvsocket
in a terminal, and it works (returns JSON output).Now I have spent countless hours not being able to replicate this as PHP 8.2 cURL code. This is only the latest out of numerous different variations I've tried. Yes, I've tried using it without the CURLOPT_URL
, with and without JSON encoding, and just about every "obvious" thing that somebody could suggest. None of them work.
$POST_data =
[
'command' => [ "get_property", "playback-time" ]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '/tmp/mpvsocket');
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, '/tmp/mpvsocket');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($POST_data));
//curl_setopt($ch, CURLOPT_ABSTRACT_UNIX_SOCKET, '/tmp/mpvsocket');
curl_setopt($ch, CURLOPT_VERBOSE, true);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
var_dump(curl_error($ch));
The output is:
* Closing connection -1
bool(false)
string(0) ""
Context: Debian Linux. PHP 8.2.
I have no problems making HTTP(S) requests, even to localhost, from the same kind of code. It seems to only be a problem when "Unix sockets" are involved. But PHP's cURL long since supports this, so it doesn't make any sense. Yes, I've checked so that /tmp/mpvsocket
exists.
What could be wrong?
Upvotes: 0
Views: 163