Select Page

**UPDATED**

Converting video in Ubuntu Linux 5.10 (Breezy) took me a little longer to figure out that I anticipated – but only because there are so many different solutions. If you use another flavor of Linux – I’m sure this guide can help you too. I download a lot of videos, and of course want to burn some to VCD or DVD. The formats are anything from wmv to avi, mpg to mov. I installed a lot of GUI tools, and to be honest not a single one worked for me. I found tools to burn SVCD, VCD and DVD’s, but to convert the video and prepare it for burning is another matter. Most of the tools that burn video don’t convert it to the proper format. If for some reason you got to this page and don’t know what an SVCD or VCD are – please look them up at Wikipedia.com before continuing.

If you’re a former Windows user converting to Linux (like me), here’s some background. If you’re a linux pro – move on to the next paragraph. Most of the video conversion programs and utilities in Windows do the whole job from finish to end. What I mean is, they’ll help you edit your video, then covert it to the proper format, then help create your menus, and finally burn your finished project to CD…i.e. – Rip, Encode, and Burn. In Linux, in every step in the process different tools can be used depending on your needs. Some tools only do one thing. Others do it all. Most are just a GUI interface front end built on a common command line tools already on your pc.

If you have video that you need to make linear timeline type edits in, then use the Linux GUI video editing tool Kino which you can find at http://www.kinodv.org/. If you use Ubuntu – you can install Kino using your Synaptic package manager. Kino is a nice video editor, but in only edits “digital video” with .dv or .dif extention (from a digital video camera), or quicktime format, or digital video in .avi format. This basically means, you can’t edit things in .mpg format, .asf or .wmv (of course – Windows formats), or divx or xvid. You need to “convert” the file to digitl video format before you can open it in Kino (read on for ways to convert video). If you just want to burn some video to a disc you can play in pretty much any DVD player – read on.

Getting Started

If this is your first time reading this page – or if you’re returning…strongly consider using the “subscribe post” link at the bottom of this article. I edit video all the time and constantly refine the content on this page to the latest tools and techniques I’ve found. If you subscribe, you’ll get an email whenever I edit this page. You won’t get email for any other reason.

I use K3B for almost all my VCD and DVD (iso) burning needs. K3B is a Linux burning program for CD’s and DVD’s – very similar to what Nero is like in Windows. But before I can burn a VCD or DVD I need to get my videos in the proper format by converting them. For the most part when converting them, I now exclusively use command line tools – which is a very quick and versatile way to do it once you know how. This may or may not be for you depending on your knowledge of UNIX and the command line. If you prefer a GUI interface, I will try to point out those options as well. If you can navigate directories in the terminal – you most certainly can use these commands to convert video there as well.

Converting and Encoding Video

I now have 3 options for converting video well for use in a dvd player in Ubuntu Linux (or any linux distro). If you want to convert video for play on your computer – jump to the end of the article. First I’ll go over the first two which are ffmpeg and mencoder. I used to almost exclusively use ffmpeg when making video to play in a dvd player. I’ve tried both, and gotten very poor quality video and results from mencoder. I know many swear by it, but maybe it needs more resources than my 1.2 Ghz 512MB ram machine will lend. ffmpeg works very well on my older hardware.

On the command line in terminal, you can of course just run the command “man ffmpeg” or “man mencoder” to read the manual (help) page for each to find out how to use them. If you don’t have either on your machine, just install using of course Synaptic Package Manager under System -> Administration. Using the manual pages, I wrote myself some examples that I thought I would most commonly use, and here they are:

FFMPEG on the command line:
===================

by selecting a format as one of the options (“vcd”, “svcd”, “dvd”, “dv”, “pal-vcd”, “ntsc-svcd”), all the format options (bitrate, codecs, buffer sizes) are then set automatically.

You can just type:
$ ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg

#same example but use high quality, ntsc vcd format
$ ffmpeg -i myfile.avi -hq -target ntsc-vcd /tmp/vcd.mpg

#same example but dvd quality
$ ffmpeg -i myfile.avi -target ntsc-dvd /tmp/dvd.mpg

