Mastering VLC via the Command Line [Linux]

Spread the love

Everybody loves VLC. It works under Windows, Mac, and Linux; it’s free and open source; it does practically everything we expect it to do and more; etc. Yet there is one thing that makes VLC really special for Linux – the command line. Every function, tip, and trick can be used via the command line, with the advantages that we all know about. It becomes easy to make scripts, to gain independence from the graphical interface, to look cool, etc.

Also read: The Best of VLC: 7 Useful Things You Can Do in VLC Media Player

The Basics

No surprises here, the basic syntax for reading a file is

vlc [option] [file(s) path]

If you list more than one file, VLC will read them sequentially as a playlist. The option allows you to define things like full screen, the modules to load, and basically anything you normally access from the menus in the graphical interface. Notice that if you want to launch VLC without any graphical interface, replace “vlc” with “cvlc” in all the commands. Let’s start with the basics.

1. Reading a DVD

To read a DVD, use the command:

vlc dvd://[device][[@title][:[chapter][:angle]]]

For example, to read chapter 7 in English, type:

vlc dvd://@1:8 -audio-language=en

2. Reading an Audio CD

To read an audio CD, very similarly, use

vlc cdda://[device][@[track]]

3. Reading a Flux

To read a flux from the network:

vlc http://IP_server:port

To read the flux from the webcam:

vlc v4l2:///dev/video0

where v412 refers to the API of Video4Linux, and assuming that your webcam is at /dev/video0 (it’s the case for most of us).

4. Managing playlist

I said earlier that you can easily create a playlist by putting more than one file as an argument. You can then define the playing mode with

vlc -Z [files]

to read in shuffle mode;

vlc -L [files]

to repeat the playlist;

vlc -R [files]

to repeat the current element.

5. Put Video in Full Screen

To put a video in full screen:

vlc --fullscreen [file]

or

vlc -f [file]

Advanced Usage

So far, we’ve seen the necessary code for using VLC as a multimedia player. But most of you know that we can use it for much more than that. VLC has a lot of modules which can be used to transcode files, stream them on the Internet, etc. To see all of these modules, type

vlc -l

I will therefore give a few examples of how to use some of these modules. The best way to begin is with the transcoding. The syntax is of the type

vlc [input_stream] --sout \
'#transcode{vcodec=[video_codec], acodec=[audio_codec]}
:standard{access=[type_of_output], dst=[name_of_output], mux=[output_type]}'

Even if it may seem a bit complex at first, each element is pretty easy to understand. In “[input_stream]” you put the file or flux that you want to transcode. The “--sout” indicates the output channel. Both “vcodec” and “acodec” define, respectively, the video and the audio codec used for the transcoding. You can choose among the codecs supported by VLC, like mp4v, MPJG, WMV1, vorb, flac, etc. The list is quite long so you may want to check on the official website. Then, “access” is for saving the transcoded file. The type of output can be “file”, “udp”, “rtp”, or “http”. “dst” stands for destination and defines the name of the output. Finally, “mux” is the format, to select among ts, ps, ogg, avi, etc.

As you may have noticed, the access option makes the difference between transcoding and streaming on the networking. We could do something like

vlc -vvv video.avi -sout
'#transcode{vcodec=mp4v, acodec=mpga}
:standard{access=http, mux=ogg, dst=XXX.XXX.XXX.XXX:Port}'

which will transcode the file video.avi using the codec MPEG4 and MPEG audio layer 2 and then stream it as an http flux at the IP XXX.XXX.XXX.XXX and the port chosen.

As a final note, you can display the help for each module with the line:

vlc -p [module_name] --advanced

Conclusion

Of course, you can still do more with VLC and the command line. Summing up broadly, there is still audio content streaming, using different modules, screen casting, and more. But the syntax is very similar to the examples above, and the wiki should now seem a bit clearer. I invite you to play a little with the syntax, and to make your own examples in order to be more familiar with this great tool.

Do you have other examples? Basic or advanced? Please let us know in the comments.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Adrien

Adrien is a young but passionate Linux aficionado. Command line, encryption, obscure distributions… you name it, he tried it. Always improving his system, he encountered multiple tricks and hacks and is ready to share them. Best things in the world? Math, computers and peanut butter!

Comments are closed