I am using my Nokia C2-01 which does not accept mp3s. I am thinking how to convert my mp3s to aac because it should maintain the sound quality well. Another option is to convert mp3 to m4a but I think it is not so good because m4a is mostly a container. There is a lot of discussion about the reverse: convert from aac/m4a to mp3 but not relevant here. I did not find anything relevant in apt-get for aac.

[Michael] I can do for one file ffmpeg -i test.mp3 test.aac but for many files the following does not work where the command is wrying to overwrite some .mp3 files for some reason.

ffmpeg -i *.mp3 *.aac

Output for a single file with ffmpeg

Command ffmpeg -i test.mp3 test.aac takes a lot of time (50 seconds for 9 MB file) and takes a lot of space (9 < 27 MB), with its output in the following. The increment of the space is significant. I think a less space taking format could be better.

ffmpeg version 3.2.2-1~bpo8+1 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --prefix=/usr --extra-version='1~bpo8+1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --disable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-libopencv --enable-frei0r --enable-libx264 --enable-chromaprint --enable-shared
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[mp3 @ 0x5619e57e29a0] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'test.mp3':
  Duration: 00:49:26.67, start: 0.000000, bitrate: 24 kb/s
    Stream #0:0: Audio: mp2, 22050 Hz, mono, s16p, 24 kb/s
Output #0, adts, to 'test.aac':
    encoder         : Lavf57.56.100
    Stream #0:0: Audio: aac (LC), 22050 Hz, mono, fltp, 69 kb/s
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
size=   25740kB time=00:49:26.67 bitrate=  71.1kbits/s speed=53.5x    
video:0kB audio:25303kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.725856%
[aac @ 0x5619e57f44c0] Qavg: 375.695
  • @drewbenn How to overcome such a challenge? - - Can you keep the space same from mp3 to acc? Please, see the body for bigger space taken by aac than mp3. – Léo Léopold Hertz 준영 Apr 5 '17 at 17:58
  • @don_crissti Is the following approach good from here unix.stackexchange.com/a/229046/16920? - - I am thinknig how to make the structure of parallel for the loop attempt. Actually, I am more interested in how to make this with Zsh and parallel. – Léo Léopold Hertz 준영 Apr 6 '17 at 18:16
  • @don_crissti Yes, they are in the same directory. – Léo Léopold Hertz 준영 Apr 6 '17 at 18:38
  • it's been included in derobert's answer. – don_crissti Apr 6 '17 at 19:42

You need to use a loop in the shell to loop over all the MP3 files, as ffmpeg typically only wants one output file per run. In bash, it'd look like:

for f in *.mp3; do
    ffmpeg -i "$f" "${f%.mp3}.aac"

Note that for sound quality reasons, you probably want to give ffmpeg some options. The ffmpeg AAC Encoding Guide has details, but as a quick example that middle line might become:

ffmpeg -i "$f" -c:a libfdk_aac -vbr 3 "${f%.mp3}.aac"

(PS: It's somewhat surprising your phone doesn't support MP3, support is very common and its listed on the spec sheet for your phone).

don_chrissti offers an alternative using GNU Parallel (which should be quicker on multi-core processors, as it will run multiple encodes simultaneously):

parallel ffmpeg -i {} -c:a libfdk_aac -vbr 3 {.}.aac ::: *.mp3

Please note there is a moreutils version of parallel as well, which has completely different syntax (and won't work in the above).

  • Yes, I was surprised too. The support is incomplete, not standard mp3. The resolution is not to use mp3 format, but acc or m4a. - - Can you estimate how much the space changes with your latter command in comparison to mp3? – Léo Léopold Hertz 준영 Apr 6 '17 at 18:13
  • 1
    @LéoLéopoldHertz준영 no idea about the space requirements. AAC should be a smaller than MP3 for the same quality, but that's when encoding from non-compressed (or lossless). Transcoding may be different. Personally I use FLAC, Opus, and Ogg Vorbis... – derobert Apr 6 '17 at 18:16
  • It would be great to get some firsh-hand experience about the issues. I really like FLAC too. – Léo Léopold Hertz 준영 Apr 6 '17 at 18:17

I can do for one file ffmpeg -i test.mp3 test.aac but for many files the following does not work where the command is wrying to overwrite some .mp3 files for some reason. ffmpeg -i *.mp3 *.aac

The asterisk is just going to expand to all MP3 files in your directory, so the first in the list will just try to overwrite the second. You need to write a loop. Assuming your shell is bash:

for mp3file in *.mp3; do
   ffmpeg -i $mp3file `basename $mp3file .mp3`.aac

I really recommend ffmpeg a command line format converter.

If you need a GUI I recommend Qwinff, Qwinff can also convert multiple files easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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