#same example use same quality as source
$ ffmpeg -1 myfile.avi -sameq -target vcd /tmp/vcd.mpg

#converting a file for VCD format using a and b frames for MPEG 2
$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 /home/user/Video/vcd.mpg

#same conversion, but start at 0 seconds and convert only first 45 minutes
#use -ss for start position and -t for duration
$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 -ss 00:00:00 -t 00:45:00 /home/user/Video/vcd.mpg

#converting a file to mpeg using mencoder (poorer quality than ffmpeg I think, but that’s on my system – and it really depends on the file and the codec you’re using)
#see the tovid examples below for better better results with mencoder
$ mencoder -oac copy -ovc lavc -of mpeg -o output_file.mpg your_file.wmv

A new trick that I learned was that you can use ffmpeg to extract audio only from video files. Recently I made some .mpg files for a promo dvd I was making for my band. I wanted to also make a promo cd – but use the audio from the video files. Using ffmpeg, it’s possible to rip the audio from any video file (it can convert) directly to an mp3 file like this:
$ ffmpeg -i video.mpg -f mp3 audio_track.mp3

In that example, video.mp3 is your input file and audio_track.mp3 is your output mp3 file. It works great!

I keep a mencoder example around just in case I want or need to try it again and so I have a second option just in case ffmpeg doesn’t work well on a particular video. I sometimes use it to convert windows media files. One last tip – if you are going to be converting any windows media files – you must get the proper codecs installed on your system or ffmpeg won’t work. The easiest way to do this is by running the “Automatix” script explained in the ‘First Things to Do’ section of this guide. It installs the “essential-codecs” from the mplayer site automatically. If you have any problems with this, or don’t want or plan to use Automatix – just download and install them essential codecs from the mplayer web site yourself.

I love using ffmpeg – but some Windows media files it just won’t convert. It will convert a MB or two and then bomb out with a “segmentation fault”. If that happens – I used to try the mencoder option instead. Which brings me to my third and newest option – Tovid. I have found that using the Tovid option gives the best results, and every single Windows media format whether asf or wmv I’ve tried it has converted. Tovid is merely a frontend that uses ffmpeg, mencoder, transcode, and dvdauthor – but it does so very efficiently. I originally installed Tovid on Ubuntu using Synaptic package manager, which made an icon under the Sounds and Video system menu that brings up the 0.22 GUI interface. If you don’t have an icon in that menu, try running “tovidgui” from the command line to bring up the gui. This interface has never worked for me in Breezy (but does in Dapper flight 6). I downloaded the 0.25 Tovid from their web site and installed it from code using their instructions and the Tovid command line tools seem to be working for me so far. If you have any problems with python depencies when you install Tovid – be sure to run these 2 commands on your terminal, and then install Tovid again for it to work right:

$ sudo apt-get install python-wxgtk2.4
$ sudo apt-get install python-dev

Tovid is a suite of scripts that you can use for the various stages of the conversion and burn to disc process. They heavily use mencoder for conversion, and for some reason they do it much better than when I run mencoder myself. The first script of the Tovid suite that you’ll find handy is “idvid” (short for id video). Use it like this:
$ idvid file.avi

It will not only give you the video properties, you will get the width and height, aspect ratio, duration, bitrates, but the most important is the last bits of info you get. It will tell you whether the video and audio is compliant with VCD, SVCD, or DVD. Then you’ll know whether you need to convert it, or if you can burn it straight to disc.

After you run the idvid command on your video(s), you’ll probably need to convert them to the proper mpeg (mpg) format before burning. This is very easy using tovid on the command line. There are a multitude of options you can find in the man page, but these are the two most common I use:

$ tovid -dvd -ntsc file.mpg video
$ tovid -vcd -ntsc file.mpg video

after the tovid command the first option I use is to tell it whether or not to make the video format for a dvd or for a vcd. Then I use the ntsc option for my type of tv. Next I tell it what the input file is. Last, I tell it what to name the output file (prefix only with no extension)…i.e., if you make this video like I did, your output converted file will be video.mpg. If you accidentally name your output file video.mpg, not to worry – tovid will save it as video.mpg.mpg.

