Convert lossless m4a to flac

24,824

Solution 1

You can convert an m4a file to flac with the ffmpeg command-line tool:

To install ffmpeg:

sudo apt-get install ffmpeg

To convert:

ffmpeg -i filein.m4a -f flac fileout.flac

Solution 2

sudo aptitude install libav-tools

for file in *.m4a; do avconv -i "$file" -f flac "`basename "$file" .m4a`.flac"; done

Solution 3

While both the answers involving ffmpeg/avconv (which I think are essentially the same tool) both work, they currently have a flaw. Namely that lossless m4a is often 24 bit sample, and currently ffmpeg/avconv will generally force the conversion to end up in 16 bit sample.

I believe using sndfile-convert (libsndfile) does not have this problem. Likewise, I believe it can be avoided by using mplayer to decode the m4a before encoding it with ffmpeg or flac. I think soundKonverter on KDE may do this for you.

In any case, whatever you do, I suggest checking whether the original and the converted file have the same bit depth of samples.

Solution 4

Personally I use this code. for file in *.m4a; do fname=$(basename "$file" .m4a); ffmpeg -i "$file" -vn -ar 48000 -f flac "$fname".flac; done.

So the output file don't have *.m4a.flac as extension.

And this is the ouput from ffprobe on a flac file:
Stream #0:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit)
And don't forget to check the tags/metadata on the file. I was surprised to see my mail address in the tag/metadata. And ffprobe show more mtag/metada as Easytag.

thanks to zetdotpi and https://stackoverflow.com/a/2664758

Share:
24,824

Related videos on Youtube

Simon Lenz
Author by

Simon Lenz

Updated on September 18, 2022

Comments

  • Simon Lenz
    Simon Lenz almost 2 years

    I tried to convert a file with pacpl, but I get the well-known "256" error. With the -v flag, the FAQ of pacpl tells me:

    "The file you are trying to convert is a lossless .m4a file. The format is not yet supported by FAAC/FAAD."

    Since faac/faad seems to be used in every other converting tool on Ubuntu, how can I successfully convert formats?

    • Admin
      Admin over 11 years
      How is the lossless m4a a 24 bit sample? CD's are 16 bit, and SACD's are not rippable by any means, which means it was pointlessly "upconverted" to 24 bit, which is stupid.
    • ctrl-alt-delor
      ctrl-alt-delor over 7 years
      @user126919 maybe they recorded it in 24bit.
  • Simon Lenz
    Simon Lenz over 12 years
    works for me:) Hopefully the pacpl devs will fix the problem
  • Martin Schröder
    Martin Schröder over 11 years
    But sndfile-convert can not read iTunes AAC-LC.
  • zetdotpi
    zetdotpi about 11 years
    `` for file in *.m4a; do echo $file; ffmpeg -i "$file" -f flac "basename "$file" .m4a.flac"; done `` To do a batch conversion of all *.m4a files in directory.
  • bomben
    bomben about 3 years
    Also, conversion from m4a to flac does seem to lose a metadata picture that was written to the files.