published: 2012/06/06. tags: dvd authoring, dvd making, dvd creation

Creating a DVD with multiple mov files as chapters

Automate, automate, automate

What I am about to write was done on a Mac but it should be possible on a Linux machine as well. If you are on Windows, sorry, this may not be for you.

In a few days I have a trip coming and I wanted to create a dvd with some of the video I shot for my son. I use iMove to edit and generate HD .mov files. I used iDVD a few times and like it. However, I don't like the fact that I can't get any file in the filesystem into this app. It only recognizes photos from iPhoto and video from iMovie. But these days I shoot a lot of video on my iPhone 4S that already creates the files as .mov and not .MTS and hence there is no reason for me to put them into iMovie unless I need to edit multiple clips. So, after a bit of research, I finally settled for DVDStyler. Initially I had problems using it and I was about to jump ship but none of the alternatives are any better and so after working out the problems I managed to settle with a good workflow for me to author my DVDs.

As a consumer of the DVD, my requirements are simple. I should be able to plaly all the clips or I should be able to select individual clips representing different events. I thought this is very easy to do since I am stitching together all the clips (.mov files) together. But it turns out, there are two units, one the titles and the other chapters. A title contains several chapters. Think of titles as multiple movies and chapters are the various scenes that can be selected. There is also a third unit called titleset which apparently is used mostly for supporting multiple aspect ratios.

I am not sure how the commercial DVD making applications work, but in case of DVDStyler, each .mov represents a title and not a chapter. Not knowing this and having created a DVD and thinking all was done, I realized the issue after started playing it on the TV.

I actually forgot to mention another requirement as a consumer of the DVD. The ability to forward/rewind by clips. Apparently this is not possible across titles. It's only possible to do this by chapters. It is actually this requirement and not the ability to select individual clips that forced me to revisit my strategy. So, since DVDStyler can only create chapters when all the chapters are from a single file, I have to first create the single file. This is where my trouble started. ffmpeg is good for converting individual files but not for stitching together multiple files. Added to that, the quality of video on a DVD is different from the HD video. Hence, it doesn't make sense to reencode everything to a very high definition and then reduce it again. It takes a lot of time. The final format generated are vob files. So, I thought I would convert each of my .mov clips into a vob file and then combine the vob files. In the past I used VOBMerge and so thought I could do the same. Then I came to know that VOBMerge is only available for Linux and not Mac (though there is a VOBMerge in the App Store which is not free and not sure if it's by the same author). Searching on the internet, few people mentioned that it's a simple matter of using the 'cat' command to merge all the vob files. That actually works, except one major problem. The timestamps are messed up. And DVDStyler certainly doesn't recognize such cat merged files. I tried to use "MPEG Streamclip" but for some reason I couldn't view the .vob files. But luckily in another forum, it was mentioned that transcoding the merged vob file through ffmpeg would fix the timestamp issue. And indeed it did.

Then I could use the DVDStyler but now the problem is, there is no way for DVDStyler to know the boundary of the chapters as it's one single file. It does allow us to manually enter the chapter boundaries, but that requires some effort. Further, it's no longer possible to author the menu items by dragging and dropping as can be done with the individual .mov files. However, it's not difficult once the chapter boundaries are specified. It's a simple matter of double clicking the menu items and then picking the right chapter (and also selecting "Play All" so that it doesn't come back to main menu after playing one chapter).

With all the above research, I already authored two DVDs and before I forget what all I did, I thought of putting this together so that it would come in handy for me later on. Here are the steps

  1. First identify the list of .mov files and the sequence in which to stitch them together
  2. Put all these files (fully qualified path) in a text file one per line
  3. Create a temporary directory, say /tmp/dvd
  4. Run this perl script as
    perl mf2vob.pl text-file-with-all-the-clips.txt /tmp/dvd
    (Note that you need to save the script displayed as text to a file named mf2vob.pl. If not, use the name you used in the above command).

    What this does is, takes each of the .mov (or any other format that ffmpeg recognizes) and converts them into a vob file. I have some default arguments for ffmpeg that are close to what DVDStyler was using but if necessary you can change those default setting by editing the $bcmd variable. In addition to converting your original clips into individual vob files, it also prints the "cat" command that you then need to execute.

  5. Copy paste the entire "cat" command and execute as follows
    copy-pasted-cat-command > some-dir/some-file.vob
  6. Then, we need to fix the timestamps. For this, use
    ffmpeg -i some-dir/some-file.vob -acodec copy -vcodec copy some-dir/some-file-ts-fixed.vob
    Once you play the fixed vob file and ensure everything is fine, go ahead and delete the original merged vob file to save some space. These are in GBs, so better delete immediately before forgetting.
  7. Now we are ready to author the DVD with DVDStyler. Open the DVDStyler, drag the ts fixed vob file into the project. Double click on the clip and in the "Chapters" field, clear out the default values.
  8. The perl script above also generates a string called "chapters: ". Take the list from there and paste it into this Chapters field. So, the perl script I wrote essentially automates both .vob conversion and cumulative time stamp calculation.
  9. Now, all that's required is to keep clicking on the menu items and picking the title and chapter. Once you pick the correct title (title1 if you only have one merged file), it automatically displays all the chapters based on the time durations entered in the Chapters field. So, just keep selecting the appropriate chapter and DVDStyler is smart enough to pick the thumbnail for the menu item based on the video at the beginning of that chapter.
  10. One caveat. The computed timestamps are not always accurate. They could be off by at most a second or two (mostly 1 second). I don't know the exact reason for this, but it could be because ffmpeg gives the Duration information only up to 2 decimals and that can cause rounding errors. But that's only one type of error and there seems to be some other issue also contributing to the small offset that I couldn't figure out. The thumbnail of the menu item can help you figure out if the computed value for the chapter is off by a second or two.
Experiment with one DVD, perhaps with just a few chapters and you would become an expert. The whole process takes a few hours, but that's mostly for encoding the vobs and then finally creating the DVD. Add more time to burn the final iso file to DVD. I usually don't directly burn to the DVD and instead generate the iso, mount it, play the DVD with DVD Player and make sure everything is fine and then burn the DVD using Disk Utility.

Below are the screenshots of the DVD main menu and the chapters menu of the DVD I created called "Active Atharv".

© 2012 Dirisala.Net/articles