Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: SoX is unable to convert AAC to MP3 (Read 14525 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

SoX is unable to convert AAC to MP3

I use SoX on one of my FreeBSD servers. While is has no general errors, it largely fails at converting M4A to MP3; the resulting audio files are scrambled. Is there anything I need to configure?
audiophile // flac & wavpack, mostly // using too many audio players

SoX is unable to convert AAC to MP3

Reply #1
I use SoX on one of my FreeBSD servers. While is has no general errors, it largely fails at converting M4A to MP3; the resulting audio files are scrambled. Is there anything I need to configure?


derp, i was wrong

SoX is a resampler, not an audio encoder/ converter.
http://sox.sourceforge.net/SoX/Resampling

For converting you should look at some audio encoders (Lame), or maybe ffmpeg suit your needs
https://www.ffmpeg.org/


SoX is unable to convert AAC to MP3

Reply #2
edit: Yes you were.
audiophile // flac & wavpack, mostly // using too many audio players

SoX is unable to convert AAC to MP3

Reply #3
Hmm:

Quote
SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats.


Seems you're wrong.

It can convert many formats into many other formats. It can't convert *any* format into *any* other format.

The features page mentions a couple of additional libraries you need to read MPEG4 (m4a) and write MPEG1 (MP3). Have you looked into libmp3lame and ffmpeg to complement SoX?
Every night with my star friends / We eat caviar and drink champagne
Sniffing in the VIP area / We talk about Frank Sinatra
Do you know Frank Sinatra? / He's dead

SoX is unable to convert AAC to MP3

Reply #4
ffmpeg came as a dependency, so it is installed - but all other formats I tried seem to work well. What's special with m4a?
audiophile // flac & wavpack, mostly // using too many audio players

SoX is unable to convert AAC to MP3

Reply #5
If you have ffmpeg, why are you hammering your conversion process with a tool that's anything but user friendly as your post confirms?

SoX is unable to convert AAC to MP3

Reply #6
sox input.m4a output.mp3 is as user friendly as it could be IMO.

It just should work.
audiophile // flac & wavpack, mostly // using too many audio players

SoX is unable to convert AAC to MP3

Reply #7
ffmpeg came as a dependency, so it is installed - but all other formats I tried seem to work well. What's special with m4a?

If you have ffmpeg the challenge is not reading m4a, the challenge is more likely the writing of MP3. Do you have libmp3lame installed as well?

What happens if you reduce the problem into smaller chunks. Try converting m4a to WAV (and test if it sounds OK) and a WAV to MP3 (and test if it sounds OK). That could give you an indication where in the chain the problem lies.
Every night with my star friends / We eat caviar and drink champagne
Sniffing in the VIP area / We talk about Frank Sinatra
Do you know Frank Sinatra? / He's dead

SoX is unable to convert AAC to MP3

Reply #8
MP3 to AAC:

Quote
[aac @ 0x808c5d120] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.


AAC to MP3:

Quote
[mp3 @ 0x808d1e120] Custom get_buffer() for use withavcodec_decode_audio3() detected. Overriding with avcodec_default_get_buffer
[mp3 @ 0x808d1e120] Please port your application to avcodec_decode_audio4()


Looks like something deeper is wrong.
audiophile // flac & wavpack, mostly // using too many audio players

SoX is unable to convert AAC to MP3

Reply #9
Looks like something deeper is wrong.


Your version of ffmpeg doesn't have an AAC encoder built in, but since you aren't trying to encode AAC, I don't think that really matters. 

I would do what Maurits suggested above, and try decoding AAC to WAV (which will probably work) and then encoding WAV to MP3 (which may give you a more informative error message).


SoX is unable to convert AAC to MP3

Reply #11
Ugh, lossy to lossy transcodes are bad, but since they're occasionally unavoidable, and since you already have ffmpeg, try:

 
Code: [Select]
ffmpeg -i your.m4a -c:a libmp3lame -q 2 your.m4a.V2.mp3


or 

 
Code: [Select]
ffmpeg -i your.m4a -f wav - | lame -V2 - your.m4a.V2.mp3


depending on whether your ffmpeg was built with libmp3lame support, or if you have the standalone binary (which breaks tags).

SoX is unable to convert AAC to MP3

Reply #12
Sox has removed ffmpeg handler on 2013:
http://sourceforge.net/p/sox/mailman/message/30473886/

So is there actually any way to read an MP4 file, for instance to get its spectrogram ?
Because all I'm getting is this error message:
Code: [Select]
sox input.mp4 -n spectrogram -h -o image.png
SOX FAIL formats: no handler for file extension `mp4'

SoX is unable to convert AAC to MP3

Reply #13
So is there actually any way to read an MP4 file, for instance to get its spectrogram ?
Because all I'm getting is this error message:
Code: [Select]
sox input.mp4 -n spectrogram -h -o image.png
SOX FAIL formats: no handler for file extension `mp4'

You have to pipe from ffmpeg or something.
If you need sample accuracy (proper treatment of delay and padding of AAC), neroaacdec is the only CLI decoder I know of that does it right.

SoX is unable to convert AAC to MP3

Reply #14
You have to pipe from ffmpeg or something.
If you need sample accuracy (proper treatment of delay and padding of AAC), neroaacdec is the only CLI decoder I know of that does it right.

Thanks for the answer, and the info about Nero decoder.

SoX can natively read OGG files and also MP3 files with libmad.dll so it's a pity there is no 'simple' way to do the same with MP4.