Ogg Theora Cook Book

Encoding with VLC

The VLC media player (www.videolan.org) allows easy encoding of video files to Theora. Encoding can either be performed via the graphical user interface (GUI), or from the command line. The following instructions have been written for use with VLC version 1.0.1 running on Ubuntu. Other versions may differ in details, though the overall process will be the same.

Using the GUI

When you start VLC, you are immediately greeted by its main window:

User Interface of the Video LAN Client (VLC)

In the Media Menu select Convert/Save. This brings you to the following dialog:

convertb_01.png

Under File Selection click Add and select the source video file for encoding.Then click on Convert/Save at the bottom. This leads you to the encoding dialog:

convertb_02.png

Under Destination click Browse and select the location and name of the Theora file that you want to create. Remember that the correct file name extension for a Theora file is .ogv. Under Settings set the Profile to "Video - Theora + Vorbis (OGG)".

Then press the Start button. This starts the encoding process and brings you back to VLC's main dialog:

convert_10.png

At the window's bottom, the text "Streaming" is now displayed. This indicates that it is busy encoding your file. The slider will slowly move to the right as encoding progresses. Once encoding is done, the slider jumps back to the left and the "Streaming" display disappears.

Advanced Options 

If you are not satisfied with the encoding result, try adjusting some of the more advance encoding parameters. In the previous encoding dialog, before hitting Start, press the button with the "tool" icon, just to the left of the profile selection:

convertc_01.png

This opens up a new dialog, with the 4 tabs, labeled; "Encapsulation", "Video codec", "Audio codec" and "Subtitles". Make sure you do not change any parameters under "Encapsulation". The video encoding options you need are under the "Video codec" tab, shown below:

converto_00.png

If your encoding result's video quality was too low, try increasing Bitrate. If your video source material has a very high resolution, try setting Scale to 0.5 to encode at half the original resolution. As of this writing, changing video resolution fails to work properly for some source material, when using VLC 1.0.1.

Encoding from the Command Line

If you are encoding a number of files to Theora, clicking through the VLC dialog windows can become tedious and error-prone. Here VLC's command line interface comes to the rescue. While not as intuitive as the GUI, it allows you to exactly repeat an encoding process with constant parameters.

Use the following command to encode your source video, (in the example below the files are called "my_source_video.mp4" to "my_theora_video.ogv" you can of course, use whatever name you want) with the same parameters as used in the GUI example above:

vlc my_source_video.mp4 \       --sout="#transcode{vcodec=theo,vb=800,scale=1,       deinterlace=0,acodec=vorb,ab=128,channels=2,\       samplerate=44100}:standard{access=file,mux=ogg,\       dst='my_theora_video.ogv'}" 

All the parameters that had previously been specified in the advanced encoding options dialog window, are now given in text form. The only options whose meaning might not be immediately obvious are vb which means video bitrate and ab, which refers to the bitrate of the encoded audio.

Recommended Encoding Options

The command line shown above merely utilizes the parameter set provided by the GUI interface, which is in no way optimized for Theora encoding. We can do much better by using options that are exclusively available on the command line only. A better option might be to use the following command line as a basis for encoding. Tweak it to suit your needs:

vlc my_source_video.mp4 \     --sout-theora-quality=5 \     --sout-vorbis-quality=1 \     --sout="#transcode{venc=theora,vcodec=theo,\            scale=0.1,deinterlace=0,croptop=0,\            cropbottom=0,cropleft=0,cropright=0,\            acodec=vorb,channels=2,samplerate=44100}\            :standard{access=file,mux=ogg,\                      dst='my_theora_video.ogv'}" 

In this example video and audio quality are specified as numbers in the range 0 (low quality) up to 10 (highest quality). In case you want to remove black or noisy borders around the video, adjust the options croptop through to cropright.

These examples require that your VLC installation comes with the VLC Theora plugin. Verify the plugin's presence by typing:

vlc -p theora 

Even if this prints out "No matching module found" it may still be possible to encode to Theora, by using the ffmpeg plugin that supports Theora as well. However, the advanced "--sout-theora-quality" option is not available with ffmpeg.

Why not to use the GUI

The Theora codec works best when encoding for a specified video quality. Encoding for a given target bitrate will always give inferior results for a file of the same size. Unfortunately there is no way to specify target video quality via the GUI, which is why you just shouldn't use it for any kind of professional encoding work. Also, note that you cannot crop borders of the video when encoding from the VLC GUI. 

Keep in mind that this chapter was written using the 1.0.1 version of VLC, which was current at the time of this writing. Newer versions may outgrow these limitations.