mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.67k stars 2.93k forks source link

Howto: Dump a JSON description of all filters #13017

Open tvraman opened 11 months ago

tvraman commented 11 months ago

Would like to use that as a reflection API to be able to add filters to a running mpv from inside Emacs

guidocella commented 11 months ago

https://mpv.io/manual/master/#json-ipc

tvraman commented 11 months ago

Yes, I have read that section carefully but I still dont know how to use it to get what I want, ie a json dict of all the af options that are available. See what I tried:

So I tried echo '{"af" : ["help"]}' | socat - /tmp/empv-socket {"request_id":0,"error":"invalid parameter"} 19:06:49 tmp $ echo '{"help" : ["af"]}' | socat - /tmp/empv-socket {"request_id":0,"error":"invalid parameter"} 19:07:19 tmp $

Guido Cella @.***> writes: and it got me nothing.

https://mpv.io/manual/master/#json-ipc

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

--

guidocella commented 11 months ago

If you read that carefully you would have seen the very first example using get_property.

tvraman commented 11 months ago

Guido Cella @.***> writes:

:-) I read it carefully but i did not make the connection, still haven't after reading this message will go poke at it some more:-)

For what its worth, making the docs clearer might help -- perhaps add introspection as an example?

If you read that carefully you would have seen the very first example using get_property.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

--

guidocella commented 11 months ago

get_property Return the value of the given property. The value will be sent in the data field of the replay message.

This already seems to clear to me.

tvraman commented 11 months ago

Guido Cella @.***> writes:

Perhaps my question isn't cear then?

What I want --

The JSON equivalent of mpv --af=help

and more generally

mpv --dump-slave-commands-json -- wherein I want all available commands that I can invoke via json-ipc to be dumped out as a giant json; purpose: slurp that into Emacs (package empv.el) and invoke them from the emacs side, with the afore mentioned json dump used to generate interactive completion, type-check args etc.

get_property Return the value of the given property. The value will be sent in the data field of the replay message.

This already seems to clear to me.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

--

guidocella commented 11 months ago

Oh I thought you wanted the current filters. I don't think you can do --af=help via IPC, but you don't need to connect to a specific mpv instance for that, just invoke mpv --af=help like bash and zsh completion scripts do.

guidocella commented 11 months ago

Correction, there is echo '{ "command": ["get_property", "option-info/af/choices"] }' | socat - /tmp/mpvsocket, but this only lists mpv-specific filters. not ffmpeg's. It would good to expand that actually since it is used for completion in the console. But from other programs you can just call the mpv executable and parse the output of mpv --af=help, and e.g. mpv --af=volume=help shows the arguments of that specific filter.

tvraman commented 11 months ago

Guido Cella @.***> writes:

That takes me back to the old ugly world of parseing out the information as I did with mplayer slave mode; I want to do better with mpv. Now that it is clear as to what I want, perhaps turn it into a feature request:-)

Oh I thought you wanted the current filters. I don't think you can do - -af=help via IPC, but you don't need to connect to a specific mpv instance for that, just invoke mpv --af=help like bash and zsh completion scripts do.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

--

tvraman commented 11 months ago

Guido Cella @.***> writes:

this is a better solution; see other reply for why I dont want to parse the output of af=help

Correction, there is echo '{ "command": ["get_property", "option-info/af/choices"] }' | socat - /tmp/mpvsocket, but this only lists mpv-specific filters. not ffmpeg's. It would good to expand that actually since it is used for completion in the console. But from other programs you can just call the mpv executable and parse the output of mpv --af=help, and e.g. mpv --af=volume=help shows the arguments of that specific filter.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

--

guidocella commented 11 months ago

But even if we fix option-info/af/choices, it wouldn't have the arguments of individual filters, assuming that's what you meant with "type-check args".

tvraman commented 11 months ago

Guido Cella @.***> writes:

yes, this whole thing requires a feature -- not a bugfix.

But even if we fix option-info/af/choices, it wouldn't have the arguments of individual filters, assuming that's what you meant with "type-check args".

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

--