Windows System Administration

The Ultimate Guide to DVD Encoding with Handbrake

handbrake-head

It’s no secret that I’m a huge fan of Handbrake. After committing to copying my DVD collection to my storage array, I’ve tried and tested just about all software out there for converting video to H.264 with an emphasis on quality and speed. Many software packages have problems with quality or desynchronized audio, Handbrake is my hands-down favorite when it comes down to converting video — and that includes both free and commercial software.

One of the complaints I hear about Handbrake is that there are too many options. Well, the good news for someone looking for simplicity is that the built-in presets mostly take care of them for you. And for anyone who likes to dive into the nitty gritty of video compression, it also allows for a lot of tweaking to get the most out of your movie while maintaining small file sizes and high quality.

This guide was done on the Windows version but the other versions are all very similar. Also it assumes that there is no copy protection on the disc. If you have copy protection and it is legal in your country to remove it, you can use DVD43 (free), AnyDVD (paid), or other software to do so. If you have a particular question regarding Handbrake, be sure to ask in the comments below and I will get back to you as soon as possible. Thanks to the developers of Handbrake for the great piece of software they have put together! Many of the answers I am supplying below are available via the Handbrake wiki, which is also where you should go if you are looking for more detailed information on a particular item. On to the list!

The Main Menu

You will mainly use 2 buttons here – Source and Start. Source lets you select the DVD you wish to rip from, which is either the disc directly, or the “video_ts” folder if it is stored on your drive. Start begins the encoding process. If you want to run more than one at once, you would Start the first one, then “Add to Queue” to add it to the list of encodings it will do next. The Show Queue button allows you to reorganize or delete upcoming encodings.

Source Information

This area shows you information about your current disc. It will automatically select the largest title and most movies have only one angle. If you only want to encode a certain chapter or section of the disc, this is where you would select it.

Output File

Select where you would like to send the file when done, easy enough!

Output Settings

Container: MP4 or MKV. This depends on where you want to play the file – MP4 is usually more compatible but MKV can have more flexibility.
Large File Size: This mainly seems to be depreciated but you used to have problems playing files larger than 4GB on some devices if this is not checked.
Web Optimized: Assists with streaming via web – if you do not plan on hosting the video online it is safe to keep this off.
iPod 5G support: Only useful if you plan on playing video on a 5th Generation iPod.

Presets

Presets are the easiest way to get encoding fast. The Regular->Normal setting seems to work best both on my local PC and my HTPC. For movies with a lot of special effects where I am looking for higher quality (sacrificing longer encoding times and more hard drive usage) I will move to High Profile. If you are planning on making the movie portable, select the device which closest matches the one you have. It should shrink it down to whatever size you need.

You can also save new presets. If you like to encode a movie a certain way or for a certain device, feel free to change the settings and then ‘Add’ a new profile.

Picture

Source: Resolution of the original video.
Aspect ratio: Whether the original should be “stretched” and how much.
Anamorphic: How much the original should retain its resultion. I keep this on “Strict” most of the time. If you move it to different settings, you may need to specify the resolution, but in general it is best to keep the resolution the same.
Cropping: Best left to automatic – will remove any black bars on the top, bottom or sides of the video. If you find it missed the, select custom and then how much you want to chop off.

Video Filters

Detelecine: This has to do with how the video is interlaced when framerates are changed around. See Handbrake’s wiki for a technical explanation.
Decomb: Similar to Detelecine, this looks at every pixel. While having better results, it will slow down your encode. See more details.
Deinterlace: Deinterlaces every frame an can result in some loss of quality to the video. Removes the lines you sometimes see when anything is moving quickly across the screen.
Denoise: This will filter out noise and film grain from the video.
Deblock: This will remove blocky video due to compression or low quality.
Grayscale Encoding: Your movie will be in black & white.

Generally speaking I leave these options off as they slow down video and also alter the video from what is on the DVD. If you want to keep original quality, keep them off, otherwise feel free to customize to your needs. There is a great Handbrake wiki settings page which explain them further in technical detail.

Video

Video codec: H.264 or MPEG-4 via ffmpeg. In most situations H.264 is superior as the video codec.
Framerate: Highly recommend keeping this same as source. Otherwise your audio and video might get desynchronized.
Quality: I usually go for Constant quality anywhere from 60 to 75. Target size is good if you are trying to fit it on a CD or DVD, and Avg Bitrate is used on some older devices.

Audio

If you want to encode the video only with English then it is usually OK to leave this area alone. You can add other audio tracks to your movie by clicking “Add track” and then selecting the source. Mixdown if you don’t expect to play the movie on a full-speaker system, but keep the bitrate at 160 or more. DRC stands for Dynamic Range Compression – setting this higher will help reduce the differences between the soft and loud moments in the movie.

Subtitles

MakeUseOf covered Subtitles on Handbrake last year, you can review it on that article.

Chapters

Some software will allow you to fast forward or rewind based on the chapters in the file. Handbrake will automatically convert your DVD chapters into the file, tweak them here as needed.

Advanced

Handbrake allows you to change all sorts of settings within the h.264 encoder. These are for advanced users, but below is a summary of the settings just in case you find a need to tweak them for a movie you are encoding.

Reference Frames B-Frames
Adaptive B-Frames Direct Prediction
Weighted B-Frames Pyramidal B-Frames
Motion Estimation Method Subpixel Motion Estimation
Analysis 8×8 DCT
CABAC Entropy Coding No Fast-P-Skip
No DCT-Decimate Deblocking

Instead of rehashing what is already over on the Handbrake wiki article H.264 options, you can just head over there for the gory details. These are tweaks which control how the video is compressed. The only reason to change them is if you are trying to encode a video and are not getting the quality or compression results you are expecting.

Get Encoding!

Hopefully this guide will help you to understand Handbrake and all that it is capable of. This is one of the most important tools in the savvy media connoisseur’s toolbox, and I hope you have found it as useful as I have. Let us know if you have any questions in the comments area below.

Canon CanoScan LiDE 50 Scanner and Windows 7 (32 or 64-bit) Driver Fix

Canon’s site for the LiDE 50 does not list any Windows 7 drivers for download, nor Vista 64-bit drivers. However, I did find that you can use the CanoScan LiDE 60 drivers in place of the LiDE 50 drivers, and they do have options listed for Windows 7/Vista in both 64-bit and 32-bit varieties. 

Do do this, you download the appropriate driver (either the Windows 7 64 or 32 drivers) which is contained in an executable file. Use a program such as 7zip to uncompress this file into another folder. Within this folder, there are no drivers but further cabinet files. Use 7zip to decompress the _winzip_ file, which actually contains the driver you need to install.

In your device manager, locate the scanner and select the option to update the driver. You will need to select the driver manually, then specify the device type and driver, then click the “Have Disk” option. Locate the folder where the driver is located and select the .inf, and it will successfully (hopefully) install the LiDE50 as a LiDE60 scanner.

After having the device installed properly, download the latest CanoScan Toolbox, of the date of this writing it is version 4.9.3.2. This will give you access to all of the options you should have to set the buttons on your scanner, for example.

No need to buy a new scanner just because Canon didn’t develop a driver for the LiDE 50, apparently the chipset for the 60 is almost exactly the same.

What I recently learned about EDID, Windows 7 and nVidia

20100111_230155__86379

EDID stands for Extended display identification data and is what many computer monitors and televisions with a VGA/HDMI use to tell the PC what resolution they support. Which, in theory at least, is great.

However what I recently found out is that many LCD and Plasma televisions do not broadcast the correct 16:9 resolution via EDID, and therefore the computer doesn’t know what resolution to display and you have a stretched image. Read more

How To Reset Windows XP, Vista, Windows 7 Passwords with Ubuntu 9.10 Live Image and a USB Drive

I put this together for a project in a class I am taking, and thought it would be handy for others as well. The goal is to access a Windows filesystem and reset the password for a user, for example if someone forgot the Administrator password or the account is locked out from too many bad password login attempts. This works on all modern Windows Operating Systems: Windows 2000, 2003, XP, Vista, Win7 etc. Make sure to create a backup if you want to make sure you don’t corrupt your Windows install, as it can happen.

Tools used:

Accessing the Filesystem

First we use unetbootin to install Ubuntu 9.10 to a flash drive. The flash drive needs to be at least 1GB to install the image.

Unetbootin settings

Select “Diskimage” and then the .iso file we downloaded of the Ubuntu 9.10 image.

Select the USB Drive and Drive Letter to install the ISO onto. Click OK:

Unetbootin doing its thing

Once the program is done, click ‘exit’ and remove the USB Drive. You now have a bootable live image of Ubuntu 9.10.

Plug the usb drive into the target system. Boot off of the drive, you may need to change the boot options in the BIOS if it is set to boot off of the hard drive. Select “Default” in the unetbootin boot menu to boot into the Ubuntu OS. It will automatically log you in.

Once booted you already have access to the Windows filesystem since the ntfs filesystem driver is included in the kernel. This is nice and wasn’t the case not too long ago.

We chose two reasons to use unetbootin and Ubuntu 9.10. The first is the ease of use of installing a bootable image. After downloading the two packages, it is trivial to load the OS onto the drive, and since it includes ntfs drivers it allows us to access the unencrypted hard drive on boot. Since it is on a USB drive, any system made since 2000 or so should be able to boot this. You don’t need to lug around a CD or even access the CD drive.

To prevent easy access to the hard drive, encryption of the hard drive partition would be necessary using Microsoft EFS or TrueCrypt hard drive encryption software. After encrypting the hard drive, any live operating system running would not be able to decrypt the hard drive easily.

Furthermore, installation of a BIOS level password would ensure that any unauthorized users would not be able to boot alternative operating systems via USB, CDROM, Floppy or other method. The only way to defeat a BIOS level password would be to reset the BIOS (requiring entrance into the hardware of the system) or using an Evil Maid style attack.

The Evil Maid attack is performed by a theoretical malicious party that has access to the target PC without alerting the legitimate user. Without knowledge of the authorized; a root kit or device would be installed (for example, on the USB connector of the keyboard) to sniff out the password as entered on bootup. After the user boots the system and finishes her work, ostensibly shutting down the system securely, at least to her knowledge, the Evil Maid would then collect the password entered into the BIOS, thereby defeating the BIOS password security measure.

Resetting the Password

We can now reset the Administrator or any other password on this system using the tool chntpw. To install this package, ensure the system has a connection to the internet (via dhcp perhaps?) and run the command:

sudo software-properties-gtk --enable-component=universe --enable-component=multiverse; sudo apt-get update; sudo apt-get install chntpw

Alternatively, you can download the executable and place it on the USB drive to give access without connecting to the internet. chntpw is the software that modifies the SAM (Security Accounts Manager) database file. Use the terminal to change directories to the password file

cd /media/path/to/disk/WINDOWS/system32/config/

Then execute the chntpw utility:

  # sudo chntpw -u username SAM SYSTEM

View the sample output:

ubuntu@ubuntu:/media/B830C9BC30C981BC/WINDOWS/system32/config$ sudo chntpw SAM SECURITY
chntpw version 0.99.5 070923 (decade), (c) Petter N Hagen
Hive <SAM> name (from header): <\SystemRoot\System32\Config\SAM>
ROOT KEY at offset: 0x001020 * Subkey indexing type is: 666c <lf>
Page at 0x7000 is not 'hbin', assuming file contains garbage at end
File size 262144 [40000] bytes, containing 6 pages (+ 1 headerpage)
Used for data: 255/20736 blocks/bytes, unused: 9/3648 blocks/bytes.

Hive <SECURITY> name (from header): <emRoot\System32\Config\SECURITY>
ROOT KEY at offset: 0x001020 * Subkey indexing type is: 666c <lf>
Page at 0xe000 is not 'hbin', assuming file contains garbage at end
File size 262144 [40000] bytes, containing 13 pages (+ 1 headerpage)
Used for data: 1074/49024 blocks/bytes, unused: 9/3808 blocks/bytes.

* SAM policy limits:
Failed logins before lockout is: 0
Minimum password length        : 0
Password history count         : 0
| RID -|---------- Username ------------| Admin? |- Lock? --|
| 01f4 | Administrator                  | ADMIN  | dis/lock |
| 03ec | ASPNET                         |        | dis/lock |
| 03ed | CSC603                         | ADMIN  | dis/lock |
| 01f5 | Guest                          |        | dis/lock |
| 03e8 | HelpAssistant                  |        | dis/lock |

---------------------> SYSKEY CHECK <-----------------------
SYSTEM   SecureBoot            : -1 -> Not Set (not installed, good!)
SAM      Account\F             : 1 -> key-in-registry
SECURITY PolSecretEncryptionKey: 1 -> key-in-registry

