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.
No surprises here, the basic syntax for reading a file is
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:
For example, to read chapter 7 in English, type:
2. Reading an Audio CD
To read an audio CD, very similarly, use
3. Reading a Flux
To read a flux from the network:
To read the flux from the webcam:
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
to read in shuffle mode;
to repeat the playlist;
to repeat the current element.
5. Put Video in Full Screen
To put a video in full screen:
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
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
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
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:
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.