-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you get current play position programmatically? #3370
Comments
Something like this?: low-batt@gag ~$ echo '{ "command": ["get_property", "time-pos"] }' | socat - /tmp/mpv-socket | jq '.data | strftime("%T")'
"00:01:04"
low-batt@gag ~$ I used Homebrew to install socat and jq. Then I brought up IINA and selected Preferences / Advanced and enabled advanced settings. Under "Additional mpv options" I clicked on
I then restarted IINA for the changes to take effect. IINA is a graphical user interface for the mpv media player. That player is designed for command line use and has no real GUI, only a small controller on top of the video for basic control. IINA provides a full featured GUI for mpv. Many mpv features are available in IINA. From the mpv manual:
This allows us to use mpv's JSON IPC API. See that section of the manual for examples. This sends a command to get the current position in seconds: low-batt@gag ~$ echo '{ "command": ["get_property", "time-pos"] }' | socat - /tmp/mpv-socket
{"data":64.254000,"request_id":0,"error":"success"}
low-batt@gag ~$ Then jq is used to parse the JSON, extract the value of the data key and convert the seconds to a time string. |
Wouldn't it be easier to just have playback time as an optional sticky display in IINA so when someone is transcribing or taking notes on the video in a separate app all they have to do is glance at the playback time and write it down? Given that's not an option/feature, I tried the instructions above. There are some assumed steps that I (a non-programmer) am not aware of so it's not working for me.
Any help greatly appreciated. |
@ELgit Yes, my above instructions could use some more details. Don't worry, we will get this to work for you. The following is a partial answer. I need to get this working using Automator. Using Automator we should be able to automate this so that one key press inserts the time. Still working on that. Ran out of time today. For now lets get this working for you from terminal.
Yes. I'm sure we could come up with an easier way to do this with a new feature. But the question posed by this issue was not about that. So the answer given addresses how to do this with IINA as it is today. A request for a new IINA feature to make this easier should be entered as a new feature request issue. There are plans to add AppleScript support. That might make this easier. I should have included a picture showing how to use Then restart IINA. This setting causes IINA to open a socket for inter-process communication (IPC) at Once IINA is listening for commands then while playing a movie you should be able to paste the following command sequence into terminal:
After running that command pasting into a TextEdit window added this to the document:
To update the pasteboard with the press up arrow in terminal to recall the previous command and then press return again. The technologies involved in the command sequence:
The next step is to get something like this running under Automator and assign a shortcut key. I will investigate that. |
This can be easily done under the plugin system, which should be available in 1.4.0. We can release a beta version as soon as it's merged. |
As @lhc70000 indicated this will be easier to accomplish once planed features are added to IINA in an upcoming version. With IINA 1.3.0, using Automator I was able to configure a shortcut key and paste into
do shell script "export PATH=\"$PATH:/opt/homebrew/bin\";echo '{ \"command\": [\"get_property\", \"playback-time\"] }' | socat - /tmp/mpv-socket | jq -r '.data | strftime(\"%T\")' | pbcopy"
tell application "System Events" to keystroke "v" using command down
To test this is working open The tricky part is to insure the script is not blocked by macOS security, thus the need to grant applications permissions in |
Hello, I'm a transcriber and I used to use VLC for transcriptions. I have to insert timestamps into my transcript, so I have an applescript that can copy / paste the current VLC play position into my transcript, like this: [00:03:32].
Is there any way to access the play position programmatically in IINA? A terminal command or so? If the play position were in the window title I could access it via applescript, but it doesn't show it in the window title either...
The text was updated successfully, but these errors were encountered: