How can you open a video on your desktop at a specific time using terminal?

I wanted to know if it was possible to open a mp4 file located on my desktop right at a specific time of the video (e.g. 1 hour 10 minutes 30 seconds) using the terminal?

$ open /Volumes/USERNAME/Desktop/lecture.mp4

This works for starting at the beginning of the video.

But how could I include a specific time (hours, minutes, seconds) at where the video opens/starts at?


Solution 1:

If you have the VLC media player installed, you can run the following example compound command in Terminal to start playing the video file at the 1 hour 10 minutes 30 seconds mark:

open -a /Applications/VLC.app/Contents/MacOS/VLC '/path/to/name.mp4' --args --start-time 4230

Showing on two lines to see the whole compound command:

open -a /Applications/VLC.app/Contents/MacOS/VLC \
    '/path/to/name.mp4' --args --start-time 4230

Using the default macOS open command to open VLC and pass it the --start-time option, the value of which is expressed in seconds.

open options:

  • -a application -- Specifies the application to use for opening the file.
  • --args -- All remaining arguments are passed to the opened application in the argv parameter to main(). These arguments are not opened or interpreted by the open tool.

VLC option:

  • --start-time -- Starts the video here; the integer is the number of seconds from the beginning (e.g. 1:30 is written as 90).

See also: Documentation:Command line