November 18, 2004

Linux CD/DVD Recording

Author: Preston St. Pierre

This is an introduction to using CD and DVD recorders under Linux and
UNIX systems. Its main focus is on command line based tools. It will give you
an idea how the powerful tools and utilities behind the fancy GUIs
work and what they can do for you. Recording CDs and DVDs from the
command line can be useful in many situations, for example if you access
to the host only via the network; if your host does not have X11
available; or perhaps your favorite GUI won't start for some reason.
Another reason for using the command line based tools is that they can be
used in scripts to automate repetitive tasks such as backups.

Note on + and - medias

Today most DVD recorders support both DVD-R(W) and DVD+R(W) medias,
and even though this guide refers to DVD-R(W) discs the same instructions
could just as well be used with DVD+R discs.

Software

To create images and record them onto a CD/DVD, we need to have some programs
available on our system. All programs used in this guide are open source, released
under licenses that make them free to download and use. Please make
sure that you have all of these programs installed and working before
you continue reading this guide.

Note:
Many Linux distributions have many or even all or these programs installed
in the default installation, so make sure that you don't have them
installed already before spending time downloading and compiling the
packages listed below.

DVD+RW-Tools

This is a package containing tools used when working with DVDs and images.
In this guide, we will focus on the growisofs-application
provided with this package. However, it does also provide a utility
that erases DVD-RW discs (dvd+rw-format)
that we will use for this purpose.

CDRDAO

CDRDAO is a CD recording software that works in Disk-At-Once mode (DAO). By
recording in DAO-mode, the software has full control over the layout
of the disc and its tracks, a function which is required in many situations.

Cdrtools

The Cdrtools-package contains a set of utilities that can be used when
working with CDs. Growisofs will use the mkisofs-tool
from this package when creating its images, and we will use readcd
to make ISO images from existing DVDs. Also, the cdrecord
application can be used to scan for CD/DVD recorders connected to
your system, and we will use it to record ISO images to CD-R(W)
discs.

GNU VCDImager

The VCDImager is a full-featured toolkit for working with (Super)Video
CDs (VCD and SVCD). It supports most common features needed for
working with (S)VCDs, and allows for some quite advanced mastering as
well. In this guide, we use it to convert MPEG-streams into (S)VCD
images that can be recorded and viewed on VCD and DVD players that
support these formats.

Locating CD/DVD Recorder

To use your CD/DVD recorder under Linux, you will need to find the device
to use when accessing your recorder. (This will be either a system-path
or a bus-id, depending on your system.)

The two programs (cdrdao and growisofs) used in this
guide have different ways of addressing the recorders, and below is a short
description on how to find the device for your particular system.

To install and detect your recorder is not in the scope of this guide,
therefore, only a short description on how to detect it will be provided.

Device for CDRDAO

We provide cdrdao with an option that specifies which device it
should use when performing the requested actions. (recording, reading etc)
This is done with the --device argument. Depending on your system
and setup, you will need to address the recorder in different ways.
The format for the --device argument is: [prot:]bus,id,lun

However, on some systems, the device might be addressed using a device in /dev, for
example /dev/sg0. Other examples that follow the format above
might be 0,2,0, ATAPI:0,1,0 or ATA:0,1,0.

To find out how to address your recorder, cdrdao offers a
scanbus argument, that will try to find all available recorders and
CD players connected to your system, and display them along with
their bus id. To scan for devices, simply execute
cdrdao scanbus.

If cdrdao is unable to find your recorder, you could also try scanning
with cdrecord (which is a port of the cdrtools-package), using
cdrecord --scanbus.

Example:

From the example below, we see that our recorder should be addressed as
ATA:1,0,0.

root@linux:~#cdrdao scanbus
Cdrdao version 1.1.9 - (C) Andreas Mueller <andreas@daneb.de>
SCSI interface library - (C) Joerg Schilling
Paranoia DAE library - (C) Monty

Check

http://cdrdao.sourceforge.net/drives.html#dt
for current driver tables.

Using libscg version 'schily-0.8'


ATA:1,0,0            
_NEC    ,DVD_RW ND-3500AG, 2.1
root@linux:~#

Note:
In our examples, we will use device ATAPI:0,1,0, which you should replace
with the identifier for your recorder.

Device for growisofs

Growisofs has a different way of addressing it's recording-device. It
uses a UNIX-path to a device under /dev that is connected to the recorder.
For more information on how to locate the path to use for your
recorder, please see the setup-notes for DVD-recorders/readers for
your particular system and distribution.

Note:
On some systems, a softlink named /dev/dvd will be set up at
installation to point to your DVD-reader/writer if available, so this
could be a good place to start.

Note:
In this guide, we will use /dev/dvd whenever a device needs to be
specified when recording DVDs. If this does not work on your system,
please replace it with the appropriate path for your system in all
examples related to DVD-recording.

Working with DVDs

Below are descriptions of how to do the more common tasks related
to recording of DVDs.

Recording a DVD image

