Skip to content

The Moving Parts

Outcome: you can name the piece responsible when something in VLC behaves oddly — the file, the decoder, the output, the interface — and you have met the stream output chain that chapters 8, 9 and 11 are built from.

VLC is not one lump of program. It is a small core surrounded by hundreds of modules — plug-in pieces, each doing one job: reading a kind of file, decoding one codec, drawing video one way, making sound another. The lab counted this build's modules:

$ cvlc --list | wc -l
518

(Five hundred and eighteen module help entries; transcript t09.) When VLC opens a file it walks a chain of those modules, and most of this guide is just learning to say which link you are talking about.

The chain of a normal play

Four kinds of module handle an ordinary file, in order:

  1. Access and demux. The access module fetches the bytes — from a disk file, a disc, or a network address. The demuxer (short for demultiplexer) unpacks the file's container — MP4, MKV, WebM and their kin are envelopes, not encodings — and separates what's inside into streams: usually one video stream, one or more audio streams, sometimes subtitle streams.
  2. Decoders. Each stream goes to the decoder for its codec: H.264 video, AAC audio, and so on. Decoding turns packed data back into raw pictures and raw sound, many times a second.
  3. Outputs. Raw pictures go to a video output module (a window, a full screen, or — in this lab — a dummy that throws them away), and raw sound to an audio output module (your speakers, through PulseAudio or a sibling, or a dummy). Almost everything about "no picture" or "no sound" is a fact about this link, not about the file.
  4. The interface. The part you talk to — the Qt window, the command line, a web page — is itself just a module riding on top, sending the core orders: play, pause, seek, stop. The core is called libvlc, and it is the same engine in every costume.

That separation is why this guide can prove things on a machine with no screen: swap the real outputs for the dummy ones (--vout=dummy --aout=dummy) and the rest of the chain — demux, decode, timing — runs exactly as it would for a person watching.

Interfaces are interchangeable

Chapter 10 uses two interfaces that come with the same program:

  • cvlc, the console interface: no window at all, orders given as options on the command line. This is the scriptable face of VLC.
  • The RC interface (-I rc): a prompt you type orders into — add, play, get_time, quit — or feed from a script.
  • The HTTP interface: a small web server inside VLC that takes orders from a browser or any program that can fetch a URL, guarded by a password.

Because interfaces are only riders, anything one of them can do, the core can do; they differ in who is giving the orders, not in what orders exist.

The stream output chain

The second half of VLC hangs off one option: --sout, the stream output chain. Instead of sending decoded media to a screen and speakers, a sout chain sends it somewhere else — into another file, or onto the network — optionally transcoding (decoding and re-encoding in a new codec) on the way. A chain is written as a small sentence:

#transcode{vcodec=VP80,vb=700,scale=0.5,acodec=vorbis,ab=96}:std{access=file,mux=webm,dst=parade.webm}

Read it left to right: transcode the media — video to VP8 at 700 kilobits, half size; audio to Vorbis at 96 — then hand it to the standard output, which writes it to a file, wrapped in the WebM container, at this destination. Change access=file to access=http and the same sentence streams instead of saving (chapter 9). Change what the transcode keeps — vcodec=none keeps no video — and it extracts audio (chapter 8). Every option name in that sentence comes from the modules' own help: cvlc -p transcode prints the transcode vocabulary, and cvlc --longhelp --advanced (3,625 lines in this build, against 1,649 for the plain --longhelp) prints everything else. That two-storey help is where this guide checked every option it teaches — chapter 10's interface options, for instance, live only in the advanced storey.

The configuration

VLC keeps its settings in a text file — ~/.config/vlc/vlcrc on Linux — where every option the help lists appears with its default, most of them commented out. A setting given on the command line wins for that run; a setting in the file wins every run until changed. The lab's runs set a throwaway home folder so the lab's experiments never touched a real configuration; on your machine there is exactly one such file, and chapter 13 uses it for the classic cache fix.