Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a load of audio files (about 1000) which I want to convert from m4a to mp3 so I can use play them on a CD player which has a USB port.

I tried doing something simple like: ffmpeg -i FILE.m4a FILE.mp3 but this seems to reduce the bitrate to a very low value, which isn't what I want.

Similarly I don't want to convert using a constant bitrate, such as 320k, because some of the files I am converting are 320k m4a's and some are as low quality as 96k m4a's.

It seems to make no sense to force 320k, since some files will become many times larger than they need be. Similarly it makes no sense to destroy all my 320k files by converting them to something much lower than 96k. (At the moment, the files are being converted to about 50k.)

Does anyone know how I can do this? What I really want to do is tell ffmpeg to convert all m4a files in a directory into mp3's while retaining the current audio quality as best it can. (Of course there is likely to be some extra losses from converting from lossy to lossy file formats.)

Thanks for your help. If this isn't possible, is there some sort of script which might detect the required quality as it converts files individually?

PS: I am working on an intel Mac, but also have a Ubuntu box.

share|improve this question

1 Answer 1

VBR

You can use the -qscale:a option in ffmpeg to create a variable bitrate (VBR) MP3 output. From FFmpeg Wiki: Encoding VBR (Variable Bit Rate) mp3 audio:

Control quality with -qscale:a (or the alias -q:a). Values are encoder specific, so for libmp3lame the range is 0-9 where a lower value is a higher quality. 0-3 will normally produce transparent results, 4 (default) should be close to perceptual transparency, and 6 usually produces an "acceptable" quality. The option -qscale:a is mapped to the -V option in the standalone lame command-line interface tool.

You'll have to experiment to see what value is acceptable for you. Also see Hydrogen Audio: Recommended LAME Encoder Settings.

Encoding multiple files

You can use a Bash "for loop" to encode all files in a directory:

$ mkdir newfiles
$ for f in *.m4a; do ffmpeg -i "$f" -codec:v copy -codec:a libmp3lame -q:a 2 newfiles/"${f%.m4a}.mp3"; done

Get ffmpeg

It's recommended to use a recent build of ffmpeg if possible. See the FFmpeg Download page for links to builds for OS X, Linux, and Windows. You can also follow a guide to compile FFmpeg.

share|improve this answer
    
Did you mean to have "*.m4a" not m4v? I am converting m4a files not m4v files? –  user3728501 Jan 21 '14 at 12:04
1  
@EdwardBird Yes. That was a typo and it has been fixed. –  LordNeckbeard Jan 21 '14 at 18:09
    
Okay thanks, the commands worked but I don't think it is doing what I wanted. I've set -q:a 0, which is doing what I expected for higher quality m4a's (producing large files with higher vbr rates) but lower quality files I think are still being converted into large files, with vbr's of about 250-260 kb/s. I would have expected the files which are about 96k in m4a format to be converted to a similar bitrate with the lame encoder in vbr mode. I'm assuming I haven't quite understood how the vbr encoding mode works? –  user3728501 Jan 21 '14 at 22:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.