27

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?

Martin Schröder
  • 6,772
  • 1
  • 19
  • 35
Simon Lenz
  • 549
  • 2
  • 7
  • 11
  • 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. –  Jan 29 '13 at 03:25
  • @user126919 maybe they recorded it in 24bit. – ctrl-alt-delor Dec 03 '16 at 17:31

5 Answers5

31

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
David Foerster
  • 35,754
  • 55
  • 92
  • 145
duffydack
  • 7,238
  • 2
  • 23
  • 18
  • works for me:) Hopefully the pacpl devs will fix the problem – Simon Lenz Jan 15 '12 at 22:38
  • 1
    `` 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 '13 at 00:04
13
sudo aptitude install libav-tools

for file in *.m4a; do avconv -i "$file" -f flac "`basename "$file" .m4a`.flac"; done
Sociologist
  • 441
  • 1
  • 4
  • 6
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.

SKhan
  • 41
  • 1
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

Jay
  • 11
  • 1
  • Also, conversion from m4a to flac does seem to lose a metadata picture that was written to the files. – bomben Jun 03 '21 at 07: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.

JamesIsIn
  • 152
  • 1
  • 11