Still working to recover. Please don't edit quite yet.
Difference between revisions of "how to encode video to OGG Theora"
(→Thoggen) |
(→VOB file: The internal ffmpeg vorbis encoder is about the simplest possible encoder that produces working output. It sounds terrible compared to the reference encoder. libvorbis sounds much bette) |
||
Line 33: | Line 33: | ||
===VOB file=== | ===VOB file=== | ||
− | Example of the command: <code>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 | + | Example of the command: <code>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 vorbis -ac 2 -vol 300 -ab 128k -newaudio</code> |
This will take an input file (<code>-i</code>) “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 (<code>-f</code>) is [[Ogg file|ogg]]. Aspect ratio of the video (<code>-aspect</code>) is 4:3 with video codec (<code>-vcodec</code>) being Theora (note called ‘'''lib'''theora’) and the video bitrate (<code>-vb</code>) of 1024k. Audio codec (<code>-acodec</code>) is Vorbis with two audio channnels (<code>-ac</code>) increased volume (<code>-vol</code>, 256 is normal), audio bitrate (<code>-ab</code>) is 128k. The output file will be “new.oggâ€. What follows after that is the parameters for additional stream of audio (<code>-newaudio</code>); there could be multiple audio, video, and subtitle streams. | This will take an input file (<code>-i</code>) “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 (<code>-f</code>) is [[Ogg file|ogg]]. Aspect ratio of the video (<code>-aspect</code>) is 4:3 with video codec (<code>-vcodec</code>) being Theora (note called ‘'''lib'''theora’) and the video bitrate (<code>-vb</code>) of 1024k. Audio codec (<code>-acodec</code>) is Vorbis with two audio channnels (<code>-ac</code>) increased volume (<code>-vol</code>, 256 is normal), audio bitrate (<code>-ab</code>) is 128k. The output file will be “new.oggâ€. What follows after that is the parameters for additional stream of audio (<code>-newaudio</code>); there could be multiple audio, video, and subtitle streams. |
Revision as of 22:45, 7 February 2009
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.
Contents
DVD
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
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 or other systems using apt-get you can install via apt-get install thoggen
, on Ubuntu GNU/Linux you will need to type: sudo apt-get install thoggen
. After the installation you will be able to find the “Thoggen DVD Ripper†in the menu or start it by thoggen
command.
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).
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 cansel 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
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
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:
- On Debian-based system you have installed build-essential package (
apt-get install build-essential
) - You have libtheora and libvorbis installed (
apt-get install libtheora-dev
andapt-get install libvorbis-dev
) - 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
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 vorbis -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
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 vorbis -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).
Unimplemented features in ffmpeg
Some useful features are yet not implemented for Ogg containers, Ogg Vorbis, or Ogg Theora:
- Ogg container with video cannot have title (
-title
) and other simmilar settings - Ogg Vorbis and Ogg Theora cannot be specified by quality, only by bitrate
- Only maximum of 2 channels can be in Ogg Vorbis
- Ogg container does not accept
-acode
and-scode
settings.
VLM
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.