How to make your own Ogg/Theora videos
Here is how we created the free conference videos we are sharing with you.
Our goal is to show you that it is very easy and pretty cheap to create Ogg/Theora videos using only Free Software tools. It would be great if more people shared what they experience, in particular when they attend interesting presentations!
License
Copyright 2006-2008, Bootlin.
This mini-howto is released under the terms of the Creative Commons Attribution-ShareAlike 2.5 license.
Requirements
A mini-DV camcorder.
Such a device costs approximately 500 US dollars / euros. Mini-dv tapes cost about 5 US dollars / euros.
Note that other devices may be used, such as DVD or harddisk camcorders.
Harddisk camcorders are not a very good solution, because video is stored with a high compression rate (MPEG-4 format). You will not get the best results if you encode from MPEG-4 to Theora, because you will be using low bitrate input compressed with another codec.
A DVD camcorder is fine (MPEG-2 compression), because the input quality would be much better. The best is still DV input, which has very little compression, and allows to get the best of the Theora codec.
Camcorder accessories
A tripod is a must-have. Without one, your image will not be very stable (even with image stabilization), and above all, you will be exhausted after one hour.
An external microphone is nice to have, but not mandatory at all. You still
get pretty good quality audio with the built-in one. So, if you are satisfied
by the audio that you get, you do not have to buy such a microphone. However,
the best solution for top quality audio is to connect you audio input to the
room audio system (if any, and if the speaker is using a microphone).
Computer connectivity
You need a GNU/Linux computer with FireWire input (aka IEEE 1394 or iLink).
If you have a notebook with a PCMCIA adaptor, you best option is to get a
FireWire PCMCIA card which doesn’t need any special driver. This should mean
that it is compliant with the 1394 OHCI standard, which is fully supported by
Linux. Note that recent distributions (at least Fedora Core) automatically
load the right drivers when such a card is plugged in.
It may be possible to use USB connectivity too to get the video from the
camcorder. We just do not know how yet. Any resources are welcome!
Storage
The DV files are huge (roughly 15 GB per hour). As intermediate processing
steps are used in our flow, intermediate files of similar size will be
created. Hence, you will need at least 30 GB of free space to process 1 video.
Anyway, it’s much better to have 100 GB or more to store and process several
videos in a row. For notebook owners, external hard drives (typically
high-speed USB 2.0) are your friends.
An external microphone is nice to have, but not mandatory at all. You still get pretty good quality audio with the built-in one. So, if you are satisfied by the audio that you get, you do not have to buy such a microphone. However, the best solution for top quality audio is to connect you audio input to the room audio system (if any, and if the speaker is using a microphone).
Shooting the video
Before or right after filming, make sure that you ask the speaker(s) for permission to publish the video! Make sure you mention the license that you are going to use.
Video capture
Connect the camera to the computer with the FireWire cable.
If you are using a PCMCIA FireWire adaptor, all the modules should have been loaded automatically at module load time.
If you have a legacy FireWire input, you may have to do a few things by hand (logged as root):
modprobe dv1394
chmod a+rw /dev/dv1394/0
You will now use dvgrab
to get the video through the FireWire link and save it to a file. This tool is shipped by most distributions.
dvgrab --size 0 --format raw <output-file-prefix>
Note: --size 0
means that the output file is not split into many smaller ones, when they exceed a given size.
Now that you’re done, let’s assume that you created a video.dv
file.
Video trimming
When you read reused tapes, it’s hard to avoid video frames from the previous recordings at the begining or at the end. Before compressing, you first have to trim out the unwanted frames.
This is pretty easy to do with the kino tool, available in all recent distros.
Make sure you export the trimmed video in DV format, to avoid losing quality.
We will soon post kino usage screenshots on this page, to get you started faster with kino.
Quick Ogg/Theora generation
That’s very easy to do. Get the latest version of the ffmpeg2theora package.
ffmpeg2theora -o video.ogv video.dv
You’re done!
You can use the -v
and -a
parameters to control video and audio quality. The defaults (5 and 2) should be fine for average quality requirements. With -v 7
, we already get very good video quality, but the output file size is roughly double. As far as audio quality is concerned, keep in mind the source quality. Unless your audio input is high quality (audio in directly connected to the conference room sound system), there is no need for high bitrate audio compression (-a
setting greater than 4).
Deinterlacing?
If the output video quality is poor, it could be because your video needs deinterlacing. In particular, this happens when you record your video in long play mode. Interlaced video is very easy to identify: you just need to find a sequence with motion (camcorder or character motion). Pause the video and interlaced lines will show up.
So, if you source video is interlaced, use the --deinterlace
parameter of ffmpeg2theora:
ffmpeg2theora --deinterlace -o video.ogv video.dv
Denoising the video
Look carefully at the generated Ogg/Theora video. Do you see MPEG-like squares moving on surfaces which shouldn’t change at all (walls, sky, board, etc.)?
If this happens, this means that your original video contained noise. This is very frequent with digital camcorders, in particular in low light conditions (when you amplify a weak signal, noise gets more significant). Such noise, though it is not obvious on the source video, can get amplified in the compression process.
Hence, it’s best to remove noise before compressing, so that pixes in still surfaces do not change at all in the source video. Follow the below instructions and compare the output Ogg/Theora video size. You will find that the output file is smaller that what you got by just running ffmpeg2theora on the raw DV video.
Fortunately ffmpeg2theora now supports denoising filters: we contracted Jan Gerber, its developer, to add such filters to his tool. First make sure you have at least version 0.20 (otherwise, download the latest version).
The implementation is based on ffmpeg / mplayer‘s postproc library. Available filter settings are detailed by ffmpeg2theora --pp help
, or can be found by looking for tmpnoise
in mplayer’s manual page. Filter settings are not easy to choose, however. For your convenience, here are the settings we chose after multiple experiments: --pp de,tn:256:512:1024
. At least with our videos, they produce good quality output without significant side effects.
Ogg/Theora video with metatags
It’s possible and useful to add metainformation (title, author, location, license) to the ogv video files.
This can be done thanks to ffmpeg2theora parameters:
ffmpeg2theora -a 3 -v 7 --pp de,tn:256:512:1024 \
--artist "Michael Opdenacker" --title "Fosdem 2006" \
--date "February 2006" --location "ULB, Brussels, Belgium" \
--organization "Bootlin (https://bootlin.com)" \
--copyright "Copyright 2006, Michael Opdenacker" \
--license "Creative Commons Attribution-ShareAlike 2.5" \
-o video.ogv video.dv
If you need to mass encode several videos in a script, it is now possible to add the metatags by hand after encoding. This can be done with the TagTheora tool.
Going further
Run ffmpeg2theora --help
for details about more possibilities like live encoding and streaming.
Thanks
- To Diego Rondini, for letting us know about TagTheora