I thought I’d take the opportunity to share a Bash script I made to automate ripping music off CUE/BIN files. It splits BINs into separate files, so it’s 1 file per track, and strips pregap data, encodes audio tracks to FLAC or Ogg Vorbis, and it also generates new CUE sheets.

Link to the script:

https://github.com/linux4ever07/scripts/blob/main/cuebin_extract.sh

The idea came to me some years ago when I noticed that GOG packaged some of their games in a dumb way. It was specifically DOS games (bundled with DOSBox) that had CD audio. They would include the original BIN file, but with a modified CUE sheet that would not let you access the high quality CD audio. On top of that, they included Ogg Vorbis tracks, wasting HDD space for no reason by effectively storing the music twice, but only letting you access the lower quality Vorbis tracks. So, I thought, why not just split the BIN, encode the audio tracks to FLAC, and that way you both get better audio quality and also use less HDD space. DOSBox supports CUE sheets that list FLAC, Ogg Vorbis and even Opus tracks.

I took inspiration from ‘bchunk’, which is a program that does something similar. However, bchunk converts data tracks to ISO files, which is not what I wanted. I wanted to keep the original tracks completely untouched, so my script will copy data tracks as normal BIN files. bchunk also can’t encode audio tracks to FLAC or Ogg Vorbis, but it will produce uncompressed WAV files. And bchunk doesn’t produce new CUE sheets for the created files.

I also use the script to extract the OST from random games. I put together a playlist with some of my favorite retro video game music that I extracted using the script:

https://www.youtube.com/watch?v=nHI7ghR6XX4

There’s other uses for the script, such as splitting BINs in general. For example, many BeOS / ZETA disc images contain boot floppies as the first track, and once you split the BIN you can access the boot floppy image. And you can create frankenstein disc images by exchanging tracks between different disc images.

The script is made for Linux, but should work on macOS / FreeBSD as well if you have a recent version of Bash installed, as well as ffmpeg, flac and oggenc.

1 point

Why not just use cdparanoia with the original CD?

permalink
report
reply
8 points

If you have the original disc, then yeah. The script is more meant for when you get CUE/BINs online, such as Redump disc images for example.

permalink
report
parent
reply
-20 points

Then then why not buy the CD?

permalink
report
parent
reply
-14 points

I ask because that repo says “The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.” and yet it exists only to abuse other people’s creative rights.

permalink
report
parent
reply
8 points

permalink
report
parent
reply
15 points

Many older games are not sold physically anymore, and getting them on the second hand market can be pretty expensive depending on how rare they are.

permalink
report
parent
reply
5 points

I am not sure this script will help. But I actually have a lot of cue/bin files from back when I ripped my cd collection. If I remember correctly, I played them through mediamonkey (ape files) or foobar. Windows user then… Most CD’s are either lost or in the back of the attic somewhere. I consider the files dead, but havent deleted them yet. I use plex which can’t play cue/bin files. This script might make my old cd collection come alive again…

permalink
report
parent
reply
6 points

Let’s say the OP was given the CUE rip by his friend

permalink
report
parent
reply
4 points
*

I just checked the macOS / FreeBSD man page for ‘stat’, and noticed the syntax differs from the version in GNU coreutils (which is what’s used in Linux). That’s probably the only thing that would need to be changed to make the script work on those other systems. It’s on line 526.

permalink
report
reply
1 point

Well pretty much no one is using BSD

permalink
report
parent
reply
2 points

Fair enough. But macOS has more users than Linux, and is partly based on FreeBSD. The shell and the userland tools are from FreeBSD. I prefer Linux of course and haven’t used a Mac in years, but I still think it’s nice making scripts compatible with all *nix systems.

permalink
report
parent
reply
2 points

Fair enough, I just don’t pester the developer if you can avoid it. (Foss devs often receive demands)

permalink
report
parent
reply
4 points

Looks good! Thanks for sharing!

permalink
report
reply
2 points

Thank you! I’m happy if more people besides just myself have use for it. It’s a niche some people might not be aware of. Especially for younger people who aren’t familiar with the CD format, and how music is stored in those games. It might help people get more direct access to the OST of their favorite retro games. Instead of having to search around the web for high quality audio, they can just extract it themselves.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 8.5K

    Monthly active users

  • 6.3K

    Posts

  • 174K

    Comments