***************** SYSKEY IS ENABLED! **************
This installation very likely has the syskey passwordhash-obfuscator installed
It's currently in mode = -1, Unknown-mode
SYSKEY is on! However, DO NOT DISABLE IT UNLESS YOU HAVE TO!
This program can change passwords even if syskey is on, however
if you have lost the key-floppy or passphrase you can turn it off,
but please read the docs first!!!

** IF YOU DON'T KNOW WHAT SYSKEY IS YOU DO NOT NEED TO SWITCH IT OFF!**
NOTE: On WINDOWS 2000 it will not be possible
to turn it on again! (and other problems may also show..)

NOTE: Disabling syskey will invalidate ALL
passwords, requiring them to be reset. You should at least reset the
administrator password using this program, then the rest ought to be
done from NT.

Do you really wish to disable SYSKEY? (y/n) [n]
RID     : 0500 [01f4]
Username: Administrator
fullname:
comment : Built-in account for administering the computer/domain
homedir : 

User is member of 1 groups:
00000220 = Administrators (which has 2 members)

Account bits: 0x0210 =
[ ] Disabled        | [ ] Homedir req.    | [ ] Passwd not req. |
[ ] Temp. duplicate | [X] Normal account  | [ ] NMS account     |
[ ] Domain trust ac | [ ] Wks trust act.  | [ ] Srv trust act   |
[X] Pwd don't expir | [ ] Auto lockout    | [ ] (unknown 0x08)  |
[ ] (unknown 0x10)  | [ ] (unknown 0x20)  | [ ] (unknown 0x40)  | 

Failed login count: 1, while max tries is: 0
Total  login count: 1

- - - - User Edit Menu:
 1 - Clear (blank) user password
 2 - Edit (set new) user password (careful with this on XP or Vista)
 3 - Promote user (make user an administrator)
 4 - Unlock and enable user account [probably locked now]
 q - Quit editing user, back to user select
Select: [q] >

Depending on the status of the SYSKEY password security, you may only be able to blank the password and not actually change it. I recommend blanking the password and then resetting it once you log into the system.

You can also unlock a system if the user accounts have all been locked out due to too many login attempts or any other reason. Using these tools you can gain access to almost any unencrypted Windows system, from Windows NT up to Windows 7.

As a warning, If there is data on the hard drive you wish to keep, make sure to make a backup of the hard drive before performing this password as it can corrupt the Windows installation.

Convert Windows or DOS Encoded Files to Unix/Linux. (ANSI to UTF-8)

Windows files and Unix files (Redhat, Ubuntu, etc) are encoded in different ways. Namely, the end of line that is a part of most files created in Windows is not compatible with Unix. You can usually see this because there is a ‘weird character’ at the end of each line. ‘cat’ does not show it, but ‘cat -e’ will show these characters:

xx.xx.125.240 spc240.xx.xx^M$
xx.xx.125.241 spc241.xx.xx^M$

The ^M is a Windows ‘End of Line’ character.

Fortunately there is an easy way to fix these for using them in a unix based system.

Install ‘dos2unix’, and then run the file through them:

dos2unix filename

You can even run these on a bunch of files:

[root@ns1 ~]# dos2unix RDNS-*
dos2unix: converting file RDNS-xx.xx.81 to UNIX format …
dos2unix: converting file RDNS-xx.xx.82 to UNIX format …
dos2unix: converting file RDNS-xx.xx.85 to UNIX format …
dos2unix: converting file RDNS-xx.xx.95 to UNIX format …
dos2unix: converting file RDNS-xx.xx.100 to UNIX format …

‘cat -e’ will show that these files are fixed.

You can also use the program ‘recode’.

Remote Desktop from Windows XP to Windows Server 2008 or Windows Vista

The Remote Desktop connection settings for Windows Server 2008, and I believe Windows Vista, includes 3 levels of service:

  • Don’t allow connections to this computer
  • Allow connections from computers running any version of Remote Desktop (less secure)
  • Allow connections only from computers running Remote Desktop with Network Level Authentication (more secure)

windows_server_2008_remote_desktop_properties

At first blush, you would probably choose the “more secure” option. Practically, this mainly means that it only allows connections from the latest Remote Desktop software in Windows Vista. It is probably another attempt by Microsoft to force consumers and businesses into upgrading to Windows Vista. But… I digress.