If you want to convert lots and lots of videos at once (like I sometimes do), and don’t want to run this command a ton of times, or write a script to convert them – tovid has a nice option. Just use tovid-batch instead like this:

$ tovid-batch -dvd -ntsc -infiles *.avi

You can also convert every single (video) file in a folder like this:
$ tovid-batch -vcd -ntsc -infiles *.*

If you’re not familiar with the command line or dos, the asterik means “do everything like this” (avi). So of course *.mpg would mean all mpg files, *.wmv, all windows media files, *.* means all files of all extensions, etc.

I don’t use it much anymore now that I know about the tovid-batch command, but you can install and using the ‘video-convert’ scripts from the ubuntu forums designed for nautilus. Nautilus is like the dekstop manager is Gnome, and if you right click the desktop – you’ll see a heading entitled “scripts”. Download the video-covert script from the forum and follow the instructions for installing it (it’s very easy). Once installed, just right click any video file(s), go to “scripts -> video-convert” and answer the simple option prompts and voila! It converts them all (using command line tools) for you! The greatest benefit of this is that you can shift-click multiple files at once, and use the script to convert them all one by one. Doing it yourself in terminal you would have to either convert them one by one, or write a script to create them in succession.

If you install this script and like it, you can also visit the ubuntu forums and get the audio-convert script too, to convert audio files the same way. You’ll be converting flac, ogg, wav, and mp3 files in no time. Just make sure that you’ve installed the command line tools for the formats you’ll be converting in synaptic. i.e., if you want to convert .flac files to mp3 using audio-convert, make sure you install the .flac command line tools in synaptic first so the .flac format will be supported and usable by audio-convert.

Making a Disc for Your DVD Player

Before I tell you how to create a disk for your dvd player – I first ask you to consider an option that will allow you to watch video on your t.v. from your computer, without converting anything! Believe it or not, I really convert video that often anymore, since my DVD player will now play plain data cd’s and dvd’s burned from my computer. Wouldn’t you like to do the same? It’s cheap and easy if you know what to buy…you can do this for under $30-$40.

There are two options – the first is to buy a region free dvd player that will play DVD, DivX, MP4, VCD, SVCD, MP3, WMA, JPEG, AVI, xVid, and mor The second is to buy a hard drive player or HDD player case. Basically – it’s the same as an external hard drive enclosure, but it also has a VGA cable and video and audio outputs to play audio and video directly to a computer monitor (without computer) or your television (without a computer). It has a chip inside that contains the menu system to navigate the hard drive and play video on it’s own. So, buy this empty enclosure, add a hard drive, hook it up to your pc with the usb cable (works with windows, mac, and linux) and transfer the video or audio to it. Then – hook it up to your tv or entertainment system with the included audio cables, and watch your movies without ever burning a cd or dvd. When your done watching your movies, just delete them and transfer more!! You can even take it with you on the road, watch in the car, on a laptop, or even in the hotel room, on anything with video/audio inputs!

I’ll show you the links first on where to get these on eBay, and then back to the “how to make a DVD” tutorial!!


Coverting video is the first step to making something you can play in your DVD player. You can burn video to a regular CD, and make either a VCD (Video CD) or SVCD (Super Video CD). The advantage is that you need only a regular cd burner and a simple CDR. The disadvantage is that you can only burn ~100 minutes of video, and the video quality is tv quality or less. In the ffmpeg commands above I show how to convert to either VCD or DVD formats very easily.

Once converted, it’s easy to use K3B to build a VCD or SVCD just by clicking on the files you want to add and burning to CDR. This is easy and cheap, but VCD’s can only store 70 minutes of video. If you have a movie or video that’s longer you can put it on 2 or more video cd’s easily. But burning dvd format files you’ve converted is not so easy because in order to make a dvd, the files have to be in the right format, in the right folders, and you usually need some type of menus or navigation system. It’s only easy once you know the commands – or if you have a decent gui program to put it all together. I’ve found that it’s also easier to create a DVD on the command line in linux (but I’ll go over GUI options after this too). For the command line – all you need is to have both dvdauthor and mkisofs installed. If you don’t, just add them in Synaptic Package Manager.

