How to use ffmpeg to convert ape to mp3?

16,405

Solution 1

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.

Solution 2

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.

Solution 3

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

Solution 4

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.

Share:
16,405

Related videos on Youtube

michael
Author by

michael

Updated on September 18, 2022

Comments

  • michael
    michael almost 2 years

    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
    
  • llogan
    llogan over 10 years
    Note that the "deprecated" message refers to ffmpeg from Libav (a fork of FFmpeg), and not ffmpeg from FFmpeg.
  • Csabi Vidó
    Csabi Vidó over 10 years
    No the error message is at the bottom: Encoder (codec id 86017) not found for output stream #0.0. Running the same program with another name doesn't fix any real issue, it just suppresses the Libav fagottery, but -codec:a libmp3lame might be the fix for the issue.
  • No Time
    No Time almost 10 years
    Welcome to AskUbuntu! Could you edit your post to make the script easier to read. (Use >, or 4 spaces before each line)
  • Rmano
    Rmano over 8 years
    In my experience most problem with video conversion are resolved by installing the real ffmpeg. I am using the static builds --- no installation, no fuss, uncompress and go --- provided in the link in this answer since at least two years (updating sometime) and had no problem at all.
  • Cbhihe
    Cbhihe over 8 years
    Please, check your code block. Makes no sense (to me at least).
  • AlwaysTalkingAboutMyDog
    AlwaysTalkingAboutMyDog over 8 years
    The code block makes perfect sense. The for statement prevents the terminal from executing the command after you hit enter. The done finishes the loop, while the two lines in the middle are inside the loop.
  • Cbhihe
    Cbhihe over 8 years
    @Zzzach...: thank you so very much. Pfeww ! Now, at long last, I know bash ! ;-) More seriously, please look at the pre-edit formatting of that code block ...
  • Maxim
    Maxim almost 3 years
    The question was about an APE file...