There are a variety of pages and tools on burning and copying DVDs. This page is being put up for my own personal use, so that I don't have to look things up each time.
I am NOT any sort of video editing expert. There are many articles, (some of them are linked here) that cover the finer points of video editing. The wonderful ffmpeg has all sorts of options that I don't begin to cover. (Even their man page doesn't cover all of them. For example, there is a -vol option, to raise the volume, that isn't mentioned in the man page.) This page is just about backing up DVDs and converting other video formats so that they can be burned to a hopefully watchable DVD.
Most of this has been done on CentOS 5.x and 6.x. How it's done, package names and the like, will differ between distributions, but hopefully, the reader can adapt it to their own needs. The commands, once the various programs are installed, are usually similar, though from time to time, one will find that a distribution doesn't have a particular library.
Note that as of time of writing, I recommend using ATrpms for ffmpeg and other multimedia programs, rather than repoforge (formerly rpmforge). As mentioned below, some of the current (late Fall, 2011), repoforge packages are older versions, possibly lacking features in later releases. There is also the completely unofficial linuxtech repo, which, as the readme points out, consists of packages that its maintainer built for personal use. It has, for example, HandBrakeCLI which is discussed below. It can be found at linuxtech.. The link goes to the RHEL6.x packages, I think those are the only one covered.
In most cases, if one installs mplayer and/or vlc, many of the libraries will be provided as dependencies. One will usually also want dvdauthor, dvd+rw-tools, and ffmpeg. Lastly, I strongly recommend the tovid program, which makes many things much simpler.
These are various tips I've gotten from various places. One of my most frequently referenced pages is the howto-pages.org article. I give other links when I have them throughout this article.
These days, with Linux becoming more and more Windows like, many people prefer the GUI tools to do these things. Judging from various forums, however, sometimes the GUI tools don't work, and just like Windows, it can be difficult to figure out why. CLI (Command Line Interface) tools also use fewer resources, can be run in screen or tmux, and quite possibly provide greater flexibility.
Lastly, note that much of this requires several gigs of disk space.
With all that out of the way, these are methods that work for me.
If you find some glaring error, feel free to drop me a note at scottro11 [at] gmail.com, and also feel free to send your own tips, but don't be offended if they don't appear here. Note that many of the commands will require being run as root or with root privilege using sudo.
cat /dev/scd0 > datadisk.iso |
This will take awhile, but at the end of it, you'll have an ISO file than can be burned to a backup DVD. People also use dd if=/dev/scd0 of=datadisk.iso, but I haven't found any difference.
The iso can now be burned to a DVD with the growisofs command, part of the dvd+rw-tools. I like to check it first, to make sure that it did get what I wanted, so I usually do
mount -o loop datadisk.iso /mnt ls /mnt |
Hopefully, this will show me the various files that are on the original DVD. Once that's done, unmount. Note that the command is umount, NOT unmount, something often missed by newcomers.
umount /mnt |
Remove the source DVD and replace it with a blank DVD-R (or DVD+R, if that's what you use.)
growisofs -dvd-compat -Z /dev/scd0=datadisk.iso |
One can, as is covered all over the place, also make a large collection of files into an iso, then burn that. For example, to make and burn an iso of a directory called my files, assuming you're in the directory that contains the myfiles directory
growisofs -Z /dev/scd0 -R -J ./myfiles |
I have sometimes run into problems with this when making isos larger than 4 GB on CentOS. I haven't had the problem with video files, only with directories containing other types of data.
CentOS, as its users know, is binary compatible with RedHat, which, aimed at the enterprise, will use older, proven stable, versions of packages. The growisofs program relies upon mkisofs. The syntax for mkisofs, (to just create an iso of the myfiles directory) is
mkisofs -J -r -o myfiles.iso ./myfiles |
The ./ refers to the current directory and is probably not necessary, it's simply a habit. The -o is for the output.
Most current distributions actually use the more modern genisoimage. This has no trouble with larger files. If you run the command
mkisofs --version |
on the majority of distributions, you'll see a message like
mkisofs 2.01 is not what you see here. This line is only a fake for too clever GUIs and other frontend applications. In fact, this program is: genisoimage 1.1.10 (Linux) |
In practice, when I do run into problems, I just put the files on either another machine or a VirtualMachine, running something with more current versions of makeisofs. As far as I know, there isn't an rpm for genisoimage for CentOS 5.x, and the one time I tried to install it on CentOS, it needed more current versions of one library or another.
If the file is larger than a DVD's 4.7 GB, one can use a double layer (DL) DVD in the same manner. I've noticed that if it's a DVD+R DL DVD there is a message, when growisofs starts to burn, about splitting layers. I don't see that with a DVD-R DL DVD, however it seems to make no difference.
There are two common tools for this, dvdbackup and vobcopy. I think vobcopy is supposed to be faster, but I've never done any benchmarks.
NOTE FOR CENTOS USERS
Unfortunately, there is no dvdbackup program in the CentOS repos at time
of writing. (March 2010). However, rpmforge has lxdvdrip which includes
dvdbackup_lxdvdrip, and it works the same way.
The problem below has either been fixed or will be fixed
shortly
I'm leaving in the issue mentioned below for reference. However, I
believe that Dag has already pushed the repaired lxdvdrip 1.70 and 1.76
through, so the reader should try to install via normal procedure
first.
The issue was that if one tries to install the package with yum, using the rpmforge repo, (see the CentOS wiki article for information about enabling the rpmforge repo), it will fail, saying it needs dvdbackup and streamdvd.
One workaround is to find old versions of these packages (the oldest I saw were for Fedora Core 4, back when it was called Core), install them with the --nodeps option, then install lxdvdrip. The more elegant, in my opinion, option is to rebuild the spec file, removing those dependencies.
For those familiar with building rpms, I have a revised spec file (slow site, not always available) here. (On the same, somewhat unreliable site, I have my own version of the x86_64.rpm file, here.) This page is not a tutorial on rebuilding rpms. Once again, see the CentOS wiki article for information.
Assuming you know how to do this, if the link above is down, or you prefer to do it yourself, grab the src.rpm from Dag's site (current at time of writing), and install it. Then, in the spec file, you will see a line reading
Requires: dvdauthor, dvdbackup, dvd+rw-tools, mplayer, streamdvd, transcode |
Change it to read
Requires: dvdauthor, dvd+rw-tools, mplayer, transcode |
In other words, remove dvdbackup and streamdvd. Then rebuild it with
rpmbuild -ba lxdvdrip.spec |
Then install it with rpm -ivh lxdvdrip-<version>.rpm. (For example, rpm -ivh lxdvdrip-1.76-1.x86_64.rpm).
Most other distros should have a package for it. I'm not sure about Fedora, but even if it's not in the repos, there is probably a current rpm around. I suppose one could install it on Ubuntu and use alien to create an rpm, but again, that's beyond the scope of this article.
Once it's installed, one can insert a DVD into the DVD drive and run the command
dvdbackup -M -i /dev/scd0 -o backupdir |
(If using CentOS, substitute "dvdbackup," with "dvdbackup_lxdvdrip".) That's assuming you've created a backup directory called backupdir. -M is mirror, -i is input and -o is output. Inside that directory, you'll find a directory containing the DVD files. There will be one parent directory with the VIDEO_TS and possibly AUDIO_TS inside. For our example, we'll assume that dvdbackup called it MYVIDEO
Both vobcopy and dvdbackup may require libdvdcss. Depending upon your country and distribution, this may be be easy or hard to get. As it keeps changing, I'm just going to say that if necessary, and legal--and once again, one assumes you're doing this to make legal copies of what you own--either google for your distribution and libdvdcss or ask on the distro's forums.
If using vobcopy, one first mounts the DVD.
mount /dev/scd0 /mnt |
Now run vobcopy. It seems necessary to put the -m (for mirror) before the -i (for input directory), but your mileage may vary.
vobcopy -m -i /mnt |
This will create a DVD directory in your current directory. Again, we'll assume it's called MYVIDEO. (It isn't necessary to specify an output directory for vobcopy, though you can give it a title if you choose--if you don't, vobcopy calls it by the existing title, in this case, MYVIDEO.) When done, unmount the mounted dvd.
|
Get to the directory containing MYVIDEO (your current directory if you used vobcopy, or backupdir if you used dvdbackup.)
At this point, you can use mkisofs to first create an ISO, then burn it with growisofs, or do it in one step. The two step method, again, assuming you are in the directory containing the MYVIDEO directory.
mkisofs -dvd-video -o video.iso ./MYVIDEO |
If you want to give it a title, you can do that here with
mkisofs -dvd-video -o video.iso -V "MY TITLE" ./MYVIDEO |
This will produce an iso called video.iso. (Obviously, you can call it whatever you want, such as myvideo.iso). You can now check the file if you wish, using mplayer, vlc or your media player of choice. For example, with mplayer
mplayer video.iso |
Now, put a blank DVD in your dvd burner and burn it with
growisofs -Z /dev/scd0=video.iso |
To do it in one step, burning directly to disk without using mkisofs to make an iso first
growisofs -Z /dev/scd0 -dvd-video ./MYVIDEO |
Again you can use the -V "MY TITLE" option if desired.
If you try to play the disk immediately after burning, you might find that mplayer and vlc are unable to play it. Before you say bad words and throw out what seems to be a coaster, eject the disk and replace it. A friend of mine's version of growisofs will do this automatically, (unless one uses the option use-the-force-luke=notray), but mine doesn't. It may depend upon your system, both software and hardware, but regardless, eject the disk once before trying to play it. Once ejected, it's fine. That is, you can eject it and put it directly into a tabletop player and it will play. The tovid suite's "tovid dvd -burn" will also automatically briefly open the tray after burning, depending upon tovid version.
Once again, all this works in the same way with DL DVDs for larger files. If one just wants to make a backup copy of a purchased movie, for example, you can use vobcopy or dvdbackup to copy the DVD, put in a DL DVD and run growisofs as usual.
In some cases, one might just want the file. I've seen relatively complex solutions for, as an example, taking a video with several tracks and playing it on a Macbook Air. One can just copy the directory that was made with dvdbackup or vobcopy, transfer it over network or with USB to a Macbook Air, then play it with VLC. I don't know if Apple's own dvdplayer will play it--it shows up, by default, as a directory in the OS X finder, but dragging the directory into VLC will play it as a normal video.
I also used this article from idolinux.blogspot.com for the first step.
If moving from one country to another, or receiving a present from another country, it may be that your tabletop DVD player can't play PAL or NTSC dvds. As I live in the US, and have only run into being unable to play PAL, this section is geared towards converting a PAL DVD to NTSC format.
Step one is to dump the DVD to a big vob file. The idolinux article suggests using mplayer with
mplayer dvd://1 -v -dumpstream -dumpfile dump.vob |
This works, but I found that the following vobcopy command would also work. First mount the DVD, then use vobcopy as follows, with the -i and -m flags where I have them. (Otherwise, you get the usual video directory, that we used above).
mount /dev/scd0 /mnt vobcopy -i -m /mnt |
Note the order of the -i and -m flags. In this case, we want one big vob file, so the command is done differently than it was above.
This should create one large file called MYVIDEO.vob (with MYVIDEO being whatever title vobcopy was able to get from the disk.)
Next, it's always good to use mplayer or other media player, to make sure it's what you want.
mplayer MYVIDEO.vob |
Assuming it looks good, use the incredibly versatile ffmpeg.
ffmpeg -i MYVIDEO.vob -target ntsc-dvd -acodec copy mynewvid.mpg |
Note that skrud.net's article adds in framerate and aspect. His version is
ffmpeg -i /path/to/vobfile -target ntsc-dvd -r '30000/1001' -aspect 16:9 -acodec copy outputfile.mpg |
I didn't find that to be necessary, it seemed as if ffmpeg figured it out. The -acodec copy means to copy the audio from the source.
Now we have an mpg file. At this point, I use tovid, which segues nicely into the next section. (But see the section on mkv files, where I did find it necessary to include the aspect ratio.)
Installation will be left as an exercise for the reader. It's a popular program, so help should be available on your distribution's forums. Ubuntu has a package for it. If using a distribution such as CentOS or Fedora, you may be able to use Ubuntu's alien to make a working rpm.
I had no trouble with the older version, 0.31. However, 0.33 didn't work quite properly on CentOS 5.5. Therefore, I downloaded the subversion. Instructions are given on the wiki pages. This worked perfectly for me on CentOS 5.5. At time of writing, October 2010, 0.33 is the latest version. For CentOS 5.x users, at least, I recommend using the subversion instead. However, see the note in the make xml section about further changes in the latest subversion.
Also, note that as time has passed, 0.33 is already outdated. Back to 0.33, if you're still using it, the problem is easily fixed. (If you even have the problem I had.) There are several shell scripts placed in /usr/lib/tovid, including one called makedvd. In version 0.33, makedvd has the line
IFS=$'\n' device=($(find -L /dev -type b -name 'dvdrw*' 2>/dev/null )) |
If you don't feel like using the subversion, then, you can fix that script. Note that I've only put in part of the line. The key is to include a maxdepth option in find and it should work.
IFS=$'\n' device=($(find -L /dev -maxdepth 1 -type b -name 'dvdrw*' 2>/dev/null )) |
One other minor point--at present, (2012, at time of writing), some of the more up-to-date distributions are using python 3. For example, in ArchLinux, I used subversion. When I ran the setup.py scripts they had, to build and install, I got errors about unknown modules. Therefore, rather than running ./setup.py build (or whatever command was needed, as per the INSTALL documentation), on ArchLinux, I used
python2 ./setup.py build_doc python2 ./setup.py build_tovid_init sudo python2 ./setup.py install |
The first two commands should only be necessary with a new subversion installation. This is covered in the INSTALL provided with the subversion files.
I'm not going to go too deeply into using tovid here. There are some good basic wiki articles here. (I'm only giving the general wiki page, as the urls of the articles are constantly changing).
One note is that it seems the the repoforge version of ffmpeg doesn't play well with making thumbnails for titles. If making basic text menus, it's fine, but if using thumbnails, it will show the menu, but then hang. The only solution I've found, if I want to use thumbnail menus, is to use a distribution with a later edition of ffmpeg. (This applies to the current repoforge version of ffmpeg, ffmpeg-0.6.1-1.el6.rf. For those who use the ATrpms version, which is something like 0.6.8, this isn't an issue. See this thread on tovid users.
IMPORTANT NOTE: As of tovid 0.32, (I think) the syntax has changed. I've tried to update this page and hope I haven't missed anything. Assuming you have an avi file, first encode it into an mpg.
tovid mpg -in myfile.avi -out myfile_encoded |
(This used to be tovid -in myfile.avi -out myfile_encoded).
It will examine the file and eventually produce a file called myfile_encoded.mpg. Now, make an xml file to use. (Unless using subversion, see the note below).
tovid xml myfile_encoded.mpg -out myfile |
(This used to be makexml myfile_encoded.mpg -out myfile).
This creates a file called myfile.xml.
It seems, though I'm not positive of this, that in the latest subversion, tovid no longer uses tovid xml. Instead, after creating the mpg, one goes directly to creating the disk structure. In subversion, which will become tovid-0.35, the command is, after having created the mpg
tovid disc -nomenu -files myfile_encoded.mpg -out myfile |
The reason for using the -nomenu option is that the default will be to create a menu. As mentioned above, on CentOS and ScientficLinux 6.x with repoforge's version of ffmpeg, this doesn't work.
After creating the mpg, tovid may give a message to use -no-menu and not mention the -files flag. Either -nomenu or -no-menu should work, but -files is necessary.
One minor oddity--I have no idea if it was because I was using subversion or some other reason. I recently, on CentOS 6.2 upgraded ffmpeg, mplayer, and a few other related media packages. The next time I ran tovid mpg on an avi file, it failed, saying it couldn't recognize the avi file. I then uninstalled tovid (which I'd installed from subversion) and installed the latest subversion. After that, it worked. I was in a hurry at the time, and didn't make any investigation as to what broke what, I just mention this in case the reader ever finds themselves in a similar situation.
I do find that tovid's dvd -burn will often, when it's all done, give me an error, saying something to the effect of input/output error, write failed, then a row of !'s and message that it encountered an error. However, in all cases, as long as the rest of the burning seems to have gone successfully, that is the usual whatever% done, estimate finish and so on, that there is no problem. I eject and replace the dvd, test it with mplayer, and all is good.
While on the subject of menus, if making something with menus, mplayer now supports dvdnav. This means that if I've made something with a menu, and want to check it, and the directory was called myvideo I can check with
mplayer -dvd-device ./myvideo dvdnav:// |
This can then be navigated with the number pad, using 1,3, 4, and 6. with 7, the home key on a standard US keyboard number pad, taking you back to the menu.
Depending upon your distribution, mplayer also has a default input.conf. In CentOS, with the atrpm version, this can be found in /usr/share/doc/mplayer-<version>/. On ArchLinux it seems to get installed in /etc/mplayer.
If you don't have the file in /etc/mplayer or your home/.mplayer directory, then the normal arrow keys won't work with dvd navigation. On a laptop, you might be able to select an item, but not get back to the menu. So, if your normal arrow keys (as opposed to number pad arrow keys) aren't working properly, make sure you have the input.conf file in /etc/mplayer or your home .mplayer directory.
If you do have the file, then you should be able to navigate with the normal arrow keys, using the escape key to get back to the menu.
If using tovid 0.34, one can can immediately burn the dvd, or first create the structure. To create the structure in a separate step
tovid dvd myfile.xml |
(This used to be makedvd).
This will create a DVD directory called MYFILE. Then you can burn it with
tovid dvd -burn ./MYFILE |
To do it in one step
tovid dvd -burn myfile.xml |
This will make the structure, then burn it. If you have two dvd burners, then specify the device.
tovid dvd -device /dev/scd0 -burn myfile.xml |
(This isn't always necessary--however, sometimes I've found that for some reason, CentOS will symlink /dev/dvd to /dev/scd1 rather than /dev/scd0.)
If one already has an mpg file, they can just skip the first step of tovid mpg -in infile -out outfile. For example, in the previous section about PAL and NTSC, we created an mpg file called outputfile.mpg, using vobcopy and ffmpeg. Once that file is created, I can finish the job with tovid's xml command.
tovid xml outputfile.mpg -out outputfile |
Once that's done, I can use tovid dvd as described above.
By default, I believe tovid still uses mencoder. This can take a long time as it encodes audio and video separately. Using ffmpeg is much faster, but has to be specified.
tovid mpg -ffmpeg -in myfile.avi -out myfile_encoded |
At time of writing however, if using ffmpeg, you can't use subtitles unless they're already hardcoded into the avi file. If you want to include subtitles, don't use the ffmpeg option. Also, as the man page points out, when one does insert subtitles, they are hardcoded into the resulting mpg file, meaning you can't turn them off. I'm not covering subtitles here, see the man page.
I have seen tovid have problems with some High Definition Blu-Ray ripped mp4 files. If using ffmpeg, it takes about 10 seconds and the resulting mpg file is a 0 byte file. If not using the ffmpeg option, it will examine the file, then exit with a message about having a problem encoding the audio to ac3 format.
When that happens, once again, ffmpeg can save the day. When I have run into this situation I've been able to fix it with
ffmpeg -i myfile.mp4 -target ntsc-dvd file.mpg |
From there, I was able to use tovid xml on the mpg file and create a reasonably good DVD.
The video track will usually be track 0. The audio track will usually be 1, and if there's a second audio track, that will be 2. (One way to confirm which is which is to use vlc and select the audio track from its menu. Howard covers ways to do it all from command line.)
In this case, we'll say that the first audio track, 1, is in French and the second, 2, in English, and the reader only wants the file with the English track.
ffmpeg -i movie.avi -map 0:2 -target ntsc-dvd file.mpg |
As usual, there are many more options that can be used. In this case, we're creating an mpg file that can be made into a DVD but will only have streams 0, the video, and 2, the English audio.
On a somewhat related note, ffmpeg can grab a section of a media file. If you want to only grab 5 minutes of a 20 minute video, the options are -ss in seconds for the start time and -t for the duration, also in seconds. You can also use HH:MM:SS, that is hours, minutes, and seconds. For example, if you have a 20 minute video and you want to only get the second five minutes of it, the syntax would be
ffmpeg -i myvideo.avi -ss 300 -t 300 fiveminutevid.avi |
That means you will grab the video beginning at 5 minutes (300 seconds)
into the video and stop grabbing after 5 minutes (the second 300).
Again, one can use the hours:minutes:seconds format for both the -ss and
-t options.
Another common option with the command is -sameq, to keep the same quality as the original. Otherwise, the excerpt may be of poorer quality. So something like ffmpeg -i -myvideo.avi -ss 300 -t 300 -sameq fiveminutevid.avi will ensure that the excerpt has the same quality as the original.
mount /dev/scd0 /mnt vobcopy -i -m /mnt ffmpeg -i MYVIDEO.vob myvideo.avi |
While such simplicity might make purists gnash their teeth, it works, and is handy when, for example, one has a home made dvd from a camcorder that they wish to share with friends.
avimerge -o newfile -i file1.avi file2.avi |
My biggest problem with it was that it would often go out of sync with the sound--so that when it neared the end of the merged file there would be silence--the entire sound track from both files had already been done. It does have a -c option, meaning that one should drop video frames, in case audio is off. The explanation from the man page is that some avi files run a little bit short on audio so that when merged avimerge loses sync. So, using the -c option, e.g., avimerge -o newfile.avi -i file1.avi file2.avi -c (judging from the man page--the syntax may be avidmerge -c and then the rest of it but neither worked for me), will, in theory drop enough video frames so that the audio remains in sync. As I said in the previous sentence, however, it didn't work for me. I would still wind up with a merged avi file with sound completely out of sync.
I've had the best luck with mencoder. I used the syntax from a page by someone named Wilt. The syntax I use, (taken from Wilt's page) is
mencoder -oac copy -ovc copy -noodml -o newfile.avi file1.avi file2.avi |
That should be on a single line. The options are explained in the link above, oac and ovc are copy transfer mode for video and audio, noodml means don't write OpenDML index, -o is for the output file. This gives me a perfectly synced single avi file.
Usually, tovid and ffmpeg can deal with them normally. The my-guides site has a good article on converting to avi with VLC.
Sometimes, I have run into issues trying to simply feed an mkv to ffmpeg. However, so far at least, I've always been able to use the -target ntsc-dvd option that I mention in the tovid section, to get reasonable mpg files.
I've also been able to strip out unneeded subtitles. For that one can either use the ffmpeg option -map mentioned in the removing unwanted audio, or use the excellent mkvtoolnix suite of tools.
For CentOS 6, I used the EPEL-testing repo. For information on CentOS repos, see their wiki article. I had to play around with its dependencies though--enabling epel-testing repo gave me an error about libcurl, but downloading the rpm directly, then doing rpm -ivh worked--it needed some boost-filesystem files, which I found usin yum provides */<missing_dependency>, e.g yum provides */libboost_filesystem-mt.so.5 which was one of the errors.
One of the tools in the suite is mkvmerge. To remove subtitles from the mkv, use the -S option. The syntax is (if the original is called file.mkv and you wish the new file to be called newfile.mkv
mkvmerge -S -o newfile.mkv file.mkv |
Actually, in at least one mkv file, using ffmpeg -in myfile.mkv -target ntsc-dvd myfile.mpg automatically stripped out the subtitles. I'm not sure how that happened though.
If such a thing happens, and you want to keep the subtitles, one can then extract them with mkvextract. As a rule, the subtitle will be track 3 (1 and 2 usually being video and audio). You can get this information by running
mkvmerge --identify file.mkv |
You will get back something similar to
File 'file.mkv': container: Matroska Track ID 1: video (V_MPEG4/ISO/AVC) Track ID 2: audio (A_AC3) Track ID 3: subtitles (S_TEXT/UTF8) |
The subtitles can then be extracted with mkvextract.
mkvextract tracks file.mkv 3:file.srt |
Now, if you use mplayer to play the mpg that you made with ffmpeg, as long as the srt file is in the same directory, mplayer will automatically use it. Note that the srt file has to have the same name as the mpg file. So, if the file made with ffmpeg is myfile.mpg the srt file has to be named myfile.srt.
As mentioned below, the mpg file may be much smaller than the mkv file. In one case, I had the mpg file without subtitles. I didn't really need the 7 GB mkv file, but also wanted an mpg with subtitles hardcoded into it. To do that, I went back to tovid. I had myfile.mpg and myfile.srt, which I'd gotten by using mkvextract as mentioned above. To create a second mpg file with subs
tovid -subtitles myfile.srt -in myfile.mpg -out mynewfile |
This created a new mpg file with the subtitles. (Note that as mentioned elsewhere in this article, one can't use ffmpeg with the -subtitles option.) The mpg was about a gig larger than the non-subtitled mpg, but still less than half the size of the of the mkv file.
One problem I have run into with that is on some widescreen files. If you run mplayer myfile.mkv and hit ctl+C shortly afterwards, it might show that the aspect ratio is something like 2.21:1 or 2.50:1. What will happen is that it will create the mpg which is fine.
From there, I used the tovid's suite xml and dvd commands. However, I received a series of messages like WARN: unknown mpeg2 aspect ratio 4. When I tested the dvd file, it had squashed the wide screen into a square format, complete with distortion of the picture. The way around it seems to be to use an aspect ratio of 16:9 with
ffmpeg -i myfile.mkv -target ntsc-dvd -aspect 16:9 myfile.mpg |
This still seems somewhat square, but it works. I've not yet found a good solution for this problem. Some folks use padding, others use -s as in size rather than -aspect, but I've yet to find the perfect solution for that pesky 2.21:1 (or 2.40 or 2.50) aspect ratio.
A thread with several suggested solutions can be found here, but none were perfect for me.
One handy option for ffmpeg when testing this is the vframes option. If I'm testing an aspect ration, I only need a minute or so of the file. I can run something like
ffmpeg -in myfile.mkv -aspect 16:9 -vframes 2500 myfile.mpg |
This way, rather than waiting for the entire file to be converted, it will only work with the first 2500 frames, taking a minute or so. I can then play the mpg file and see if I am happy with the new aspect ratio.
One should also note that the mpg file will usually be smaller than than the mkv file, so that even if one is working with a 7 GB mkv file, the result might be burnable to a standard 4.7 GB DVD. (Of course, using the tovid suite also took care of it, tovid puts all those options in for you. Although I mention the --split option of mkvmerge below, if the reason for using it is to hope to get an mpg file that will fit a normal size DVD, it may be unnecessary. For example, I've had 6.6 GB mkv file, and after running tovid on it, to turn it into an mpg, the mpg was only 1.6 GB.
As for the aforementioned mkvmerge--as it name implies, it can merge files, but it can do several other things. The general syntax is mkvmerge --[various options, such as split] -o (outfile) filename. Despite the merge in its name, it can also split files based on time or size. For example, if you had a 7 GB mkv file that you wished to split into two smaller mkvs, of about 4 GB and 3 GB, you can run
mkvmerge --split size:40000m -o output.mkv myfile.mkv |
This will create 2 files output-001.mkv and output-002.mkv. The man page goes into more detail. One can also do it by time, as per the example in the man page. To split after an hour's duration
mkvmerge --split duration:00:60:00.000 -o output.mkv myfile.mkv |
The format, according to the man page, must have the form of HH:MM:SS.nnn or be in seconds, e.g. --split 3600s. The man page goes into more detail, also noting that it will split right before the next key frame, so the division might not be exactly what you expected.
The mkvinfo file mentioned above can also be useful for things like removing subtitles, especially if you wanted to use the ffmpeg -map option previously mentioned. Just run mkvinfo myfile.mkv to get various information about the file, including the audio and video and subtitle, if included, track.
I found one other useful mkvmerge trick from an article on automate-everything.com. I wanted to combine a cd1.avi and cd2.avi. However, they had subtitles. In this case, rather than a srt file, each avi had its respective .idx and .sub files--one needs both in order to get the subtitles working. However, with the trick from this article, I was able to make each avi file into an mkv with the subs hardcoded into the file. With cd1.avi, cd1.sub, and cd1.idx all in one directory, I ran
mkvmerge -o video.mkv cd1.avi cd1.idx |
I then did the same with cd2 so that I now had cd1.mkv and cd2.mkv. To combine them I used mkvmerge with a + to append rather than add, as the man page puts it.
mkvmerge cd1.mkv + cd2.mkv -o newcd.mkv |
However, when I wanted to burn this to a disk, tovid, even using mencoder instead of ffmpeg, didn't do it properly. In the end, I googled various methods of harcoding the subtitles into the mkv using mencoder. As I had mixed results, and didn't keep track of what I was doing, I advise the reader to just google, using a term like hardcode subs with mencoder.
One sample, which has worked for me in the past is
mencoder -slang eng -of lavf -lavfopts format=mp4 -oac lavc -ovc lavc -lavcopts aglobal=1:vglobal=1:acodec=libfaac:vcodec=mpeg4:abitrate=128:vbitrate=1200:keyint=250:mbd=1:vqmax=10:lmax=10 -vf harddup file.mkv -o file.mp4 |
This hardcoded English subs into an mp4 file. From there, I was able to make an mpg with tovid.
Elsewhere in this article (I probably should have given subtitles their own section), I mention working with tovid and srt files. There's a pretty neat little tool that will take a sub and idx file and turn them into a nearly perfect srt file, using the command line. It needs tesseract, which I didn't find on CentOS--I wound up using more current Arch installation. The instructions on the author's site are for Debian and Ubuntu based distributions. If the reader is unfamilar with git, the way to get the program, before doing the configure and build the author mentions, is to run the command
git clone https://github.com/ruediger/VobSub2SRT |
This will create a directory called VobSub2SRT in whatever directory you were in when you ran the command. At that point, you can follow the author's instructions. It should be a simple ./configure && make && sudo make install, but the README seems to be updated from time to time, so it's suggested that the reader check the above link for the author's latest information.
Using the program, by, for example, putting mysub.sub and mysub.idx in one directory, then just running vob2srt mysub will produce a mysub.srt file. At that point, one can refer to the information given in the tovid section.
ffmpeg -i input.avi -vcodec msmpeg4v2 smaller.avi |
In my case, I wasn't happy with the results. This may have been because of the avi files I used, but the results were quite poor, giving me heavily pixilated videos.
In contrast, shrinking mp4 files went well.
ffmpeg -i input.mp4 -acodec mp2 smaller.mp4 |
In one quick test it reduced a 166MB mp4 file to 98MB with little loss (to a non purist) of quality. The user is advised to judge for themselves whether the lost of quality is a problem for them.
Going back to avi files, I found that converting the avi to mp4 with ffmpeg reduced the size from 176MB to 86MB. In some cases a simple ffmpeg -i file.avi file.mp4 gave me an error of
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height |
Apparently this was an audio compatibilty issue and using ffmpeg -i file.avi -acodec copy file.mp4 fixed the problem. In this case, once the file was converted to mp4, trying to compress it further with the -acodec mp2 command only made it a few megabytes smaller, so I wouldn't bother trying for further reduction in size.
This is being used with the very kind permission of the author.
Assume that your Rapidshare username is john and your password is 1234. Make a directory in your home directory, .cookies. (Note the dot before the name, this keeps it a hidden file). Now run the command
wget --save-cookies ~/.cookies/rapidshare --post-data "login=john&password=1234" --no-check-certificate -0 - https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi > /dev/null |
That's all one line (or one can break the line with \ as is done on the original link.)
Note that that is an upper case letter o, not the numeral zero.
Next, make a shell script. (Again, this is exactly the same script that Axel gives at my-guides.)
#!/bin/bash for url in `cat $1` do wget -c --load-cookies ~/.cookies/rapidshare $url done |
Save it somewhere in your $PATH, for example, $HOME/bin, and call it downloader.sh Make it executable with chmod 755 downloader.sh
Now, if you have a list of urls, such as rapidshare.com/file1.rar rapidshare.com/file2.rar, rather than having to go to each url, make a list of all the urls and save them as a file called urls, which might read
http://rapidshare.com/file1.rar http://rapidshare.com/file2.rar http://rapidshare.com/file3.rar |
(As we all know, the urls are much longer than that, and more of a nuisance to type.) Now, to get your batch of files just type
downloader.sh url
Again, this is taken EXACTLY from the my-guides.net and many thanks to Axel, the author, as it was just what I needed.
If, for example, your friend has made a DVD of their child's dance recital, they may have uploaded it as a series of rars. This will usually have a suffix of something like dance.001.rar, dance.002.rar, and so on. They may also appear as dance.r001, dance.r002. They will usually have either an r00 (or 00.rar), or possibly a number starting at 02. (See below when I explain creating rars.) I'm not sure how Windows rar programs do it, but it's usually fairly easy to figure out. There might be a series such as r001, r002 and one file with a suffix of .rar. In any case, figure out the first file--if you guess wrong, you'll probably get an error message. Assuming it was in the format of r001, r002 and one file with a rar suffix, and that that file is called dance.rar, the syntax is
unrar e dance.rar |
You will see it gradually decompress the files, and when it finishes, you will have an avi, iso, or whatever the original file's format was. If there is no separate rar file, and they're all listed as 001.rar, 002.rar, then run unrar on the lowest number, e.g., unrar e dance.002.rar.
One important point, at least in CentOS' and FreeBSD's versions of rar and unrar is that the command must be run as shown above. If you run rar -e dance.rar, you'll just get a list of available options. (Note that you don't actually need unrar, as rar e will do the same thing as unrar e.
Sometimes, the sender will have an sfx file. This is a self-extracting executable and you can run unrar on that. In that case, the file names will be something like dance.01.sfx, dance.02.rar. One can run unrar e (or rar e) on either the 01.sfx or 02.rar and it will work, it doesn't seem to matter.
Much of this depends upon who you might be sharing files with--if they're your family, they might find it easier to work with rar files. The very few times I've done this were to send Linux iso files to someone who was unable to find a download site, so we used p7zip, so I really don't know--I assume, but it's only an assumption, that the rar format is more popular because it's a more common MS format, though p7zip should work with either unrar or the Windows only 7-zip app.
Regardless, to create a rar archive, the simplest method is to first create a directory, as it will create 50 or more files, depending upon the size of the original file. So, we'll create a directory, copy the dance.avi into it, and make a rar archive. Assuming we are in the directory that contains the dancevideo, which we're calling dance.avi
mkdir dancevideo cd dancevideo cp ../dance.avi . rar a -v15m dance |
You will see it creating the rar files. The a is for add. Again, note that like the e for extract, there is no leading -. For those less experienced with command line, the cp ../dance.avi . has a space and period after the file name. That single period means current directory, so we are copying the dance.avi to the current directory.
The -v15m means each file will be 15 Megabytes. Oddly, in CentOS, if I then did a du -sh on the individual rar files, they showed as 16 Megabytes---to get a du -sh of 15MB, I had to use -v14m. I don't know why. CentOS is the only Linux I've tried it with so I don't know if it's just one more thing that RedHat doesn't do right or if it's a Linux thing. FreeBSD works as expected, if one uses -v15m each rar is 15 Megabytes.
The p7zip program should be available in most distributions. It should also pull in p7zip-plugins. (The names may differ between distributions--I think Ubuntu calls it p7zip-full which brings in both programs). It provides 2 programs 7z and 7za. 7z handles more formats, 7za is a standalone executable. For our purposes, we can use 7z.
Therefore, the actual command is 7z. So, to use it to create an archive
7z a -v15m dance |
This will create files called dance.7z.001, 002, and so on. One would extract them the same way as unrar, 7z e dance.7z.001. As mentioned in the rar section, if someone sends you a rar archive, you can extract it withe 7z e whatever.rar (or r01, or sfx).
7z seems to be a bit faster than rar. I've only benchmarked it very roughly (using the time command to unrar something), so don't take that as a definite fact. Also, once again, in CentOS, using -v15m results in files of 16MB, so once again I use -v14m when making a 7z archive in CentOS.
LiteOn and LG, to name two, make inexpensive, lightscribe capable burners. Lightscribe capable DVDs are usually available, if you look around, for little more than the cost of normal DVDs.
Once the burner is installed, for rpm or deb based distros, the software can be downloaded from Lightscribe's site. First get the system software. You can then get the simple labeler software as well. This creates a directory in /opt called lightscribeApplications. To run the labling software run /opt/lightscribeApplications/SimpleLabeler/SimpleLabeler. It allows you to enter text--you can choose fonts from your system fonts. It creates a very simple label, both top and bottom text if you desire, that is, on each side of the center hole.
If, when running the application, it says something like no lightscribe drive available, try adding the following at the end of your /etc/lightscribe.rc
DriveEnumeration=false; CDROMDevicePath=/dev/scd0; |
Note the semicolons at the end of each line--I missed that and wasted a good deal of time on google. Now try running the application again.
Most of Lightscribe's applications are for Windows and/or OSX. For somewhat fancier labels, you can use LaCie's software. The only way I was able to download the 4L lableling software (the lightscribe driver itself can be downloaded from their site, but it seems to be older than what's available at lightscribe.com), was to use the link provided on the fedorasolved site, running the command
wget http://www.lacie.com/download/drivers/4L-1.0-r6.i586.rpm |
However, it may be available in your distribution's repositories.
I've been using the 4L software with the lightscribe.com's lightscribe software without problem, as opposed to using LaScrie's lightscribe driver with the 4L software. However, either should work.
After installing the 4L software, you can run it with
4L-gui |
This opens a menu that allows you to import image files by clicking (at time of writing) the uppermost left icon. From there, playing with the icons at bottom, you can fit it to the height and/or width of the disk, or manually scale the image. After that, clicking the upper right icon burns the image to disk.
In Linux at least, one can only make a cover in black and white. I usually convert an image to grayscale, using ImageMagick's convert function.
convert -type grayscale foo.jpg foo_bw.jpg |
If backing up a movie, one can search for a cover at cdcovers.cc or similar site.
One last note. On rare occasions, 4L (or SimpleLabeler) might tell you that it doesn't see a LightScribe writeable disk and that you should clean the disk according to the LightScribe documentation. This may be due to a small smudge on the inner ring, around the hole in the DVD. That inner ring has some data used by LightScribe. So, if you get that message and the label side seems clean, try cleaning the inner ring of the DVD. The one time it happened to me, I just wiped it with a dry cloth, and after that, it was fine.
HandBrake is a nice GUI tool that has both iPod and iPad preformats. It also has a command line version, HandBrakeCLI. The 0.9.5 version has an iPad preformat. In that case, one can run
HandBrakeCLI -i myfile.avi -o myfile.mp4 --preset="iPad" |
I've also seen it done without the = sign. Both seem to work. Sometimes, it's taken much longer than ffmpeg, other times, it's been quicker. I haven't found a pattern, nor can I say one uniformly produces better or worse quality than the other. It depends upon the source.
I usually just compile HandBrakeCLI. I've not had success with recent subversion on CentOS, but did get the latest tarball (0.9.5 at time of writing) to work on CentOS 6.x. On other distros, I get it with subversion.
svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk cd hb-trunk ./configure --launch --disable-gtk |
That's going by the online instructions. However, they tend to not work for me, which might simply be my lack of understanding.
I've had more consistent success with using ./configure --disable-gtk (that is, without using launch) This creates a build directory. Then, chang into the build directory and run make . This actually only makes the build, so when it was done, run make clean. This creates the binary. In other words one might be best off doing
.configure --disable-gtk cd build make build make clean sudo make install |
(Assuming you've built it as regular user, which you should, and then install it.)
Or, possibly make -j4 build clean. And, sometimes, it's worked perfectly for me to just run ./confgigure --disable-gtk, then cd into build and run make once, creating the binary. I've really gotten no consistency with build attempts on different distributions--all of these methods have sometimes worked and sometimes caused errors, and I've not figured out the reason.
To summarize, sometimes it has worked by following the instructions and doing ./configure --launch --disable-gtk, sometimes it has worked by doing ./configure --disable-gtk;cd build;make, sometimes I have had to, after cd-ing into build, run make twice, sometimes I have had success doing make build clean, and so on. So, I would start by trying the --launch one, if that doesn't work, doing ./configure, cd-ing into build and running make, then running it again if no binary is created. If I ever figure out something that works for me on all distributions, I'll post it here.
Another issue that I haven't yet solved with Handbrake is importing subtitles. It seems that it can't burn srt subtitle files into a video, as far as I can tell from quite a bit of googling, though the help file included doesn't mention this.
To further confuse the issue, it may just be that it can't burn plain text files into a video. I've had some success with
HandBrakeCLI -i myfile.avi -o myfile.mp4 --preset="iPad" --srt-file myfile.srt --srt-default |
To the point where, in VLC, if I went into the menu and looked, I was able to enable them. However, they didn't show up in mplayer. As it's almost never a factor, since I tend to watch movies on Linux, I haven't really investigated.
So far, on the few movies where I've needed the subtitles, I've first hardcoded them in with tovid (making sure to use mencoder rather than ffmpeg--see the tovid section), then run HandBrakeCLI on the resulting mpg file, or with mkvmerge. (Which is much quicker.) For mkvmerge, the syntax would be
mkvmerge -o newfile.mkv myfile.mkv myfile.srt |
On a 30 minute 105MB mkv file, it took about 3 seconds. However, this too has been inconsistent. Although the resulting newfile.mkv had the subtitles showing up with mplayer, when I used HandBrakeCLI to make it into an mp4, the resulting mp4 didn't have the subtitles. So, at this point, it seems that when I do need it for an iPad, I'll stick with tovid mpg -in myfile.mkv -subtitles myfile.srt -out myfile. I suspect I'm missing something, and when I figure it out, I'll post it here.
The trouble with using ffmpeg on this is that you'll have to find a guide that matches your system. One can just do a straight ffmpeg -i myfile.avi myfile.mp4, but while it will be watchable, the format may not be that good. Some guides will say use -acodec aac and then you'll use a different system and find that in that case, aac is unknown. Google, and you'll find that you should use libfaac on that distribution. (Or vice versa). In some cases, libfaac won't work, and if you use aac you are told that you must add strict experimental to the command line. It can be a bit frustrating. If you do get that error, the syntax is ffmpeg -i myfile.avi -acodec aac -strict experimental out.mp4 Another possibility, that I've found this one useful for flv files as well, is use -vcode and -acodec copy, which doesn't re-encode, but does change the format. (Thanks to a Learnosity post.
ffmpeg -i myfile.flv -acodec copy -vcodec copy output.mp4 |
Or, if your distribution has it, libflaac for audio.
ffmpeg -i myfile.flv -vcodec copy -acodec libfaac -aq 200 output.mp4 |
The -aq 200 is to improve audio quality. That one doesn't work on CentOS 6.x, I get unknown encoder libfaac, although the various faac packages are installed. Note that below I mention using libfaac, that was on CentOS 5.x. As I said, it's often difficult as different distributions and different versions of a distribution will have different names for a particular codec.
I've had the best results with the conversion matrix. The only thing different was the vpre option. There's is -vpre iPod640, however, on CentOS, one must use ipod rather than iPod. (The -vpre presets are listed in /usr/share/ffmpeg.)
ffmpeg -i myfile.avi -acodec libfaac -ac 2 -ab 160k -s 1024x768 -vcodec libx264 -vpre slow -vpre ipod640 -b 1200k -f mp4 -threads 0 outfile.mp4 |
That worked with two out of the 3 videos that I played with. If that doesn't work for you, on CentOS, I've also used 19 ffmpeg commands for all needs. I was able to use the following on CentOS 5.6 with success.
ffmpeg -i source_video.avi -acodec libfaac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 out_video.mp4 |
This usually works--on occasion, it will give an error which will include timebase not supported by mpeg4 in which case, you can usually fix it by adding -r 25 as a parameter. In other words
ffmpeg -i source_video.avi -acodec libfaac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -r 25 out_video.mp4 |
The size should be 1024x768, but I find, using this syntax rather than the other one with the -vpre option that if I put -s 1024x768 in the ffmpeg command line, when copying the file to an iPad, iTunes will say it can't be played on this iPad. I haven't found the solution for this.
Either way, it seems more dependendent upon the size and ratio of the original avi. Even when the -s 1024x768 didn't give me an error, (in the first example, using -vpre), it still didn't play full screen. This is quite possibly due to an error on my part, but even using HandBrake, the video didn't come out as 1024x768.
Once the file is converted, you can transfer it to a Mac (or Windows machine with iTunes), add it to your iTunes library, then transfer it to your iPad.
The problem is that it only works on some dmg files. Many times, it will error out, saying it's not a proper dmg file, or something similar. Other times it works like a charm. Your mileage may vary.
As every time I've seen someone post the question about how to burn a dmg on a Linux machine on a forum, someone who doesn't know the answer asks, you shouldn't do that, why are you working with proprietary software on Linux, or something equally only relevant to those who don't use Linux for actual work, let me explain that anyone who works in an environment where both Linux and OSX are used might have a reason to do it. Perhaps the IT department only has Linux and Windows machines, with OSX reserved for customer service, and one has to distribute a properly purchased and licensed program to various users. That's just one example. Sometimes, the Mac users are doing something resource intensive--my own, non-benchmarked impression is that my Linux box uses less resources, and takes less time than using OSX's builtin burning programs. At any rate, there are various reasons it might be easier to do it on the Linux machine,
However, as mentioned, it doesn't always work. One can also try running mkisofs on a dmg, burning it to a DVD and seeing if it works. For example
mkisofs -o myimage.iso myimage.dmg |
Then the usual
growisofs -dvd-compat -Z /dev/scd0=myimage.iso |
Like acertone, this one doesn't always work.
The poweriso program itself, is another that sometimes works. It can be downloaded here. It's a tar.gz of the binary. Extract it with (version number may change, it's 1.3 at time of writing)
tar xvf poweriso-1.3.tar.gz |
This will give you a binary file called poweriso. Move the binary to your $HOME/bin, or /usr/local/bin.
mv poweriso /usr/local/bin |
To use it to convert a dmg to a burnable iso file, run
poweriso convert myfile.dmg -o myfile.iso |
There are a few other options with the tool. Run poweriso -? for a list.
The easiest way, of course, if one does have a Mac, is to right click on the image and choose burn to disc, but as mentioned above, sometimes, it is simpler to create a DVD on another machine for various reasons.
As mentioned, my main reason for this article is to save myself some time. It is hoped that the reader finds at least some of it to be useful.