apple tv, ati, boxee, computing, cuda, Howto, intel, kde, kde4, Linux, Media Center, mediagate, mediaportal, microsoft, Microsoft Media Center, mplayer OpenSuSE Sabayon compile k9copy proprietary codecs, nvidia, opensuse, playstation, ps3, sabayon, VDPAU, Windows, windows 7, xbmc
We’re all recording our TV shows etc onto computer files nowadays, thanks to XBMC, Windows Media Center, Media Portal, Apple TV and even Sony Playstaion, many of us are enjoying a rich online library of content to show off to our friends. For me, the first thing I do when I buy a DVD is rip it to an mkv and store the DVD away in the cupboard. I just wish you could take a USB stick down to the video store and have this done already. But no go, so I do it myself.
This is something I’ve been doing for years. There’s just no excuse for bad quality huge file size divx files anymore. While I might have been fortunate enough in the past to have always had a dual-core while some people haven’t had that fortune, many years have passed and this type of hardware is extremely common these days. The number one reason why using the 264 codec wasn’t popular for most was simply encoding time, if you didn’t have a dual core you would have most likely been looking at about 3-7 days to encode a single file. But don’t fret, this is no longer the case.
This method, (although not rocket science at all) is often overlooked in favour of other, more historical methods out of sheer laziness. With this method it is common to produce a file between only 700MB and 1.1GB that includes a full resolution video track with NO loss in quality that I’ve ever been able to see, a full uncompressed copy of the original AC3 and/or DTS soundtrack, full chapter support, multiple subtitles and even a copy of the cover art. When I say no loss in quality, I really do mean it. I’ve looked at these things so hard, found the smallest little error and then ended up realising it was actually a problem on the original DVD. It’s important to note actually, that if you’re fussy, the kinds of issues you’re likely to be looking at will actually NOT be with the encoded file, but in the original source.
Why would I do it on linux? Well, for starters, when it comes to encoding, linux is faster and not just a little bit either, quite a lot actually. I can’t comment on Windows 7 at this point, but certainly on prior versions, Linux has had a considerable lead on encoding time. I suspect former versions of Windows did not support the new processors properly. This goes double when you have a quad core machine or higher. Plus, if you’re feeling particularly greedy, you can install the 64bit version of linux and compile your own copies of the encoder in sabayon for your specific CPU and hardware using the emerge command. If you’re going to do a lot of encoding, the 64 bit / manually compiled encoders add quite a bit of extra speed. If you’re lucky enough to own a core i7 you would get even more advantage out of the maths capabilities of that architecture. A typical scenario on my Intel Quad Q9300 takes about 2 hours to complete the mkv file above without manual compiling and running 32 bit Sabayon KDE.
**Before you start, please be aware that I in no way wish to support the pirating of DVD’s for spreading across the internet. This guide is for personal use only and is intended to be used only for the transcoding of your already owned media to your own personal system.**
Righto, now that that’s over, we can begin.
Make the ISO
This script (h264enc) will actually encode/transcode from just about any format to any other format. In fact it has presets for everything from blackberry’s, psp’s and ps3’s to generic hardware based DVD players. For the sake of this guide however, we will concentrate on encoding an MPEG-2 ISO file made from DVD to an MPEG-4 mkv file playable on any good media centre such as XBMC or media portal.
While you can use this method to encode from other DVD structures, ISO’s are the easiest method, so we will focus on that here. I’m not going to go into how to make an ISO from a DVD disc, however I can point you to k9copy for linux and DVD Fab HD Decrypter for windows. Sometimes the windows method is preferred as Linux often is not up with the latest methods of extracting this information from a DVD. The only comment I will make, is don’t bother to ‘Shrink’ the DVD to a 4.3GB ISO. Since we won’t be trying to put it on a single layer disk (in fact we can fit four mkv files on a single layer DVD (therefore four movies)) having the original 9GB file will actually help your final encode to be higher quality since the source will have more colour bits in it to read from.
Get the software
In Sabayon you will need to install the following software:
mplayer, ogmtools (for chapter support), gpac (if you want to convert for PSP etc),
mkvtoolnix (for mkv support), h264enc, smplayer (just because it’s the best media player for linux and windows) :)
There are other packages that would be useful depending on what you want to do with h264enc, but for the sake of this example I’m leaving them out for now.
# equo install mplayer smplayer gpac mkvtoolnix ogmtools
Then you need to download h264enc from the website since it’s not currently included in Sabayon and this way you don’t have to wait for an ebuild to be made.
Browse to http://sourceforge.net/projects/h264enc/files/ and get the latest version.
Extract the version you downloaded using tar -zxvf fileyoudownloaded
go into the directory that was just extracted, probably h264enc9.0.1 or something like that.
type ./install and follow the simple questions.
Checking your config
You should now have all the relevant files installed. To check, as your NORMAL user enter the following:
$ h264enc -sc
You should get output similar to the following:
someone@somemachine ~ $ h264enc -sc
-> Checking for ‘MPlayer’………………… OK
-> Checking for ‘MEncoder’……………….. OK
-> H.264 video support in MEncoder………… YES
-> AAC (FAAC) audio support in MEncoder……. YES
-> MP3 (LAME) audio support in MEncoder……. YES
-> AC3 (lavc) audio support in MEncoder……. YES
-> PCM audio support in MEncoder………….. YES
-> Checking for ‘bc’…………………….. OK
-> Checking for ‘pv’…………………….. FAILED! [no support for DVD ISO dumps]
-> Checking for ‘dd’…………………….. OK
-> Checking for ‘neroAacEnc’……………… FAILED! [no support for AAC+ audio]
-> Checking for ‘aacplusenc’……………… FAILED! [no support for AAC+ audio]
-> Checking for ‘oggenc’…………………. OK
-> Checking for ‘flac’…………………… OK
-> Checking for ‘less’…………………… OK
-> Checking for ‘lsdvd’………………….. OK
-> Checking for ‘dvdxchap’ (from ogmtools)…. OK
-> Checking for ‘mkvmerge’ (from mkvtoolnix).. OK
-> Checking for ‘ogmmerge’ (from ogmtools)…. OK
-> Checking for ‘MP4Box’ (from gpac)………. OK
-> Checking for ‘tsMuxeR’………………… FAILED! [no support for the TS container]
If you have installed a required program but the script
can’t find it, run ‘h264enc -r’ to reset the config file.
Don’t worry about the missing aac etc, you don’t need that. In fact you’re all done! All that remains is to run the script.
Before we run the script I need to point out some more things. I’m not going to step by step you through the script, there are just too many options. However there are some things that I can give you pointers on.
- Always know if your source file is interlaced or not. If you don’t know how to tell, just play your DVD in a computer (must be a computer) and you will see if there are jagged lines in the image or not. If you can’t see any or aren’t sure, you will have progressive.
- If you do have interlaced, you need to say that you DON”T want to preserve interlacing as nothing can play it otherwise. Use the Yadif and MCDEINT deinterlacer for best quality.
- Always use 2 pass, don’t bother with 1 pass or 3 pass
- Always always choose to crop, it’ll save encoding time and it’ll look cleaner when you play it later
- Always export chapters (especially with a music DVD as you will be able to skip songs)
- If you have a slower processor, you can use vhq instead of ehq, you probably won’t notice the difference.
- If you change the name of the output file, you must put .avi on the end
- When you get to the audio section choose COPY. Don’t bother with the others, they’re a waste of time unless you’re encoding for a PSP or something.
To execute the script to start your encode:
$ h264enc -2p -p ehq
Have a play, and feel free to post comments / questions. Did I mention that these can be hardware accelerated by NVIDIA GPU’s using CUDA / VDPAU? My CPU only uses about 1% playing 24GB 1080p files on an 8600GT card. It’s sweet! :)