How to use ffmpeg to convert ape to mp3?

I am trying to use ffmpeg on ubuntu 13.10 to convert AP3 to MP3?

I installed ffmpeg, but I get this error when I use it. Please tell me how can I fix it?

$ ffmpeg -i CD1_Age_0-3_Baby.ape CD1_Age_0-3_Baby.mp3
ffmpeg version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Nov  9 2013 19:15:22 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, ape, from 'CD1_Age_0-3_Baby.ape':
  Metadata:
    Album           : MOZART EFFECT I - ENLIGHTMENT
    Title           : C:\[APE SET] Ī����ЧӦ-�������ǵ����� 4CDS\CDImage01
    Genre           : Classical
    Year            : 2002
    Comment         : Exact Audio Copy
  Duration: 01:09:17.75, start: 0.000000, bitrate: 656 kb/s
    Stream #0.0: Audio: ape, 44100 Hz, stereo, s16
Output #0, mp3, to 'CD1_Age_0-3_Baby.mp3':
    Stream #0.0: Audio: [0][0][0][0] / 0x0000, 44100 Hz, stereo, s16, 200 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Encoder (codec id 86017) not found for output stream #0.0

First make sure that you have the libavcodec-extra-53 package for encoding to mp3 installed.

sudo apt-get install libavcodec-extra-53   

Try to convert the .ape file to .mp3 using ffmpeg and you will get the following message:

*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release.   
Please use avconv instead.

This is the same error message that you got in your question. So use avconv instead. The avconv program is provided by the libav-tools package from the Ubuntu Software Center. avconv, like ffmpeg, is run from the terminal.

This example uses 256kbps bitrate for the output.mp3 file and id3v2_version 3 for the metadata tags. First change directory using the cd command to the same directory where your input.ape file to be converted is located. Then run the command:

avconv -i 'input.ape' -id3v2_version 3 -codec:a libmp3lame -b 256k 'output.mp3'

Note: The command: ffmpeg -i '10 Make Peace.ape' -acodec libmp3lame -b 256k -id3v2_version 3 '10 Make Peace.mp3' will also do the conversion to mp3 using ffmpeg, but you will get the THIS PROGRAM IS DEPRECATED error message. The ffmpeg package is still available in Ubuntu 13.10 and earlier releases.

In Ubuntu 14.04, the Libav codec library (additional codecs) package (libavcodec-extra-53) has been updated to libavcodec-extra-54. In Ubuntu 14.10 and 15.04, the Libav codec library (additional codecs) package has been updated to libavcodec-extra-56.

Updates for Ubuntu 15.10 and later

In Ubuntu 15.10 and 16.04, the Libav codec library (additional codecs) package has been updated to libavcodec-ffmpeg-extra56.

In Ubuntu 16.10, 17.04, 17.10 and 18.04 the Libav codec library (additional codecs) package has been updated to libavcodec-extra57.

In Ubuntu 18.10 and 19.04 the Libav codec library (additional codecs) package has been updated to libavcodec-extra58.


You have six main options to encode to MP3 with ffmpeg:

  • Avoid the misleading Libav mess that was forced on Ubuntu users and simply download, extract, and execute a recent Linux build of ffmpeg. Put it in ~/bin and then re-login. Now when you run ffmpeg it will use this new build. This is the easiest option.

  • Follow a step-by-step guide to compile the real ffmpeg with whatever codecs and features you want.

  • Install ffmpeg from the Ubuntu Multimedia for Trusty PPA (for 14.04 users).

  • Install the libavcodec-extra-* package to enable MP3 encoding via libmp3lame in buggy avconv or the crappy, old, fake ffmpeg.

  • Pipe to lame and use it to encode: ffmpeg -i input -f wav - | lame - output.mp3

  • Upgrade Ubuntu and use the ffmpeg package from the repo. The real ffmpeg from FFmpeg returned to Ubuntu in Vivid 15.04.


Here is another Script that might help folks. What you will need to do is copy it into the root folder of the ape files you want to convert.

#!/bin/bash

set -e

# Script Name:  convert_ape2mp3.sh
#
# Description:  The script will recursively find all *.ape files
#   and then convert them to mp3 files.
#   This script has been tested on Ubuntu 14.04 
#   
# Dependencies: (you will need to install the following library prior
#                to running this script.)
#     sudo apt-get install libav-tools
# avconv -i '01_Tori Amos_Beauty Queen - Horses.ape' -id3v2_version 3 -codec:a libmp3lame -b 320k '01_Tori Amos_Beauty Queen - Horses.mp3'

# Optional:  After conversion is complete if you want you can 
#   remove all the ape files.
#   find . -type f -name "*.ape" 
#   find . -type f -name "*.ape" -exec rm {} \;

find . -name "*.ape" -print0 | while IFS= read -r -d '' FILE; do
    echo "### Converting $FILE..."
    echo avconv -i "$FILE" -id3v2_version 3 -codec:a libmp3lame -b 320k "${FILE%.*}.mp3";
    avconv -i "$FILE" -id3v2_version 3 -codec:a libmp3lame -b 320k "${FILE%.*}.mp3";

done

With libav_tools and libmp3lame installed in the directory where ape files are located, type in terminal:

$ for f in *.ape; do
      avconv -i "$f" -id3v2_version 3 -codec:a libmp3lame -ab 320k "${f%.ape}.mp3"
done

With that all ape files in directory convert to mp3 stereo 320kb and tags in ape files are respected.