4 Home
Matteo Cypriani edited this page 2018-05-05 23:52:13 +02:00


About the NRG image format

A good reference about the metadata format is the corresponding Wikipedia article: https://en.wikipedia.org/wiki/NRG_(file_format).

The source code and comments of NRGrip also provide some information, of course.

Audio data

Wikipedia again: https://en.wikipedia.org/wiki/Compact_Disc_Digital_Audio

Cue sheet


Manual audio data extraction howto

Just for fun, it is possible to extract manually the audio data from an NRG image, after displaying its metadata with NRGrip. However, this will work only for standard 2352-byte sector size (no subchannel).

You will need to know:

  • The first audio byte (dd skip): daox.first_track.index1 (or index0 if you wish to include the pre-gap)

  • The last audio byte: daox.last_track.end_of_track

  • The number of audio bytes (dd count): Last audio byte - First audio byte

To extract the raw audio data (substitute ${FIRST_AUDIO_BYTE} and ${NB_AUDIO_BYTES} with the numbers found above:

dd iflag=count_bytes,skip_bytes if=image.nrg of=image.raw \
  bs=4M skip=${FIRST_AUDIO_BYTE} count=${NB_AUDIO_BYTES}

Notes on cue sheet extraction

From Wikipedia:

  • A CD can contain up to 99 tracks.
  • Each track can in turn have up to 100 indexes (0 to 99).
  • The vast majority of songs are recorded under index 1, with the pre-gap being index 0.
  • Sometimes hidden tracks are placed at the end of the last track of the disc, often using index 2 or 3.
  • In an NRG cue sheet, the index0 points are present even when they are identical to the index1 ones.
  • The index0 points in audio tracks are incorrect if Nero has been asked to record all the sub-channel data (in that case the sector size is 2448 bytes).
  • No index other than 0 or 1 has been encountered, although the chunk format allows for such cue points to be recorded; thus the number of cue blocks seems to always be 2 * (number of tracks + 1): two indices for each track, an index0 for the lead-in and an index1 for the lead-out.

From this information and other observations:

  • The cue sheet should include all the indices for each track, but index0 should be ignored if:
    • index0 = index1, or
    • index0's position is negative.
  • The lead-in area (track 0) and the lead-out area (track 0xAA) should not appear in the cue sheet.

How will multi-session CDs be handled? Is it worth implementing, since multi-session audio CDs must be very rare?