3

is there a way to convert a bunch of APE files to FLAC in Linux without altering them in any way? I mean without applying any replaygain, etc..

4
  • 1
    ffmpeg does support both APE and FLAC, so you can convert. But both formats are lossless, so the actual decoded audio will be identical. I am not sure if you mean that by "not altered in any way".
    – dirkt
    Jun 18, 2021 at 16:18
  • this feels woefully unrelated to Linux – FFmpeg runs on pretty much anything modern. So, wouldn't you rather want to ask this on SuperUser.com? Feels like the crowd there would be more familiar with such tools. Also, as dirkt says, lossless audio, so decompress to wav, reencode as flac should always work. Jun 18, 2021 at 16:42
  • 2
    Should I use ffmpeg -i input.ape output.flac? Jun 18, 2021 at 18:56
  • 2
    This will work. Jun 19, 2021 at 12:53

2 Answers 2

4

In the directory with .ape/Monkey Audio files:

dir/with/ape$ for i in *ape; do ffmpeg -i "$i" -compression_level 12 "${i%.ape}.flac"; done
  • The compression level may be set to whatever you want (0-12), but I typically use the highest as I usually do this in small batches. NB: This is different than the options for flac which is 0-8.
  • Prior to conversion, the .ape file may be tested with
    ffmpeg -v warning -i foo.ape -f null -
    
    (use -v error to see only critical errors) to see if it will decode properly.

If you make a script or shell function (i.e., not an alias), e.g., ape2flac, you don't have to find this the next time you find yourself with ape files!

2

I tried the solution provided by @bvargo and it gets the job done, but it uses a for loop to process one file at a time, which is not very efficient. A better approach for converting multiple files is to process them in parallel. This significantly reduces the total conversion time:

parallel -j12 ffmpeg -i {} -compression_level 12 {.}.flac ::: *.ape
  • -j12 specifies the number of parallel jobs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .