Unable to convert .mp3 to .m4a using ffmpeg [closed]
Asked Answered
G

1

12

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
Gobble answered 4/5, 2013 at 11:58 Comment(3)
Please provide the full, uncut ffmpeg output, and possibly the sample file that fails to convert.Carpogonium
Surprisingly, converting it to .aac worked fine, i.e. almost same command ffmpeg -i Kalimba.mp3 -c:a libfaac Kalimba.aacGobble
Thank you for providing the info. Please note that questions about ffmpeg command line usage are off topic for Stack Overflow, so I've voted to migrate your question over to Super User, where they're better suited. No need to re-ask though: it'll get moved over.Carpogonium
C
30

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.
Carpogonium answered 4/5, 2013 at 16:45 Comment(6)
I have error Unknown encoder 'libfaac' using it.Pasty
Use another encoder, see: superuser.com/questions/370625/…Carpogonium
Interestingly enough, I can convert mp3 with album art to m4a with ffmpeg 3.4 but not with ffmpeg 4.0 or above built from the source. I use libfdk_aac for best results on my iPodsKunstlied
@Pedro If you have a specific issue with ffmpeg please ask a new question about the problem. There's no reason it shouldn't work. Please include all command line output.Carpogonium
@Carpogonium You are absolutely right, I just lost the oversight of what I was doing 'cause I'm jumping from Ubuntu to MacOSX with the rudix package manager. Sorry for the noise... Now using ffmpeg 4.1.3 and I can copy cover art from an MP3 with ID3v2 tags using -c:v copy as the video codec. Tried with a JPEG file as cover art on both systems.Kunstlied
@Carpogonium As of 2017 libfdk_aac may not always be better than aac for AAC-LC. The built in aac encoder is quite good. Reference: trac.ffmpeg.org/wiki/Encode/HighQualityAudioMontserrat

© 2022 - 2024 — McMap. All rights reserved.