27

How can I use the CLI version of the VLC on OSX?

After installing VLC on OSX, it works fine through the normal GUI process, spotlight, etc. Also, I know it's possible to do

open bla.avi -a vlc

However, when I issue vlc command in the shell, it doesn't work. which vlc in shell doesn't return anything either.

CLI version of VLC is very handy for transcoding, streaming, etc. So it would be nice to have it working.

9
  • 1
    What is your question here? Are you just looking for the command? What have you tried?
    – Baarn
    Commented Dec 19, 2012 at 16:21
  • Under linux when I issue vlc in terminal it tells me to use cvlc I guess it would be the same under OSX.
    – Baarn
    Commented Dec 19, 2012 at 16:22
  • So I'm assuming that you downloaded VLC... it should ship the needed command line tools with the program... it can do transcoding, streaming, "etc", but you need to provide a specific use case in order for us to provide any detailed information. Commented Dec 19, 2012 at 16:22
  • please don't write it doesn't work because I am pretty sure that it works, just not in the way you expect it to. So please tell what you want and what you get instead.
    – Baarn
    Commented Dec 19, 2012 at 16:31
  • 3
    @allquixotic Unfortunately, on OS X, VLC doesn't install the command line version.
    – slhck
    Commented Dec 19, 2012 at 17:34

7 Answers 7

25

The command open bla.avi -a vlc works because OS X is using its Launch Services database to open the application VLC. This doesn't have anything to do with a command line binary of the same name, which isn't installed by default.

The binary you search for is in the VLC.app package, so you can type that into a terminal:

/Applications/VLC.app/Contents/MacOS/VLC -I rc

This will open the interactive command line VLC. Or, execute the following in order to have the above line registered as an alias to vlc:

echo "alias vlc='/Applications/VLC.app/Contents/MacOS/VLC -I rc'" >> ~/.bash_profile

Once you've added this, you need to restart your Terminal. Now type vlc and you'll get to the command line.

If you don't like the interactive interface or would like to use VLC with other options, you need to edit your ~/.bash_profile accordingly, e.g. through open -e ~/.bash_profile.

3
  • 2
    Remove -I rc from the command if you actually DO want the GUI to open via the command line vlc command.
    – MikeiLL
    Commented Dec 13, 2016 at 20:52
  • 4
    @MikeiLL You could also just call open -a VLC. This works with any app in OS X.
    – slhck
    Commented Dec 14, 2016 at 13:12
  • I prefer to call this alias cvlc to make it clear it is the command line VLC (and to also be consistent with the linux version).
    – lenooh
    Commented Oct 26, 2018 at 15:44
3

OS X applications don't usually install any program executables outside their application bundle. As you don't usually interact with them from the command line, they're not put into any folder on your PATH.


If you installed VLC to /Applications, the actual executable is /Applications/VLC.app/Contents/MacOS/VLC.

/Applications/VLC.app/Contents/MacOS/VLC -hwill show some help, and /Applications/VLC.app/Contents/MacOS/VLC --intf ncurses will launch the ncurses UI.

1
  • 1
    the --intf ncurses flag is cool
    – cwd
    Commented Mar 9, 2015 at 2:36
2

To access vlc from the command line, you can create a local symbolic link as below:

mkdir ~/bin
ln -vs /Applications/VLC.app/Contents/MacOS/VLC ~/bin/vlc

To have this command available for all users, you may want to link it into /usr/local/bin instead.

Make sure that your ~/bin (or /usr/local/bin) is in your environmental PATH variable, in other words that your ~/.profile file contains something like:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Above code is default behaviour on Linux.

2

I'd suggest reinstalling VLC with homebrew.

brew install vlc

Besides installing the GUI application, brew adds vlc to the path and you can use it on the command line without setting up anything manually.

1

The dummy interface allows batch operation on the command line. I use a shell script like this saved in /usr/local/bin/vlc:

    export VLC_PLUGIN_PATH=/Applications/VLC.app/Contents/MacOS/plugins
    /Applications/VLC.app/Contents/MacOS/VLC -I dummy "${@}"
1

FYI and/or a tip.

Here're 2 ways to find out the actual path of the app that launches with open command.

Helpful, in case of that the VLC is placed in another directory rather than /Applications, such as /Users/<user>/Applications (~/Applications) or other directories.

Via AppleScript

Simple but it launches the app.

$ osascript -e 'POSIX path of (path to application "VLC")'
/Applications/VLC.app/
$ 
$ osascript -e 'POSIX path of (path to application "GIMP")'
/Volumes/External_HDD/Applications/GIMP/GIMP_v2.8/GIMP.app/

Via lsregister command

Little complicated but won't launch the app.

$ # Path of `lsregister` command
$ #   /System/Library \
$ #     /Frameworks/CoreServices.framework/Versions/A \
$ #     /Frameworks/LaunchServices.framework/Versions/A/Support/
$ 
$ cd /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/
$ 
$ ls
lsregister
$ 
$ # Sample usage
$ ./lsregister -dump | grep -o "/.*\Google Chrome.app" | head -1
/Applications/Google Chrome.app
$ 
$ # Find VLC
$ NAME_APP=VLC
$ ./lsregister -dump | grep -o "/.*${NAME_APP}.app" | grep -v -E "Caches|TimeMachine|Temporary|/Volumes/${NAME_APP}" | uniq
/Applications/VLC.app

Tested on: macOS HighSierra (OSX 10.13.6)

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.
0

First, you need to locate the actual binary executable in the VLC Mac application package. Open Finder, go to the Applications folder, right-click on the VLC app and then click Show Package Contents. Now you can browse what's actually inside.

In this case, the VLC binary is located in the Contents/MacOS folder as file VLC. Open Terminal and enter the exact file path to this, and you'll find the VLC binary executes: /Applications/VLC.app/Contents/MacOS/VLC. If you don't want to use this whole path every time, you can make a symlink and edit your Bash PATH to point to this.

Now that you can call the binary right from the CLI, you probably will want to pick an interface so that you don't have the usual GUI popping up. A full list of available interfaces are at the VLC Interfaces wiki page.

Once you find the working set of commands for your VLC CLI calls which produces your intended output, you'll probably want to use the dummy interface when calling VLC in your program/batch processing. The dummy interface is basically nothing but output in the Terminal like most non-interactive CLI programs.

End result: /Applications/VLC.app/Contents/MacOS/VLC -I dummy [further parameters here]

I recommend using the -vvv parameter so you get extensive log output to help as you test different commands.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .