0

Problem: I have some mp3 files that take up way too much space. These mp3 files happen to be voice recordings, so they can be reduced in file size without a noticeable loss in quality.

Specific asks:

  1. Find current sample rate of mp3
  2. Find the lowest bitrate where voice recordings sound acceptable at
  3. Convert current files to the revised bit rate (many files at once)
  4. Do all this via the command line for ease

Note: Current OS = Ubuntu 16.04

izk9
  • 131

1 Answers1

2

After doing a good deal of digging, I found the answers and decided to post here to consolidate for others.

Answer 1. Find current sample rate of mp3

cd 

To where the mp3 file is. Then type

file song.mp3

Replace "song .mp3" with the name of your file. This is based on the helpful answer here.

Answer 2. Find the lowest bitrate where voice recordings sound acceptable at

Both 64 and 32 worked for me. Since the mission here was to limit size, I went with 32 (here is a more indepth discussion on the topic).

To test which bit rate works best for you, run

avconv -i song.mp3 -c:a libmp3lame -b:a 64k test.mp3

Then play the test.mp3 file and see if you like it. Change the "64k" to different values to get different bit rates. For example change it to "128k" if you would like a higher quality but larger sized mp3.

Answer 3. Convert current files to the revised bit rate (many files at once)

Again make sure you have navigated in the terminal to the folder where you would like to change the files. Then run:

for f in ./*.mp3; do avconv -i "$f" -c:a libmp3lame -b:a 32k "${f%.*}-out.mp3"; done

You can specifcy any naming convention for the output file by modifying the "${f%.*}-out.mp3". This great code was provided from this answer. Visit it to see a more in depth answer for how you can a) preserve the original names and b) how you could run on an entire file directory.

izk9
  • 131