To record an image to a DVD-R disc, we will use the growisofs
software. To do this, we run growisofs with a set of arguments
instructing it about our intentions. We execute growisofs with the
following syntax:

growisofs-dvd-compat -Z /dev/dvd=image

For more details about the options used here, please see the manpage.

Example:
The example below shows how to record the image 'mydvd.img' to a DVD-R(W)
disc.

root@linux:~# growisofs -dvd-compat -Z /dev/dvd=mydvd.img

Storing files on a DVD disc

DVDs can be used to store files in the same way as ordinary CDs, with
the major difference that DVDs can store quite a lot more data. DVDs
even use the same filesystem (ISO9660) with the same common extensions
(Joliet and Rock Ridge) as normal CDs.

Growisofs offers an easy way to store a set of directories and/or
files on a DVD. It uses mkisofs to create an image, and writes it
to the DVD recorder without needing to store a copy of the image on the
harddrive before recording it.

For example:

growisofs -dvd-compat -Z /dev/dvd -J -R /path/to/disc/root

creates an image of files located at /path/to/disc/root using
ISO9660 filesystem with Joliet (-J) and Rock Ridge (-R) extensions,
and record it to a DVD-R(W) media.

Master and record a DVD Video image

In some cases, you might have a Video DVD stored as a series of
normal files in your filesystem, perhaps from some DVD authoring
software, and want to write this to a disc for usage in your
DVD-player.

To do this, we yet again turn to growisofs for help, which
as usual provides an easy solution to our problem.

In the example below, the disc-root refers to a directory containing any, or both of
the AUDIO_TS/ and VIDEO_TS/ directories. The main difference
from writing an ISO image is the -dvd-video option, that instructs
growisofs that it should prepare the disc to be used as a DVD Video disc.

growisofs -Z /dev/dvd -dvd-video /path/to/disc/root

Below is a sample listing of what the filestructure of a Video DVD might
look like:


AUDIO_TS/
VIDEO_TS/
VIDEO_TS/VIDEO_TS.BUP
VIDEO_TS/VIDEO_TS.IFO
VIDEO_TS/VIDEO_TS.VOB
VIDEO_TS/VTS_01_0.BUP
VIDEO_TS/VTS_01_0.IFO
VIDEO_TS/VTS_01_0.VOB
VIDEO_TS/VTS_01_1.VOB
...

Blanking DVD-RW discs

Working with rewritable media is no different from working with ordinary
DVD-R media aside from the obvious fact that every now and then you may
want to erase the data on them and start over. From the DVD+RW-Tools
package we get the dvd+rw-format command that does this for us.
It has two modes that can be used when erasing discs, either quick
or full mode. In most cases, a quick erase is enough, and this will
only take a minute or two (depending on your recorder), compared to the
full-erase mode, that takes about the same time as writing a full-size to
the media. (Or even longer, depending on the recorder you are using)

To perform a quick format, issue the following command:

dvd+rw-format -blank /dev/dvd

And here is the syntax for erasing the entire disc:

dvd+rw-format -blank=full /dev/dvd

Making image from a DVD

Sometimes you might need to create an ISO image from an existing DVD disc.
To do this, we use the readcd-tool provided with cdrtools. Readcd can also be used to make images from normal CDs.

Syntax:

readcd dev=device f=image

The device is given in the same was as when using cdrdao.
For more options, please see the manpage for readcd.

This example will make an image named mydvd.raw from the disc inserted
into device addressed at ATAPI:0,1,0:

root@linux:~# readcd dev=ATAPI:0,1,0 f=mydvd.raw

Working with CDs

DVD recorders can be used to record data to normal CD-R(W) discs too,
not just DVDs. This part will cover the basics of recording files and
images to CD-R(W) discs.

Recording a bin/toc image to CD

Recording an image from a set of bin/toc files using cdrdao
is rather straight forward. Just issue cdrdao with the write
command, followed by the path to the .toc-file.

Syntax:

cdrdao write --device ATAPI:0,1,0 image.toc

There are also some common options that might be usefull in some situations:

--speed <speed>

Force a given write-speed.

--eject

CDRDAO will eject the CD after it's finished writing to it.


--overburn

Allows CDRDAO to do a so called 'overburn', where a bit more

data is stored on the disc than it's specified to handle.

Example:

root@linux:~# cdrdao write --device ATAPI:0,1,0 --speed 10 --eject --overburn image.toc

CDRDAO also handles the bin/cue combination, and these images can be
recorded in the same way as bin/toc images. Just replace the
“.toc”-files with “.cue”-files in the
examples above.

Recording ISO image to CD

The cdrtools-package contains the cdrecord
that can be used to record ISO images to CD-R(W)'s.

For example:

cdrecord -v dev=device image

The device used by cdrecord is the same one used with cdrdao.

This example will record the ISO image named mycd.iso to the disc in the
recorder located at ATAPI:0,1,0:

root@linux:~# cdrecord -v dev=ATAPI:0,1,0 mycd.iso

Making ISO images from CDs

The creation of ISO-images from CDs is done in the same way as for DVDs,
using the readcd.

Syntax:

readcd dev=device f=image

This example will make an image named mycd.raw from the disc inserted into
device addressed at ATAPI:0,1,0:

root@linux:~# readcd dev=ATAPI:0,1,0 f=mycd.raw

Making a bin/toc image from a CD

To create a set of bin/toc files representing the content of a CD, you
would use the read-cd option for cdrdao, using the following syntax:

cdrdao read-cd --read-raw --datafile image.bin --device ATAPI:0,1,0 --driver generic-mmc-raw image.toc

To create an image from a CD does not really require a CD recorder. Just about any CD reader can be used to do this.

Creating ISO images

Mkisofs from cdrtools can pre-master ISO images so they can be written
to CDs at a later time. Mkisofs has a large set of options available,
but we will only use the most common ones to create a normal image. For more
details on the accepted options, please see the manpage.

Syntax:

mkisofs -o image.iso -J -r /path/to/data/

This will create an image with an ISO9660 filesystem, using
Joliet (-J) and Rock Ridge (-r) extensions.

The following will create an image named mycd.iso, containing everything under /a/data/.

root@linux:~# mkisofs -o mycd.iso -J -r /a/data/

Erasing a CD-RW disc

Erasing a CD-RW disc with CDRDAO is pretty straight forward, all needed
is to issue it's 'blank' option, followed by information on what drive to
erase the media in, using the --device option.

Sometimes CDRDAO will be unable to blank your media at the drivers default
speed, if this is the case, you can force it to use a lower speed
with the --speed option. (Example: --speed 10) This problem is
related to the media (discs) and not the recorder or cdrdao.

Example:

root@linux:~# cdrdao blank --device ATAPI:0,1,0

CCD and NRG images

You may run into .nrg- or .ccd images that you wish to write to a CD.
This can be quite tricky in the Linux/Unix-world, since none of the programs
available today have support for this. Currently, the only way to do
this is to convert them to ISO images first. To do this, there are
two small utilities available, nrg2iso and ccd2iso.

Although these two tools do their best to convert NRG and CCD images to ISOs,
there is no guarantee that the resulting images will be fully usable
since the ISO-image format does not support all the features used by
NRG and CCD images.

NRG2ISO

Nrg2iso will convert Nero image files to ISO files. If it is not provided
with your installation, it can be downloaded from:

Usage:nrg2iso image.nrg image.iso

CCD2ISO

CloneCD images can be converted into ISO's with ccd2iso, that can be
downloaded from:

Usage:ccd2iso [.img filename] [.iso filename]

Converting video-files to (S)VCD

Sometimes you might have a set of MPEG streams from which you would like to
create a (Super) VideoCD (SVCD or VCD) to be recorded with CDRDAO and used in
your VCD/DVD-player. To do this, we will use the GNU VCDImager software.

Use the following syntax for VCDImager to create a set of bin/cue-files
from an MPEG stream. Replace “type” with the appropriate
type for the output image, based on the type MPEG-stream you are
recording. The more common types are 'vcd' for mpeg1-streams,
and 'svcd' for mpeg2-streams. VCDImager will notify you
if it believes that you have selected the wrong type for the given
stream.

Syntax:vcdimager -t type --update-scan-offsets video.mpg

The following example will create a bin/cue-image in SuperVCD format, containing
the stream found in myshow.mpg. (That in this case is an MPEG2
stream)

root@linux:~# vcdimager -t svcd --update-scan-offset myshow.mpg

The MPEG streams needs to be in somewhat appropriate formats to be used
as (S)VCDs, but this is beyond the scope of this guide. There is more
information about this on VCDImager's website. (See the “Software”
section)

Graphical User Interfaces (GUIs)

Over the years, more and more graphical frontends for various terminal-based
CD/DVD recording programs have appeared. Many of these provides great
features and really make things easier when performing basic tasks.
Here we will mention a few of the best-known GUIs for CD and DVD
recording, along with links to more information about them.

X-CD-Roast

This is one of the oldest programs in this category. It has been around
for quite some time now, and offers a good set of functions without
being hard or complex to use. X-CD-Roast is a frontend for the tools
found in the cdrtools-package.

K3B (CD/DVD Kreator for KDE)

K3B is a nice-looking CD and DVD creator for Linux based on KDE. It provides
an interface that is easy to use and to get started with. It also
provides ways for power-users to perform advanced tasks.

Gnome CD Master (GCDMASTER)

This frontend for cdrdao uses Gnome to provide a good-looking and
easy-to-use interface that provides the basic functions needed to do most
of the common tasks of cdrdao.

Gnome Toaster

Gnome Toaster is a CD creation suite for Linux, with the aim to be as
user-friendly as possible, and allowing the user to master and record
an image with just a few mouse-clicks.

DVDStyler

This is a cross-platform frontend for dvdauthor and growisofs
Used to master and record DVDs in this guide).

Nautilus-CD-Burner (Extension)

Nautilus is the official filemanager for the Gnome desktop, and this extension
adds features to easily master and record CD/DVDs direcly from the
filemanager.

Click Here!