bulk/batch convert mp3 files to ogg via command line?
Solution 1:
Searching for packages matching ogg, I found dir2ogg which seems to be exactly what you want. Just
sudo apt-get install dir2ogg
dir2ogg -r /path/to/mp3s/
And it recursively finds and converts all mp3 files under /path/to/mp3s/
to ogg (assuming I read the manual correctly).
Solution 2:
Use a combination of FFMPEG and String Manipulation.
Change into the folder where your mp3's are located:
cd mp3folder
One example is to use a simple "for" loop:
for file in *.mp3
do ffmpeg -i "${file}" "${file/%mp3/ogg}"
done
The double quotes prevent spaces in the filenames being treated as 'newlines'.
ffmpeg has several options to include in the conversion like codecs, bitrate, sample size, stereo/mono, etc... The above is the most generic conversion with default settings.
Solution 3:
Be careful with conversions from MP3, M4A, etc. to OGG because the result may sound poor!
Warning: Both MP3 and OGG are lossy formats, unlike say WAV or FLAC. This means that they achieve their compression in great part by throwing away bits of audio information that are imperceptible to the human ear (called psychoacoustics [wikipedia])
When you encode (transcode) from one lossy format to another, most of those psychoacoustically redundant bits are already gone, so the transcoding quality will suffer and may even be "hearable" in the result. Hence, it isn't recommended to do such conversions unless absolutely necessary.
Minimize the effect if you do so by choosing a higher destination bit-rate than the source bit-rate
If you do this MP3-to-OGG conversion, you can minimize the chance of artifacts (poor quality) by using a higher destination bitrate than the source bitrate, e.g if your MP3s are at 128 kbps, try using Ogg at -q7
(variable bitrate level 7), which is usually around ~200 kbps.
You can pass the -q
option to dir2ogg (available in the repos as @geirha mentioned) which should do what you want.
Solution 4:
you can use the avconv a gpl program, I did a shell for exemplify (run it on folder with the .mp3 files):
#!/bin/bash
if hash avconv > /dev/null; then
for file in *.mp3
do avconv -i "${file}" "`echo ${file%.mp3}.ogg`";
done
else
echo "avconv not found"
fi
or a more simple version, without validation of avconv installation:
#!/bin/bash
for file in *.mp3
do avconv -i "${file}" "`echo ${file%.mp3}.ogg`";
done