# CD/DVD usage

## CD/DVD drives

Modern CD-ROM drives can attain very high head speeds, yet some CD-ROM drives are capable of running at reduced speeds. There are several reasons that might make you consider changing the speed of a CD-ROM drive:

- There have been reports of read errors at high speeds, especially with badly pressed CD-ROMs. Reducing the speed can prevent data loss under these circumstances.

- Many CD-ROM drives are annoyingly loud, a lower speed may reduce the noise.

### Linux

You can reduce the speed of IDE CD-ROM drives with `hdparm`, `setcd` or `cdctl`. It works like this:

    hdparm -E [speed] [cdrom device]

    setcd -x [speed] [cdrom device]

    cdctl -bS [speed]

If you are using SCSI emulation, you might have to apply the settings to the real IDE device, not the emulated SCSI device.

If you have root privileges the following command may also help:

    echo file_readahead:2000000 > /proc/ide/[cdrom device]/settings

This sets prefetched file reading to 2MB, which helps with scratched CD-ROMs. If you set it to too high, the drive will continuously spin up and down, and will dramatically decrease the performance. It is recommended that you also tune your CD-ROM drive with `hdparm`:

    hdparm -d1 -a8 -u1 [cdrom device]

This enables DMA access, read-ahead, and IRQ unmasking (read the `hdparm` man page for a detailed explanation).

Please refer to "`/proc/ide/[cdrom device]/settings`" for fine-tuning your CD-ROM.

SCSI drives do not have a uniform way of setting these parameters (Do you know one? Tell us!) There is a tool that works for Plextor SCSI drives.

### FreeBSD

speed:

    cdcontrol [-f device] speed [speed]

DMA:

    sysctl hw.ata.atapi_dma=1

## DVD playback

For the complete list of available options, please read the man page. The syntax to play a standard DVD is as follows:

    mplayer dvd://<track> [-dvd-device <device>]

Example:

    mplayer dvd://1 -dvd-device /dev/hdc

If you have compiled MPlayer with dvdnav support, the syntax is the same, except that you need to use dvdnav:// instead of dvd://.

The default DVD device is `/dev/dvd`. If your setup differs, make a symlink or specify the correct device on the command line with the `-dvd-device` option.

MPlayer uses libdvdread and libdvdcss for DVD playback and decryption. These two libraries are contained in the MPlayer source tree, you do not have to install them separately. You can also use system-wide versions of the two libraries, but this solution is not recommended, as it can result in bugs, library incompatibilities and slower speed.

In case of DVD decoding problems, try disabling supermount, or any other such facilities. Some RPC-2 drives may also require setting the region code.

DVD decryption

DVD decryption is done by libdvdcss. The method can be specified through the `DVDCSS_METHOD` environment variable, see the manual page for details.

### region code

DVD drives nowadays come with a nonsensical restriction labeled region code. This is a scheme to force DVD drives to only accept DVDs produced for one of the six different regions into which the world was partitioned. How a group of people can sit around a table, come up with such an idea and expect the world of the 21st century to bow to their will is beyond anyone's guess.

Drives that enforce region settings through software only are also known as RPC-1 drives, those that do it in hardware as RPC-2. RPC-2 drives allow changing the region code five times before it remains fixed. Under Linux you can use the regionset tool to set the region code of your DVD drive.

Thankfully, it is possible to convert RPC-2 drives into RPC-1 drives through a firmware upgrade. Feed the model number of your DVD drive into your favorite search engine or have a look at the forum and download sections of "The firmware page". While the usual caveats for firmware upgrades apply, experience with getting rid of region code enforcement is generally positive.

## VCD playback

For the complete list of available options, please read the man page. The Syntax for a standard Video CD (VCD) is as follows:

    mplayer vcd://<track> [-cdrom-device <device>]

Example:

    mplayer vcd://2 -cdrom-device /dev/hdc

The default VCD device is `/dev/cdrom`. If your setup differs, make a symlink or specify the correct device on the command line with the `-cdrom-device` option.

At least Plextor and some Toshiba SCSI CD-ROM drives have horrible performance reading VCDs. This is because the CDROMREADRAW ioctl is not fully implemented for these drives. If you have some knowledge of SCSI programming, please help us implement generic SCSI support for VCDs.

In the meantime you can extract data from VCDs with readvcd and play the resulting file with MPlayer.

VCD structure

A Video CD (VCD) is made up of CD-ROM XA sectors, i.e. CD-ROM mode 2 form 1 and 2 tracks:

- The first track is in mode 2 form 2 format which means it uses L2 error correction. The track contains an ISO-9660 filesystem with 2048 bytes/sector. This filesystem contains VCD metadata information, as well as still frames often used in menus. MPEG segments for menus can also be stored in this first track, but the MPEGs have to be broken up into a series of 150-sector chunks. The ISO-9660 filesystem may contain other files or programs that are not essential for VCD operation.

- The second and remaining tracks are generally raw 2324 bytes/sector MPEG (movie) tracks, containing one MPEG PS data packet per sector. These are in mode 2 form 1 format, so they store more data per sector at the loss of some error correction. It is also legal to have CD-DA tracks in a VCD after the first track as well. On some operating systems there is some trickery that goes on to make these non-ISO-9660 tracks appear in a filesystem. On other operating systems like GNU/Linux this is not the case (yet). Here the MPEG data cannot be mounted. As most movies are inside this kind of track, you should try `vcd://2` first.

- There exist VCD disks without the first track (single track and no filesystem at all). They are still playable, but cannot be mounted.

- The definition of the Video CD standard is called the Philips "White Book" and it is not generally available online as it must be purchased from Philips. More detailed information about Video CDs can be found in the vcdimager documentation.

About .DAT files

The ~600 MB file visible on the first track of the mounted VCD is not a real file! It is a so called ISO gateway, created to allow Windows to handle such tracks (Windows does not allow raw device access to applications at all). Under Linux you cannot copy or play such files (they contain garbage). Under Windows it is possible as its iso9660 driver emulates the raw reading of tracks in this file. To play a .DAT file you need the kernel driver which can be found in the Linux version of PowerDVD. It has a modified iso9660 filesystem (`vcdfs/isofs-2.4.X.o`) driver, which is able to emulate the raw tracks through this shadow .DAT file. If you mount the disc using their driver, you can copy and even play .DAT files with MPlayer. But it will not work with the standard iso9660 driver of the Linux kernel! Use `vcd://` instead. Alternatives for VCD copying are the new cdfs kernel driver (not part of the official kernel) that shows CD sessions as image files and cdrdao, a bit-by-bit CD grabbing/copying application.