When connecting with an older Terminal Services (TS) client in XP or even Vista, you will get this message:

“Remote computer requires Network Level Authentication, which your computer doesn’t support”

the-remote-computer-requires-network-level-authentication11

Not all is lost. There are two ways around this. The first and most obvious solution is to select the less secure option and disabled Network Level Authentication (NLA). If you are in an environment that does not allow this change, or there are some other circumstances where you need to keep Network Level Authentication enabled, you can get a Remote Desktop connection from Windows XP.

The first step is to download the latest Remote Desktop Client for Windows XP. As of the writing of this article, the latest version is 6.1.

For XP SP3: here

For XP SP2: here

That is not it. For XP, you need to enable CredSSP – Credential Security Service Provider.

CredSSP is a new Security Service Provider (SSP) that is available in Windows XP SP3 by using the Security Service Provider Interface (SSPI). CredSSP enables a program to use client-side SSP to delegate user credentials from the client computer to the target server.

Directions on how do do this are available at Microsoft here:

http://support.microsoft.com/kb/951608/

The quick and dirty summary:

  1. Click Start, click Run, type regedit, and then press ENTER.
  2. In the navigation pane, locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  3. In the details pane, right-click Security Packages, and then click Modify.
  4. In the Value data box, type tspkg. Leave any data that is specific to other SSPs, and then click OK.
  5. In the navigation pane, locate and then click the following registry subkey:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders
  6. In the details pane, right-click SecurityProviders, and then click Modify.
  7. In the Value data box, type credssp.dll. Leave any data that is specific to other SSPs, and then click OK.
  8. Exit Registry Editor.
  9. Restart the computer.

For more information on CredSSP including how to deploy this setting using Group Policy, see the CredSSP page here.

Let me know if you have any other tips or a simpler way to connect to the more secure version of Remote Desktop.

Automatically Rip DVD using Handbrake and Autoplay (XP)

I am currently copying my DVD collection to my PC for use in my media center downstairs. I have an generic process down, that works very well, but it requires a bunch of clicks to do. While figuring out how to Autoplay a DVD using ZoomPlayer rather than the built in Windows Media Player, I thought, why not add a “Rip DVD with Handbrake” option.

This is actually pretty easy to do, so I thought I would share so that anyone looking to do a similar thing could easily set it up.

First thing, I am assuming you have Handbrake installed and running. Also, unless you are only copying non CSS protected DVDs, you will need a program such as DVD43 or AnyDVD which automatically decrypts the DVD on the fly.

After ensuring those work (and tested by copying a DVD via the GUI interface) then we can begin to set up your PC so that Autoplay can copy the disks.

To modify the AutoPlay options, you first need to install TweakUI from Microsoft. Run it and navigate to the Autoplay options.

Tweakui

Click “Create” and Fill out the name and program description. Click “Change Program” and select HandBrakeCLI, which is installed into C:\Program Files\Handbrake\ by default.

If you want, you can change the icon, use the Icon from Handbrake.exe (it looks prettier!).

In the Args: field, use:

-i "%L\VIDEO_TS" -o "D:\DVD\Movie_%RANDOM%.m4v" -L -p --preset="AppleTV"

These options mean:

  • -i: source
  • -o: output
  • -L: Select longest title
  • -p: Store pixel aspect ratio in video stream
  • –preset: Which preset to use (use HandBrakeCLI –preset-list  to get a valid list)

Don’t forget to check off “DVD”.

When done it should look like this:

Autoplay

When its done, you will get an autoplay option with the Description you set above. When clicking on it, you get your movie encoded straight up:

handbrakecli

Thats it! When you insert a DVD, you are automatically asked if you would like to play it, or in this case, rip it. Just a small note, this is only for XP, I don’t know if it works on Vista or not. Also, the file name is static, I haven’t figured out how to get it to read the title from the disk, although I’m working on it.

For a full list of HandbrakeCLI options, see: http://trac.handbrake.fr/wiki/CLIGuide

Also, with the -L option; it selects the longest title on the disk. This works great for movies, but if you are trying to copy TV episodes or something with a bunch of smaller titles, then you would have to do it the normal way.

Please let me know if you have success with this or if you’ve improved upon it in some way!