Convert ogg to mp3

The purpose of this tutorial is to show how to convert .ogg Ogg Vorbis audio files into .mp3 format. This can be done with a couple of different tools via the command line on all major Linux distros. You will also see how to batch convert files in case you have many audios to convert at once.

In this tutorial you will learn:

  • How to install ffmpeg and vorbis tools on all major Linux distros
  • How to convert ogg to mp3 using ffmpeg or vorbis tools
  • How to batch convert ogg files to mp3
Converting an ogg audio file to mp3 via Linux command line
Converting an ogg audio file to mp3 via Linux command line
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software ffmpeg, vorbis-tools
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to Remove or ignore all comment lines from Linux config files




Before we dive into the conversion examples below, you’ll need to install ffmpeg or vorbis-tools on your system. The software is available on all major Linux distros and can be easily installed using your system’s package manager. Use the appropriate command below to install one or both of them on your own computer.

To install ffmpeg or vorbis-tools on Ubuntu, Debian, and Linux Mint:

$ sudo apt install ffmpeg vorbis-tools

To install ffmpeg or vorbis-tools on Fedora:

$ sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
$ sudo dnf install ffmpeg vorbis-tools

To install ffmpeg or vorbis-tools on CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
$ sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
$ sudo dnf install ffmpeg vorbis-tools

To install ffmpeg or vorbis-tools on Arch Linux and Manjaro:

$ sudo pacman -S ffmpeg vorbis-tools

How to convert ogg files to mp3 audio

  1. To convert a single ogg file to mp3 using ffmpeg:


    $ ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3
    
  2. To batch convert multiple ogg files to mp3 using ffmpeg:
    $ for i in *.ogg; do ffmpeg -i "$i" -acodec libmp3lame "${i%.*}.mp3"; done
    
  3. To batch convert ogg files to mp3 using oggdec command (from package vorbis-tools):
    $ for file in *.ogg;do oggdec -o - "$file"|lame -h -V 4 --vbr-new - "$(basename "$file" .ogg).mp3";done
    

Closing Thoughts

In this tutorial, we saw how to convert an ogg audio file to mp3 on a Linux system. Using tools like ffmpeg or vorbis tools, as well as a slew of others, allows us to convert between these two codecs from the Linux command line. You may also be interested in checking out our more in depth tutorial on ffmpeg audio format conversions.



Comments and Discussions
Linux Forum