28

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?

2
  • 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.
    – user126919
    Jan 29, 2013 at 3:25
  • @user126919 maybe they recorded it in 24bit. Dec 3, 2016 at 17:31

5 Answers 5

32

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

To batch convert:

for i in $(find . -type f -name "*.m4a"); do echo "Converting $i to flac"; ffmpeg -i "$i" -c:a flac "${i%.m4a}.flac"; done
2
  • works for me:) Hopefully the pacpl devs will fix the problem
    – Simon Lenz
    Jan 15, 2012 at 22:38
  • 2
    `` 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.
    – zetdotpi
    Jun 13, 2013 at 0:04
13
sudo aptitude install libav-tools

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

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.

1
  • 1
    But sndfile-convert can not read iTunes AAC-LC. Nov 30, 2012 at 18:49
1

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

1
  • Also, conversion from m4a to flac does seem to lose a metadata picture that was written to the files.
    – bomben
    Jun 3, 2021 at 7:15
0

Just combining all the useful information from the other three answers.

To check the bit depth on your mp4 files:

# cd into desired directory then... 
ffprobe -show_streams ./[pick one file to test].m4a | grep -e codec_name -e bits_per_raw_sample 

This should show the bit depth at the bottom of the output.

To use ffmpeg and for all files in a folder (assuming they are not 24 bit (or higher)):

# cd into desired directory then... 
for file in *.m4a ; do ffmpeg -i "$file" -f flac "$( basename "$file" .m4a ).flac" ; done 

Hope that helps.

You must log in to answer this question.

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