In another post, someone asked about playing two movie windows side by side and starting them at the same point. Here is a token effort at doing so. While I consider VLC to be a useful application, mpv
is my video player.
Quick notes… mpv is a command-line app and must be installed by the user; I will discuss below. Second, the other post mentioned a desire for synced play, which —if possible— isn’t something I’m interested in digging into. Since an install is required, I guess I should also point out that while this works for me, it may not work for anyone else. Presumably, there are other approaches to take. Obviously, it is possible to reorganise this script so as to reduce the duplication or make the whole thing into a droplet.
Script
-- common directory for movie files
set cdc to quoted form of "/Users/username/Movies/test" -- change as appropriate
-- shell command to change directory then run mpv for movie to show on left -- change as appropriate
-- options are: use window, not full screen; mute audio; begin paused; place window in upper left corner; start play nearly 12 minutes in; display timestamp for each frame;
set cmdL to "cd " & cdc & " ; /opt/local/bin/mpv --no-fs --mute=yes --pause \"./movie01.mp4\" --geometry=0:0 --start=717.634 --osd-fractions ;"
-- --autofit-larger=1200 -- unused option to limit window to a maximum of 1200 retina pixels in its larger dimension
tell application "Terminal"
set default settings to settings set "Basic" -- settings set allows choice of profile
do script "" -- dunno why but this opens a new terminal window with the above profile
activate
set position of window 1 to {100, 400} -- positions terminal on left, presumably below video window
tell application "System Events"
keystroke cmdL & linefeed -- enters and runs above command
delay 1
end tell
end tell
delay 2 -- important, at least on a slow mac, to keep some of the command below from being fed to wrong window (which is —at best— a bad thing)
-- similar command for movie to show on right of screen
-- a geometry of 100%:0% places the window all the way to the right and at top; I arbitrarily chose a different start time;
set cmdR to ("cd " & cdc & " ; /opt/local/bin/mpv --no-fs --mute=yes --pause \"./movie02.mp4\" --geometry=100%:0% --start=224 --osd-fractions")
-- --autofit-larger=1200
tell application "Terminal"
set default settings to settings set "Solid Colours" -- different profile (with different colour), optional
do script ""
activate
set position of window 1 to {600, 400} -- positions terminal more to the right
tell application "System Events"
keystroke cmdR
delay 1 -- seems to be a timing issue in getting the command entered entirely in the correct window
keystroke linefeed
end tell
end tell
delay 0.4
-- optionally provide the pid (or unix id) for each `mpv` process
set upid to (do shell script "pgrep 'mpv'")
-->
(* "26776
26796" *)
On mpv options:
- in general, the order of the options in mpv is not important. When using a single file, they can be freely employed either before or after the file specification. When feeding multiple movies, then it is possible to apply different options to the different movie files and then the order can be significant — details in the documentation under ‘per-file options’.
- the geometry option bears reading in the manual. In general, it take the dock and menu bar into account.
Installation of mpv
While you can install mpv manually, it’s probably easiest to use one of the package management tools. I use macports, as it supports my decrepit system and I find the documentation more helpful. I’m not going to post a tutorial here but below is the command to find mpv. Obviously, anyone attempting this should feel comfortable working with the terminal and performing such installations.
Documentation:
Once it is installed, you can find mpv’s package with this command and then follow the instructions at the link above to install it:
% port search --name --glob 'mpv'
And something like this should be returned:
mpv @0.36.0 (multimedia)
mpv is a movie player based on MPlayer and mplayer2.
Documentation for mpv
is available within the terminal using man mpv
(post-installation). It is also online at mpv.io | Reference manual.