||1 year ago|
|README.md||1 year ago|
|get-tracks.sh||1 year ago|
get-tracks.sh allows you to easily extract music tracks from a file with multiple songs, like a CD-in-a-file.
get-tracks.sh is a simple shell script based around
ffmpeg, using only POSIX tools.
It was tested on both OpenBSD and Linux (Ubuntu, Alpine).
Download a CD and the starting time of each track in a file, and you're good to go.
get-tracks.sh <audio-file> <time-file> # Example get-track.sh doom-eternal.opus doom-eternal.txt
audio-file can be in any format understood by
The time-file must have this format:
0:00 intro 2:20 First song 3:18 Awesome song
The behavior of the script can be changed by several environment variables.
SIMULATION [empty or not]
do not invoke ffmpeg
see the ffmpeg documentation for the output formats available
FFOPTS [any ffmpeg options] (default: '-c:a copy')
ffmpeg options, can be used to change audio quality
can be required to change in case input and output file formats differ
see the ffmpeg documentation for available parameters
NONUMBER [empty or 1]
do not write song numbers
SEPARATOR [separator] (default: ' - ')
separator between number and name
example with SEPARATOR='_': 01_intro.opus 02_blah.opus…
HEADERS [empty or 1]
print environment parameters (verbosity, simulation, etc.)
VERBOSITY [0-3] (default: 1)
0: no output except errors from ffmpeg
1: simple indications on the current track being extracted
2: print actual ffmpeg commands the script currently runs
Different input and output file formats
In case you want to change the file format, let's say from
opus, you need to override the default ffmpeg options provided by
This is done through the
FFOPTS environment variable, which needs to NOT be empty in order to replace the default
get-tracks.sh behavior (which is
ffmpeg performs re-encoding by itself.
FORMAT=opus FFOPTS=" " get-tracks.sh cd.flac cd.txt
Warning: sometimes you don't even need to
You may encounter files in some format like
webm and you want to convert the output files in
But, inside the
webm format, you may have
In these cases, no re-encoding is necessary, and you can do something like:
FORMAT=opus get-tracks.sh cd.webm cd.txt
You'll have a warning mentionning FFOPTS (based on different formats).
But the generated audio files won't have any quality loss.
This happens sometimes with the
In case there are actual
ffmpeg errors, and you don't have output audio files, then the contained audio hadn't the right format.
You'll have to re-encode.
You can get some help by running
get-track.sh without arguments.