How to convert ogg to aac music format?

6,676

Solution 1

ffmpeg -i input.ogg -strict experimental -acodec aac output.aac

you can find ffmpeg in the official repository.

Solution 2

Transcoding from one lossy format to another is not ideal. However, if you insist on doing so, this is the best way: install avconv and ubuntu-restricted-extras with

sudo apt-get install avconv ubuntu-restricted-extras

then get neroAacEnc:

wget http://ftp6.nero.com/tools/NeroAACCodec-1.5.1.zip
sudo unzip NeroAACCodec-1.5.1.zip -d /usr/bin linux/*
sudo chmod +x /usr/bin/neroAacDec /usr/bin/neroAacEnc /usr/bin/neroAacTag

NeroAacEnc is superior to avconv's internal AAC encoder, and also much better than libfaac, it consistently scores highly on listening tests; and Nero have released it free for non-commercial use.

To create an M4A (MP4) file, use

avconv -i input.ogg -f wav - | neroAacEnc -if - -ignorelength -q 0.55 -of output.m4a

The -q flag can use any value between 0 and 1, with 1 being highest-quality; according to this, 0.55 averages to a bit rate of 192 kb/s; a lower -q of around 0.4 would probably actually be perfectly suitable for most music listening. Experiment to find out what works best for you.

Unfortunately, this won't keep the metadata; but you can transfer the metadata from input.ogg to output.m4a with a second command:

avconv -i output.m4a -i input.ogg -map 0 -map_metadata 1 -c copy output.m4a
Share:
6,676

Related videos on Youtube

Brallan Aguilar
Author by

Brallan Aguilar

I'm a Computer Engineering student from Tecnológico de Costa Rica. I love Linux.

Updated on September 18, 2022

Comments

  • Brallan Aguilar
    Brallan Aguilar over 1 year

    I want to convert a ogg file to aac. But I need to transfer all the data of the ogg file (i.e. album, year, cover,...) to the aac file using a shell comand.

    Thanks!

    • pl1nk
      pl1nk almost 12 years
      Have you solved this issue?
  • Brallan Aguilar
    Brallan Aguilar over 12 years
    Mmm sorry, but the sound quality isn't good and the tags of the original file didn't copy.
  • Brallan Aguilar
    Brallan Aguilar over 12 years
    I tried it. But the problem is metadata (tag information like cover, artist,...) isn't copied.
  • Brallan Aguilar
    Brallan Aguilar over 12 years
    Mmm sorry, where I can obtain it?
  • pl1nk
    pl1nk almost 12 years
    It's not a native Linux application.
  • Eliah Kagan
    Eliah Kagan almost 12 years
    @BrallanAguilar Unfortunately the sound quality will generally not be good when converting from one lossy format to another. You should avoid doing so when possible.
  • Eliah Kagan
    Eliah Kagan over 11 years
    @AAC Even better, you could expand this answer to explain how to obtain foobar2000, how to get it working in Ubuntu with Wine (since it's a Windows program), and specifically how to use it to convert files (screenshots would be a plus, too).
  • artfulrobot
    artfulrobot about 10 years
    This uses FAAC which -to my ear- results in horrible sounding music.