Still working to recover. Please don't edit quite yet.

how to encode video to OGG Theora

From Anarchopedia
Jump to: navigation, search

This is a HOWTO explaining how to encode a video that you have on your computer to a free format of Ogg Theora. It will concentrate how to do this on GNU/Linux operating system, if your computer is still running MS Windows please see how to install GNU/Linux or how to install Gygwin.

DVD[edit]

If the video you have is in the DVD format you will have two options, you can convert directly with Thoggen (simple way, but provides less control) or you can rip the VOB file and then follow the rest of the instructions presented here.

Thoggen[edit]

File:Thoggen DVD rip 1.png
Selecting the title to rip.

Thoggen is a GUI DVD ripper which creates Ogg Theora as an output file. Installation procedure for Thoggen differs dependinng on your GNU/Linux distribution, on Debian based systems, like Ubuntu or other systems using apt-get, you can install via apt-get install thoggen, or you may need to type: sudo apt-get install thoggen to get permits. After the installation you will be able to find the “Thoggen DVD Ripper” in the menu or start it typing thoggen command (followed by & to regain control in the command line).

After starting it up and loading DVD you will be presented with the choice of which title you want to rip. Thoggen will automatically select the largest of the titles for ripping, and usually this is the correct choice. Click OK and you will be taken to another window were you will be asked to give some parameters. Select the audio track, video dimentions, quality or desired size of the output file, a possible settings for croppinng (removing areas of the video, normally used to remove the black padding around the actual picture). Thoggen will save the output file in your home directory by default, taking the label of the DVD and the DVD title number to generate the name, you can change this name on this page. In the area “Stream information” you can also enter the name of the video you will be ripping, this name will be displayed by many video players (such as VLC media player) (Note: actually this is a feature of Thoggen which doesn't yet exist on ffmpeg for Ogg Theora).

File:Thoggen DVD rip 2.png
Configuring the output file.

After everything is finalised, click OK and the encoding will begin, you will be presented with the progress image of the recently encoded frame and encoding statistics. At this stage you can pause or cancel encoding, but you cannot change any settings.

Warning: Sometimes Thoggen does weird things, like encodes only part of the title, or doesnʼt finish encoding when the end of the title is reached, consider it a payment for simplicity of use. Also media players show incorrect total time for all the files encoded with Thoggen.

vobcopy[edit]

If you chose to use a more powerful tool to encode the video you have on the DVD, you will want to extract the VOB file to your computer by using vobcopy. Install it with apt-get vobcopy or a simmilar method on your distribution. You can run vobcopy without any parameters, and the programme will attempt to guess what you wanted it to do; specifically it will extract the largest track, name it by combining the label of the DVD and the track number, and break the files up in chuncks of 4 GiB. The latter assumption will make it more difficult to deal with the files later, so it is possible to specify -l tag to allow the large file support. More options are available via man vobcopy.

ffmpeg[edit]

One of the strongest tools for re-encoding video is ffmpeg. It provides the wide range of options to encode in various formats, but here will be the discussion how to encode in Ogg theora from the various other formats.

To install ffmpeg, you will need to compile it yourself. Although ffmpeg is distributed in packages by many different distributions, it is generally a good idea not to rely on those packages (for example #ffmpeg support channel will provide no help with such packaged distributions). Start by checking out the current trunk: svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg, after the source code will be downloaded change into ffmpeg and configure the package you need. The full range of configureation options is available by typing ./configure -h, for the most uses it will be sufficient to run ./configure --enable-libtheora --enable-libvorbis --enable-gpl.

If at this stage you get errors, make sure that:

  1. On Debian-based system you have installed build-essential package (apt-get install build-essential)
  2. You have libtheora and libvorbis installed (apt-get install libtheora-dev and apt-get install libvorbis-dev)
  3. Read the error message, perhaps you have some other packages missing from your system

If everything will go fine, you only have to run make install as a superuser (i.e. with su or sudo). After the compilation, assuming you got no errors, you can check that everything is well by running ffmpeg -codecs, and one of the first lines should be the settinngs which you have passed to configure ffmpeg. (If you are getting any weird errors, and you have recently moved the source code directory, run configure with --source-path=/currennt/path)

VOB file[edit]

Example of the command: ffmpeg -i NEW1-1.vob -map 0:0 -map 0:2 -map 0:1 -croptop 0 -cropbottom 0 -f ogg -aspect 4:3 -vcodec libtheora -vb 1024k -acodec libvorbis -ac 2 -vol 300 -ab 128k new.ogg -acodec libvorbis -ac 2 -vol 300 -ab 128k -newaudio

This will take an input file (-i) “NEW1-1.vob” and map change the order of the audio streams, in here 0:0 is the video stream and 0:1 and 0:2 are audio streams. There will be no cropping done of the video (note about cropping and padding: the final width and hight must both be divisible by 16). Output format (-f) is ogg. Aspect ratio of the video (-aspect) is 4:3 with video codec (-vcodec) being Theora (note called ‘libtheora’) and the video bitrate (-vb) of 1024k. Audio codec (-acodec) is Vorbis with two audio channnels (-ac) increased volume (-vol, 256 is normal), audio bitrate (-ab) is 128k. The output file will be “new.ogg”. What follows after that is the parameters for additional stream of audio (-newaudio); there could be multiple audio, video, and subtitle streams.

Flash Video[edit]

YouTube, Google Video, and many other sites today use FLV. ffmpeg can easily convert the FLV you grabbed into Ogg. The surest way is ffmpeg -i 1.flv -vcodec libtheora -sameq -acodec libvorbis -ac 2 -sameq 1.ogg. Please see that even though Flash Video only has a mono sound, due to the bug in ffmpeg you have to force 2 chanels when implementing on the fly (optionally you can separate the streams into multiple files and them mux them later).

ffmpeg2theora[edit]

You can also use the program called ffmpeg2theora which converts any media file that ffmpeg can decode to Ogg Theora for video and Ogg Vorbis for audio.

In Debian based systems (such as Ubuntu, LinuxMint, DamnSmallLinux, Knoppix, Lubuntu, etc.) you can download and install the package that contains the program with: sudo apt-get install ffmpeg2theora

Unimplemented features in ffmpeg[edit]

Some useful features are yet not implemented for Ogg containers, Ogg Vorbis, or Ogg Theora:

  1. Ogg container with video cannot have title (-title) and other similar settings
  2. Ogg Vorbis and Ogg Theora cannot be specified by quality, only by bitrate
  3. Only maximum of 2 channels can be in Ogg Vorbis
  4. Ogg container does not accept -acode and -scode settings.

VLM[edit]

VLM is a tool that comes with VLC media player, which is intended for streaming video, however, if you are on the computer where you cannnot install your own software, do not have internet access, or some this is a one off task you can load the video, which is playable by VLC and force the output to a file. This method will often fail, crashing VLC with no explanation, and provides the least control over the process.

See also[edit]

External links[edit]