Monday, January 21, 2008

Creating DVD from your video files on Linux

Linux has many different programs for editing video and creating DVDs from your individual video file collections. The ones I know and use include:
and probably many more. Most of these programs have many features besides the video editing capabilities. Some of them might do the same things in different or more efficient ways.

I am not really an expert on video editing or creating DVDs. However, from different sources I gathered a lot of useful information to do what I need. My basic need was to create DVDs from my video files. I also wanted to have fancy DVD menus showing the preview of the videos, which is probably a good thing to have on DVDs.

For this purpose my main tool is actually videotrans. Videotrans is a collection of utilities (movie-to-dvd, movie-title, movie-make-title etc.) to create DVD compatible video/audio files, creating animated/static title menus, creating dvdauthor compatible XML files etc. Videotrans utilities are mostly complex shell scripts using some of the utilities I mentioned above and some more. I am sure there are more fancy programs to create DVDs and probably some of them are free/open source. However, I am currently using Videotrans because for the last 2 years I really got professional with it. I will not it is superior and very good. I had many problems that is for sure, but for the time being I can find my way out and create my DVDs.

Yesterday, I found a new program called, KDE DVD Authoring Wizard. The program seems to be doing the same thing with Videotrans in a more fancy KDE Wizard way, which is good. However, from my initial tests, and initial research it seems to have the same limitations with Videotrans. I will definitely look more in to it in the future (Also I had some problems because it is a KDE type utility and I use Gnome on Ubuntu).

I will try to demonstrate a little DVD creation example here using the Videotrans utilities.
Ok, for this demonstration I am assuming you have 2 long video files (with mpg extensions) and a small video (or part of a big video) to be used as title menu background animation.

Step 1 - Install Videotrans:
Because videotrans is actually a set of shell scripts (mostly), the installation is pretty straight forward. Download the latest videotrans archive from its website and unpack the file you obtained. Go in to the videotrans directory and do:

$>./configure
$>make
$>make install

You have to be superuser to install the program. Also for small utilities included in the set, you need to have a GCC installed.

Assuming you did not have problems with installation (I did not and it is one of the easiest installations I did), we can move on to creating some DVDs.

Step 2: Making your video files DVD compatible (if they are not) :
I am not really sure what a DVD compatible video is and I did not really make a research on that.However, I know I had to create the DVD compatible videos every time I created a DVD. So our first utility from videotrans set is movie-to-dvd:

$> movie-to-dvd -m "ntsc" -O "-nolirc" test.mpg

This command with the appropriate options will create to new files "test.m2v" and "test.ac3" from your home video "test.mpg". There other options available for use, but these are generally enough for me.
-m option defines which viewing mode you are using (PAL or NTSC). Since I am in US, my videos are NTSC. I think PAL is for European countries. You can find that in the man page.
-O option is to pass command line options to mplayer which is used by movie-to-dvd. And "-nolirc" parameters is to tell mplayer not to care about the remote control activities (Since I have a mythtv box on the same computer, remote control might interfere with mplayer). Now we are up to creating title.

Step 3 - Making a title:
Title in DVD is the first menu screen with buttons you get (Like previews, options etc.). In videotrans there are couple options for making the title of DVD. It can be a colored background with some kind of sound file or it can be an animated background(movie-make-title-simple) with animated previews (Picture in Picture type) (movie-make-title). I usually go for the fancy stuff :), so I am using the animated titles and I will describe creating animated titles (since it is harder to do :)).

Ok, so pick a video that you want to use in the main title of DVD. It does not have to be short, since you can get any part of any video, but I suggest keep your title video short, since it will go through a very long process.

$>movie-make-title -o title -s 10 -e 30 -m "ntsc" your_title_video.mpg

This command will generate a whole bunch of images in a subdirectory called title (-o title) and the sounds from that file in to a title.wav file.
-o title means it will create the output in a directory called "title"
-s 10 means your background animation for title will start at 10th second of the video.
-e 30 means your background animation for title will end at 30th second of the video.
-m "ntsc" same as the movie-to-dvd option, to indicate your video mode.
The important thing here is to keep in mind that the times you get from your video might be slightly differ when you generate the title images using the above command. So after generating images check your images and if needed run the above command again with adjusted times. Also keep in mind that, assuming 25 frames per second, you will end up with approximately 500 images after this operation and that is why I suggested keeping the title animation short :).

Step 4 - Making title video:
Since we have a plausible sequence of title images, we can go on and generate our title with the animated previews. I want to give a brief explanation about why images are used for title. Since we want to create a title with animated background and video previews in the front, we have to somehow overlay these videos on top of each other. And I guess the overlaying images is the easiest way to do this :). So in the end what will happen is our main video (test.mpg) frames will be overlaid with the title images created above. Then animating the new series of images will create a new video of overlaid videos.

$>movie-title -o title.vob -t title -s 5 -c 5 test.m2v

-o title.vob tells program to create the DVD title in a file named "title.vob" which is compatible with DVD.
-t title means use the images from the "title" directory to create the background animation.
-s 5 means start the PIP preview of videos from 5th second of the video
-c 5 means create chapters for DVD every 5 minutes. (be careful this is minutes).
and use test.m2v video created above to create your PIP preview.
There is another option(-T XxY) for how the videos are placed on the screen. If you do not give this option, it will place the PIPs in a reasonable way (Regular grid. I like it).

We are close to the end. I bet you can already see the your results (or not :)).
This is the tricky part, because this is where all the images are overlaid using ImageMagick program (convert). And this is why it is tricky. ImageMagick is a very powerful set of image processing tools. However, as far as I know, they keep changing the command line options from version to version. Therefore, for people using ImageMagick, it becomes tricky to do same job with different versions. I will not really get deep, but if you start to see just black screens with your video file name on it, it is probably due to a version incompatibility with ImageMagick (Suggested is upgrade/downgrade ImageMagick, after making sure everything else is working :)).

If you want to add information about your videos to the menu, videotrans is capable of adding an information button. I think it is designed for giving information on TV show episodes, but I think it can be used for general information for your videos. The only trick is to place your information in a text file with ".info" extension in the same folder with your video. So your info file should be "test.info" for the "test.mpg" video file. movie-title automatically checks this files and creates the necessary images for the information display.

Step 5 - Final step-Create the DVD using dvdauthor:
Once you successfully see the end of the above step, it will tell you how to create your DVD using dvdauthor. Actually all it does is, give you the command to run depending on your file names. The command will look like this after above step:
"dvdauthor -o dvd_directory -x title.vob-dvdauthor.xml"
The xml file is for dvdauthor to process and join the videos/sounds/titles etc.

$>dvdauthor -o dvd_directory -x title.vob-dvdauthor.xml

This will give you a directory name "dvd_directory" with your DVD created in it. Now all you have to do is, burn your dvd_directory to an actual DVD. However I strongly recommend that check your end results. For the first times I had many unwanted errors/problems and end up burning useless DVDs.

So, for burning, I first create and iso image and then burn it using K3B.

$>mkisofs -o dvd.iso dvd_directory/

This will create a file called "dvd.iso" using the "dvd_directory" create above.

Then you can simply burn your iso file.

That should make it all, stick your DVD in to a DVD player and enjoy...

1 comment:

Anonymous said...

I consider, that you commit an error. I suggest it to discuss. Write to me in PM, we will talk.