Skip to content

Latest commit

 

History

History
234 lines (170 loc) · 10.2 KB

readme.md

File metadata and controls

234 lines (170 loc) · 10.2 KB

What is it

CBAE (Cue Bin Audio Encoder) is a CLI tool that can encode the audio tracks of a CD image with the cue/bin format into OPUS, FLAC, VORBIS or MP3. The new CD Image can then be used in software that supports loading .cue files with encoded audio tracks (mostly emulators like DosBox).

Updated 2023-09 -- Check the CHANGELOG

Features

  • Supports merged .bin files, it can extract the audio from those
  • Generates new .cue files with correct parameters
  • Fast encoding, tracks are encoded in parallel
  • Display the SHA-1 hash of tracks (useful for single file .bin files)

Example

CBAE running

Take the original release of "Quake (1996)", a single CD Image, including ten (10) CD-DA Tracks. Here is a size comparison between the raw image and encoded audio .cue/.bin images.

Audio Audio Tracks Data Tracks Total Size
CD-DA 595MB 28MB 623MB
FLAC 255MB 28MB 283MB
OPUS 64Kbps 26MB 28MB 55MB

The OPUS codec produces very nice audio quality even at low bitrates. The encoded Quake CD got a reduction down to 9% of the original raw CD size.

Installing 🚚

CBAE is a nodejs script. It is a single file and has no external dependencies other than FFmpeg. You can download the script from here or from npm.

