GithubHelp home page GithubHelp logo

reflac's Introduction

reflac

This is a script that allows you to recompress FLAC files while preserving their tags, intended for whole directories and for safety regardless of file name characters and encoding.

When storing FLACs on your big storage (desktop computer, NAS, etc), there may be a desire to compress them to the maximum extent possible, saving disk space and potentially many gigabytes for large collections. For this, you might use reflac --best on them.

However, slow and old systems might not have the capability to decode a maximally-compressed (or even the standard compression ratio) quick enough for real-time playback, and recompressing in a lower setting might be beneficial as well. This script started life, in a very rudimentary form for this purpose. The author used Rockbox on an old black/white display iPod, and found that flac -3 was the maximum he could compress FLACs while maintaining uninterrupted playback on the device.

Requirements

flac needs to be in your $PATH. This program is normally packaged as “flac” by distributions.

The script both depends on Bash and GNU features of other core utilities. Versions of mv, getopt, sync, etc from other sources (such as the *BSD operating systems) might work, but require compatibility with the same switches found in the GNU versions.

reflac has only been developed on tested on GNU+Linux, but should work on any other operating system with the appropriate tools.

Safety

By default, reflac performs a sync on files after two points of its process: after moving the recompressed file from the temporary directory to the original location, and after renaming the file from “*.new” to the original name. This should provide safety in the case of system crashes or processes being killed.

Assuming file system syncs have not been disabled, one of two scenarios should arise in the worst case:

  1. No new files appear in the directory. A complete FLAC file may or may not still be available in a temporary staging directory under /tmp.

  2. There exists an additional “*.new” file in the directory being processed, which may or may not be a complete FLAC file, the status of which can be tested with flac -t.

Running

Usage: reflac [OPTION]... [--] DIRECTORY...

 -h --help       Displays this help text
 -0 --fast       Use the fastest, but worst, compression possible.
 -1..-7          Adjust FLAC compression between these standard ranges.
                 The default is -5, the same as for flac itself.
 -8 --best       Use the slowest, but best, compression possible.
 -n --no-action  Do not recompress.  With --verbose, displays a list of
                 files that would be processed.
 -r --recursive  Recurse into directories.
 -s --no-sync    Do not synchronize file data.  Will return faster, with
                 the potential danger to lose your files in a system crash.
 -v --verbose    Increases the verbosity.  Use once to display the FLACs
                 currently being processed, use twice for the full ‘flac’
                 output.
 -V --version    Displays the version of this program

DIRECTORY should point ‘reflac’ to somewhere that contains *.flac
files. Optionally terminate the argument list with -- so that any
possible directory names don’t get misinterpreted as arguments.

Bugs

What, bugs? This program is flawless! Joking aside, although the author tries to resolve in reflac itself, it is at the mercy of bugs and limitations from flac and metaflac.

Tag preservation in the light of malformed tags simply does not exist. Certain release groups use buggy software with the creation of their files and will trigger some grievances.

You might see something like this:

$ reflac FLAC
/tmp/reflac.p8OjPn32z8/1-01 The Strange Green Pipe (Medley) [Mikeaudio].tag: ERROR: malformed vorbis comment field "Super Mario 64: Portrait of a Plumber",
       field contains no '=' character

reflac will not continue after the error, resulting in the untagged-but-recompressed file remaining in the temporary directory, the path of which should be part of the error message as in the example. The original file will not have been overwritten, maintaining the existing compression as well as the existing tags.

The choice is left to the user for repairing the file manually, such as by using metaflac, or removing the temporary directory altogether. The author uses, and recommends, MusicBrainz Picard to retag files before using reflac.

reflac's People

Contributors

chungy avatar maweil avatar sbrl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

reflac's Issues

Flake

Any chance of adding support for flake which is an alternative flac encoder that more completely follows the standard and has much higher compression levels while being faster than the original flac encoder when on the same compression.

I'd light to convert my flac files to max compression flac files compressed via flake.

--verify flag

Flac allows to verify the encoding via the -V, --verify flag.

Is this a feature worthwhile adding to reflac?

Skip intermediate decompression step

The README states that currently only one coverart image per flac file is supported by reflac. I have quite a few files with multiple images embedded, thus unfortunately making reflac not usable with my collection. I then looked into the code to see how hard it'll be to implement multiple embedded images and then started wondering about how reflac handles the recompression.

From what I can gleam from the code, the process works like this:

  1. extract metadata (tags) and embedded images from the flac file using metaflac
  2. decompress to a wav file in the TMPDIR (flac -d)
  3. compress wav file in TMPDIR to flac file
  4. tag flac file with metadata extracted in step 1

I wonder why the intermediate decompression step is necessary here? The flac tool supports recompressing existing flac files out of the box, like so:

flac -V -8 input.flac -o output.flac

This operation also preserves all metadata, making the calls to metaflac obsolete and thus would simplify reflac. This also fixes the limitation with the embedded images.

how do i install the script in WSL?

I've downloaded ubuntu to windows 10 and installed the flac package. How do i install this script?
I did clone the proyect and ran "make" inside the proyect folder, this throws some errors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.