How to Convert Audio From Ogg to MP3 in Linux

1. Introduction
The Ogg format is a container for storing audio, video, and associated metadata. It makes use of the Vorbis audio compression scheme specifically designed for Ogg. Overall, Ogg Vorbis is a very free, open, and unpatented audio compression format.
In this tutorial, we’ll discover ways to convert audio from the Ogg to the MP3 format in Linux.
2. Environment Setup
Before we dive into the main points, let’s guarantee the required stipulations are prepared, together with the mediainfo instrument and a few pattern audio information within the Ogg format.
2.1. Sample Audio
First, we create a brand new listing and obtain the Ogg information utilizing wget:
$ mkdir audio && cd audio
$ wget -q -O file1.ogg https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_100KB_OGG.ogg
$ wget -q -O file2.ogg https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_500KB_OGG.ogg
The mkdir command creates an audio listing, whereas the cd command adjustments the present listing to the newly created audio listing.
The -q flag within the wget command suppresses the output, whereas -O specifies the output filename.
Thus, we now have two Ogg information (file1.ogg and file2.ogg) contained in the audio listing.
2.2. MediaInfo Installtion
MediaInfo is a command-line utility to extract and show media file metadata. This utility isn’t pre-installed on most Linux distributions.
So, let’s proceed with the set up:
$ sudo apt set up mediainfo
Now, we will test the put in model of MediaInfo:
$ mediainfo --version
MediaInfo Command line,
MediaInfoLib - v21.09
As we will see, the put in model of MediaInfo is v21.09.
Next, we will test the multimedia information and their metadata:
$ mediainfo file1.ogg
General
Complete title : file1.ogg
Format : Ogg
File measurement : 101 KiB
Duration : 4 s 949 ms
Overall bit charge mode : Variable
Overall bit charge : 167 kb/s
Audio
ID : 14380 (0x382C)
Format : Vorbis
Format settings, Floor : 1
Duration : 4 s 949 ms
Bit charge mode : Variable
Bit charge : 160 kb/s
Channel(s) : 2 channels
Sampling charge : 44.1 kHz
Compression mode : Lossy
Stream measurement : 96.7 KiB (96%)
Writing library : libVorbis (Omnipresent) (20120203 (Omnipresent))
The output of the mediainfo command is split into two elements – General and Audio. If working with video information, a Video part reveals the related knowledge.
The file1.ogg file is within the Ogg container format, whereas the audio saved within the file has the Vorbis format. Generally, the format in all elements is similar for many different codecs, i.e., MPEG Audio for MP3.
3. FFmpeg
FFmpeg is a robust multimedia framework and toolset, well-known for its command-line capabilities.
3.1. Installation
Let’s test whether or not we now have FFmpeg put in on the system:
$ ffmpeg -version
ffmpeg model 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg builders
constructed with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
...
In case it’s not already obtainable, we will normally set up FFmpeg through a neighborhood package deal supervisor equivalent to apt:
$ sudo apt set up ffmpeg
This command installs the FFmpeg framework together with instruments like ffplay and ffprobe.
3.2. Format Conversion
The FFmpeg instrument re-encodes any enter media by default. Thus, the format conversion with FFmpeg is normally fairly easy.
Let’s give it a strive:
$ ffmpeg -i file1.ogg file1_ffmpeg.mp3
This command takes an enter (-i) file, file1.ogg, and converts it to an MP3 file, file1_ffmpeg.mp3. Additionally, we will use the -y choice to overwrite output information with none prompts.
3.3. Format Verification
Let’s confirm the format of the ensuing file:
$ mediainfo file1_ffmpeg.mp3
The output confirms the MPEG Audio format with the Layer 3 format profile, i.e., MP3.
Moreover, we will even play this output file utilizing ffplay:
$ ffplay -nodisp -autoexit file1.ogg
This command performs the observe with none graphical show (-nodisp) and exits robotically (-autoexit) as soon as the observe is completed.
4. SoX
SoX (Sound eXchange) is an open-source command line utility supporting numerous audio processing duties.
4.1. Installation
SoX doesn’t present libraries for encoding and decoding MP3 knowledge as a result of patent restrictions. Thus, we might have to put in the libraries supporting the encoding and decoding of MP3 individually.
So, let’s set up SoX and an MP3 encoder:
$ sudo apt set up -y sox libsox-fmt-mp3
This command installs SoX with mp3 help (libsox-fmt-mp3).
So, let’s confirm the set up by operating the sox command:
$ sox --version
sox: SoX v14.4.2
Thus, we see that the model of sox at present put in on the system is v14.4.2.
4.2. Format Conversion
In its easiest type, the format conversion through SoX is much like the cp command, the place we will specify an enter file adopted by the output file:
$ sox file1.ogg file1_sox.mp3
This command takes the enter file (file1.ogg), decodes the audio knowledge from Ogg format, processes and encodes it into the MP3 format (file1_sox.mp3).
Moreover, we will set the verbosity stage to 3 (-V3) to see particulars in regards to the processing throughout the format conversion.
5. LAME
LAME, quick for LAME Ain’t an MP3 Encoder, is a high-quality MP3 encoder.
5.1. Installation
We can set up LAME utilizing most native package deal managers:
$ sudo apt set up lame
Let’s confirm the set up:
$ lame --version
LAME 64bits model 3.100 (http://lame.sf.internet)
...
In this case, the put in model is 3.100.
5.2. Format Conversion
Let’s shortly convert file1.ogg to an MP3 file:
$ lame file1.ogg file1_lame.mp3
This command converts the Ogg audio knowledge to MP3 audio and writes it to the given output filename, i.e., file1_lame.mp3.
Additionally, we will set the standard of VBR (variable bit charge) with the -V choice, the place 0 represents the best high quality and 9 represents the bottom high quality.
We can even mark an MP3 file as copyright-protected (-c) or non-original (-o).
6. SoundConverter
As the title suggests, SoundConverter is an audio file converter. It is particularly designed for the GNOME desktop.
6.1. Installation
First, let’s set up soundconverter:
$ sudo apt set up soundconverter
As typical, this command installs the soundconverter instrument on the system.
Now, we will retrieve the model quantity by not offering any parameters:
$ soundconverter
soundconverter 4.0.3
This command prints the model and opens the SoundConverter GUI (graphical consumer interface).
Additionally, we will additionally test the model from the GUI by clicking on the About button from the menu.

Next, let’s carry out a conversion.
6.2. Format Conversion
SoundConverter supplies each the command-line and graphical consumer interfaces.
In this case, we give attention to the command-line interface:
$ soundconverter -b file1.ogg -f "mp3" -o ./
This command makes use of batch mode with the command-line interface (-b) to transform the enter Ogg file to the MP3 format.
The -f choice specifies the output format, on this case, mp3. The output path is ready utilizing the -o (–output) choice. By default, SoundConverter replaces the file extension (suffix) of the enter file with the brand new extension specified for the output file.
6.3. Multiple File Processing
Additionally, we will convert a number of information on the identical time with the batch mode (-b):
$ soundconverter -b ./*ogg -f "mp3" -o ./
This command converts all Ogg information from the present listing to MP3 information.
Additionally, we will set soundconverter to overwrite information with the -e overwrite choice.
7. ogg2mp3
ogg2mp3 is a Bash shell script developed particularly to transform the Ogg information to MP3 format.
7.1. Installation
Let’s fetch the ogg2mp3 shell script from its Google Code Archive:
$ wget -q https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/ogg2mp3/ogg2mp3
$ chmod +x ogg2mp3
Thus, we obtain the shell script and modify it to be executable.
Then, we will transfer the executable ogg2mp3 file to the bin listing, i.e., /usr/native/bin/, for simpler entry:
$ sudo mv ogg2mp3 /usr/native/bin/
Now, we should always have the ability to use the ogg2mp3 command from wherever on the system.
We can retrieve the system model of ogg2mp3 by printing the –assist message:
$ ogg2mp3 --help
ogg2mp3 model 0.4
Bulk transcoding of OGG Vorbis to MP3.
...
In this case, the put in model of ogg2mp3 is 0.4.
7.2. Format Conversion
ogg2mp3 takes a listing of enter information (Ogg), decodes the audio with the oggdec library, processes it, and encodes the MP3 audio with LAME.
Let’s convert each Ogg information to MP3:
$ ogg2mp3 ./file1.ogg file2.ogg
This command converts each the enter information to the MP3 format, leading to file1.mp3 and file2.mp3.
We can enhance the verbosity of the operation through the –verbose flag. Additionally, we will additionally change the stereo mode utilizing the –mode (-m) choice.
7.3. Verification
Let’s test the format of one of many output information with mediainfo:
$ mediainfo file2.mp3
General
Complete title : file2.mp3
Format : MPEG Audio
File measurement : 521 KiB
Duration : 26 s 122 ms
Overall bit charge mode : Variable
Overall bit charge : 163 kb/s
Writing library : LAME3.100
Audio
Format : MPEG Audio
Format model : Version 1
Format profile : Layer 3
Format settings : Joint stereo / MS Stereo
Duration : 26 s 122 ms
Bit charge mode : Variable
Bit charge : 160 kb/s
Channel(s) : 2 channels
Sampling charge : 44.1 kHz
Frame charge : 38.281 FPS (1152 SPF)
Compression mode : Lossy
Stream measurement : 520 KiB (100%)
Writing library : LAME3.100
Encoding settings : -m j -V 4 -q 3 -lowpass 17.5 --abr 160
Notably, the writing library is LAME3.100.
8. Conclusion
In this text, we discovered easy methods to convert audio from Ogg to the MP3 format in Linux.
First, we put in and examined MediaInfo to confirm the format for each the pattern and output information. Then, we used FFmpeg to transform the audio from Ogg to MP3. We additionally used SoX and LAME to transform the identical information.
Then, we mentioned the command-line utilization of SoundConverter for performing the same conversion in batch mode. Finally, we used ogg2mp3 to transform a number of audio information from Ogg to the MP3 format in a single command.
The publish How to Convert Audio From Ogg to MP3 in Linux first appeared on Baeldung on Linux.
Related Stories
- How to Convert an OGV File to MP4
- Set Default Profile for PulseAudio
- How to Concatenate Several MP3 Files Into One
HI-FI News
through Baeldung – Linux https://ift.tt/MFDlQVS
May 4, 2024 at 04:51AM
-
Product on sale
Audiophile Vinyl Records Cleaning BundleOriginal price was: €69.90.€59.90Current price is: €59.90. incl. VAT -
Product on sale
Easy Start Vinyl Records Cleaning KitOriginal price was: €69.90.€59.90Current price is: €59.90. incl. VAT -
Vinyl Records Cleaner Easy Groove Concentrate€34.95 incl. VAT -
Easy Groove Super Set€199.00 incl. VAT -
Easy Groove Enzycaster – vinyl records prewash cleaner€34.95 incl. VAT -
Easy Groove Extreme MK. II- vinyl records prewash cleaner€45.00 incl. VAT -
Vinyl Records Cleaner – Easy Groove Virgin Concentrate€35.00 incl. VAT -
Easy Groove Spray&Wipe vinyl records cleaner€34.95 incl. VAT