Then on the command line – use them like this:

Start by running this command from a directory that contains your newly coverted video file(s). Make sure that you have created a directory inside your current dir to create the new files. In other words, if you are in /home/Video in terminal, “mkdir dvd_ready” there to create /home/Video/dvd_ready/. As long as you already have your video in the same dir you’re running the command from (/home/Video/movie.mpg), you can run this:

#-o is output dir and movie.mpt is name of your movie
#for multiple video on same dvd, run this command for each movie
$ dvdauthor -o dvd_ready movie.mpg

#when all movies are added run this command to create table of contents file
$ dvdauthor -o dvd_ready -T

#run this command to create an ISO file to burn your DVD from
#-dvd-video is the format, -o is name of output file, dvd_ready is source dir
$ mkisofs -dvd-video -o dvd.iso dvd_ready

Then, when you are done just burn your .iso file to a DVD using K3B or another program. In K3B, I can burn my .iso to DVD in under 4 minutes with older hardware.

So creating a DVD in the terminal takes a few more commands – but hey – I can usually convert the video using ffmpeg and create the DVD files and iso in under 1/2 an hour, ready to burn straight to DVD. That is much faster then I was ever able to create a DVD from Windows.

Now, if you just must have a GUI program to create a dvd and the command line is just not for you – be sure to check out DeVeDe, QDVDAuthor, DVDStyler, AcidRip, and DVD::Rip.

Every now and then I find myself wanting to convert a video just for the computer. Maybe I want to create an avi video in Xvid format, or even DivX format. You may already have “transcode” installed. In terminal, type “man transcode” to get the transcode manual. If you don’t get anything – then go into synaptic and install it. You can always get the latest version from www.transcoding.org as well.

Here are some examples of using transcode to convert video:

Convert a video to xVid format:
$ transcode -i movie.mpg -o movie.avi -y xvid

Convert a video to DivX format:
$ transcode -i movie.mpg -o movie.avi -y divx

Do you have a better way to convert video or using command line video tools? Sign in and add your comment to this page now!

Did you find the terminal commands helpful? Would you like to get more little one and two line commands to convert, hack, play, and edit all kinds of multimedia on your linux computer? I have been reading all kinds of tutorials in forums and Linux help sites for months now. I hadn’t purchased any books to help me at all until just a few weeks ago. There was one that really caught eye called “Linux Multimedia Hacks” (which is pictured below) – it is impeccable as most O’Reilly books are – especially the hacks series. In the dozens if not hundreds of hours it will save you, it’s well worth the $20. I really wish I would have bought it before I started out figuring how to do this all on my own. I knew a very few hacks already, but now I have learned dozens of new ones. I tend to save all kinds of text files in my home folder with little command crib sheets, and I have tons of sticky notes on my desk. There really is something to be said for having a printed book reference at your disposal. That way – if you don’t convert a wav file to mp3, rip a cd, or make a dvd for a month or two, the answer is right in the book contents or index. Click on the book below for more info and consider buying a copy for yourself from Amazon. You spend more on a few pizzas than what it will cost….but it will be a reference you will use for many years to come.

Learn how to manage your music collection in Linux, including your iPod. Learn how to crop video during playback and recording. Learn how to create a DVR (Digital Video Recorder) or PVR (Personal Video Recorder) with MythTV. Learn how to rip and record streaming video and audio. Learn how to convert a dual layer DVD to a single layer dvd. Even learn how to synch your digital camera and computer, make image thumbnails, leave a watermark, or create a slideshow or screen capture movie. It’s all in the book….I’m still reading!!

originally posted: 2006-05-08 11:50:00 -0400

Linux Multimedia Hacks: Tips & Tools for Taming Images, Audio, and Video (Hacks)Linux Multimedia Hacks: Tips & Tools for Taming Images, Audio, and Video (Hacks)