# Download and install globally
npm i cbae --location=global
# Run
cbae
  • From github (if you don't want to use npm)
# Clone the git to a dir of your choice
git clone https://github.com/john32b/cbae --depth 1
# Run
node cbae/bin
  • OR For Windows, download the Executable that does not require NodeJS

In Short, you need:

  • NodeJS, version 18+
  • FFmpeg, set on your PATH (So it can run from anywhere by calling ffmpeg)
  • Some basic command line knowledge is a plus

✏️ TIP: For Windows the easiest way to get FFmpeg on path, is to copy ffmpeg.exe in your Windows dir (usually C:\Windows)

Running 💻

Quick Examples

# Encode all .cue cd images from H:\DOS\cdimages into b:\encoded\
# and convert audio tracks to FLAC
cbae H:/DOS/cdimages/*.cue -o b:/encoded -enc FLAC

# Encode TombRaider2.cue into the current working directory
# convert audio to Vorbis 128KBPS, using 12 parallel tasks
cbae TombRaider2.cue -o . -enc VORBIS:128 -p 12

# Print information for all cue files in current dir
cbae i *.cue

# Encode ONLY the audio tracks, output in the same dir as the
# input file, name the generated tracks as "game-01, game-02..."
cbae ~/game.cue -o =src -enc MP3:128 -only audio -tname "game-{no}"

For HELP and USAGE call cbae -help


INPUT

A valid .cue file, full path or relative path. Supports multiple inputs.

  • In Linux you can do file globbing, /home/janko/iso/**/*.cue
  • In Windows basic file globbing is supported, c:\games\cd\*.cue
  • For multiple inputs separate with space, game1.cue game2.cue ...

OUTPUT

A directory where the new folders will be created. Full or relative path.

  • Set with -o . e.g. cbae quake.cue -o /tmp/ ... -- Will create /tmp/quake [e]/
  • Newly created folders come with the postfix [e], for Encoded
  • If you give =src then the output folder will be created on the base directory of the input .cue file.

ACTION e : encode (default)

The main thing, takes .cue files and encodes the audio tracks to a codec of your choice* (more later). Generates a new .cue file and puts all the new files in a new folder under the declared output

  • This is the default action meaning, you can skip declaring it. e.g. cbae e input.cue ... is the same as cbae input.cue ...
  • Example : cbae ~/iso/TR3.cue -o =src -enc VORBIS:96 --> Will encode TR3.cue using Vorbis 96kbps and will put everything in ~/iso/TR3 [e]

ACTION i : info

With this you can view some information on a .cue/.bin cd image.
Filesizes and SHA-1 checksum.


OPTION -p <integer>

Sets the maximum number of concurrent encodes that can run. It gets a default value of 3/4 the threads of your system.

OPTION -enc <string>

Sets encoder and bitrate, given in a single parameter in the format codec:kbps. Check the list of supported tags.

  • e.g. cbae .... -enc OPUS:80 --> will use OPUS codec at 80KBPS
  • e.g. cbae .... -enc FLAC --> will use FLAC. Notice that it doesn't require the :KBPS part

OPTION -only (audio|data)

You can choose to work on either the audio or data tracks of the CD. This is useful when you want to extract the data track of a merged CD, where you would use -only data

OPTION -sh

Makes the generated track filenames in the form of trackXX.ext. This is useful in some cases, like the winmm CD Audio Emulator (DxWnd), which needs the tracks to be named like that.
e.g. (track01.bin, track02.ogg, track03.ogg ..... )

NOTE: Soon to be deprecated in favor of -tname

OPTION -tname <string> new

Customize the filename of the generated tracks with the use of a template string. Supported tags are:

tag whatis
{no} Track Number
{cdt} CD Title
{cda} CD Artist
{tt} Track Title
{ta} Track Artist

Examples :

  • string : "game {cdt} - Track {no}" --> filename : "game Quake 2 - Track 01"
  • string : "{no}-{ta}-{tt}" --> Filename : "01-Sasha-Magnetic North"

Notes:

  • If a .cue file has TITLE tags for each and every track, then the default naming will use them.
  • The Track Artist and CD Artist tags are actually the PERFORMER fields in the cue file

List of supported codecs

Codec ID Min Kbps Max Kbps
MP3 32 320
MP3V* 44 256
OPUS 28 500
VORBIS 64 500
FLAC - -
RAW - -

*: MP3 is constant bitrate, while MP3V is variable bitrate.

Notes:

  • The RAW encoder can be used to split a merged .bin file to individual raw tracks.
  • Press CTRL+C to exit the program at any time.
  • On multiple file input, if a file fails, cbae will continue to the next file in queue.
  • If a CD Image does not include any audio tracks then it will NOT be processed at all.

Realtime speed of converting two CDs with a bunch of audio tracks to FLAC

Flac Demo

Um, what does CBAE do exactly?

CBAE takes a .cue/.bin file combo, copies the data tracks as they are, and uses FFmpeg to encode the audio tracks into separate files. Finally it produces a new .cue file and puts everything into a new folder.

Visual Example a picture is worth a thousand words

A new .cue file is generated and it makes the tracks point to the new encoded audio files.

FILE "QUAKE 1 (1996) - Track 01.bin" BINARY
	TRACK 01 MODE1/2352
	INDEX 01 00:00:00
FILE "QUAKE 1 (1996) - Track 02.opus" OPUS
	TRACK 02 AUDIO
	INDEX 01 00:00:00
	...
	...
FILE "QUAKE 1 (1996) - Track 11.opus" OPUS
	TRACK 11 AUDIO
	INDEX 01 00:00:00

Software/Emulators that support .cue files with encoded audio files

  • DosBox-staging supports {Flac, Opus, Vorbis, Mp3, Wav}
  • DosBox-X supports {Flac, Opus, Vorbis, Mp3, Wav}
  • Mednafen supports : {Vorbis, Flac, Wav}
  • PCSX-Redux supports anything its linked ffmpeg dependency supports.
  • DxWnd uses an audio emulator for CDDA games, supports {Ogg}
  • I'm sure there are more, (help me expand this list?)

CHANGELOG 🧬

V1.2

  • Added option -tname, allows you to customize the Track Filenames using a simple templating system.
  • Cue Parser will read metadata Track Title and Track Artist from the cue file. Default track naming will use those fields if they exist.
  • Aborting an operation with ctrl+c will append an "aborted" string to the output dirname.

V1.1

  • Added option -sh, gives short names to created tracks (track01.bin, track02.opus, ... etc).
  • Creating partial encodes with the -only option, will now generate a .cue file.
  • Internal code refactor, JS code now uses ECMAscript modules.

v1.0

  • The information action (i) will also display the SHA-1 checksum of all the tracks
  • Can selectively work with audio/data tracks, using the -only option
  • RAW encoder, meaning the audio tracks will not be encoded, they will be copied

v0.9

  • First version

MORE ℹ️

What about CHD ?

CHD is an entirely different thing and from what I understand CHD can only include lossless audio plus not all programs/emulators support it.

Wait, what about CDCRUSH ?

This older project of mine CDCRUSH has the functionality to encode audio tracks of a CD. But cdcrush is kinda dead now. It tried to do many things at once, and its main feature to highly compress a cd image into cold storage is (I think) deprecated by other archivers that allow the archives to be mounted. Perhaps not in the same compression ratios as cdcrush offered, but nonetheless ready to be accessed. Things like squashFS and dwarFS among others, they provide very good compression ratios, so for me, it makes sense to keep CD images in a compressed format that are ready to be mounted and played.

Then why not update the cdcrush code? I don't like the code, some parts are messy and others bloated, so I thought it would be better to do fresh start using pure JS (cdcrush was written in Haxe) while only implementing the useful stuff, which is audio encode a CD. In other words cdcrush is deprecated.


Made by me, John32B under the ISC license (See license.txt)