Unable to convert .mp3 to .m4a using ffmpeg

rahulg picture rahulg · May 4, 2013 · Viewed 14.4k times · Source

I am fully aware the legal constraints in using libfaac but this is just for my testing purpose.

I have compiled ffmpeg with faac enabled. So when I tried to convert an .mp3 to a .m4a here is the error that I am getting. Please provide a resolution to this problem. I tried it on two different sources of .mp3, still I am getting the same error.

[user@ip-10-161-13-26 ~]$ ffmpeg  -i Kalimba.mp3 -c:a libfaac Kalimba.m4a
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
  built on May  4 2013 09:33:27 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
  configuration: --enable-libfaac --enable-nonfree --disable-yasm
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
[mp3 @ 0x2464680] Header missing
[mp3 @ 0x2463100] max_analyze_duration 5000000 reached at 5015510
[mp3 @ 0x2463100] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'Kalimba.mp3':
  Metadata:
    publisher       : Ninja Tune
    track           : 1
    album           : Ninja Tuna
    artist          : Mr. Scruff
    album_artist    : Mr. Scruff
    title           : Kalimba
    genre           : Electronic
    composer        : A. Carthy and A. Kingslow
    date            : 2008
  Duration: 00:05:50.60, start: 0.000000, bitrate: 191 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s
    Stream #0:1: Video: mjpeg, yuvj420p, 512x512, 90k tbr, 90k tbn, 90k tbc
    Metadata:
      title           : thumbnail
      comment         : Cover (front)
Output #0, ipod, to 'Kalimba.m4a':
  Metadata:
    publisher       : Ninja Tune
    track           : 1
    album           : Ninja Tuna
    artist          : Mr. Scruff
    album_artist    : Mr. Scruff
    title           : Kalimba
    genre           : Electronic
    composer        : A. Carthy and A. Kingslow
    date            : 2008
    Stream #0:0: Video: none, q=2-31, 128 kb/s, 90k tbn
    Metadata:
      title           : thumbnail
      comment         : Cover (front)
    Stream #0:1: Audio: none, 0 channels, 128 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (mjpeg -> ?)
  Stream #0:0 -> #0:1 (mp3 -> libfaac)
Encoder (codec none) not found for output stream #0:0

MP3 file is at http://db.tt/HtpEBpFU

Also while using Faac independently I get this weird error for any file.

Freeware Advanced Audio Coder
FAAC 1.28

Couldn't open input file sample.mp3

Answer

slhck picture slhck · May 4, 2013

The problem is that your input contains album artwork, which ffmpeg parses as video.

Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s
Stream #0:1: Video: mjpeg, yuvj420p, 512x512, 90k tbr, 90k tbn, 90k tbc

It tries to convert the video, but doesn't find a valid output codec for the MPEG-4 format (M4A is just another name). This is because you compiled ffmpeg without libx264, which ffmpeg needs in that case, as it doesn't have a native H.264 encoder.

Anyway, you need to prevent it from trying to convert the artwork/video. Add -vn to the options:

ffmpeg  -i Kalimba.mp3 -c:a aac -vn Kalimba.m4a

Some tips:

  • FAAC is not supported by ffmpeg anymore. Use the built-in AAC encoder instead.
  • Encoding to .aac works because the output format cannot contain video, so ffmpeg won't try to convert the video/artwork stream in the first place.