I just want to convert all the 320kbps in my WALKMAN to 128kbps since they are heavy. Of course, converting all 8GB would be so long, as a .5GB 320kbps album would take half an hour in here. I can wait for 6 hours to convert 3GB, but I can't wait for all 8GB to convert from 128kbps to 128kbps, since the 5GB in it is in 128kbps already. So the question here is how to I force Ubuntu to convert ONLY 320kbps files in my WALKMAN?
-
How are you doing it now? What apps do you use? Is it in the graphical environment or command line? – RobertL Oct 28 '15 at 02:31
-
@RobertL I haven't tried it like I mentioned above, since I can't wait 5 days for 8GB of mp3s to be converted. I think I'll use soundconverter for this, however I don't know how to make the app ONLY converts high quality mp3s or what app do that. – diamondburned Oct 28 '15 at 02:33
1 Answers
Here's a way to find all of your mp3 files which are over your specified bitrate and convert them to a lower bitrate. Be sure to read all the way to the end before starting, because there are two options for the actual transcoding: Clementine or script.
You'll need to install some packages:
sudo aptitude install mp3info clementine lame gawk findutils
To make a list of all your music files and their bitrates, execute the following after you replace /path/to/your/music appropriately:
find /path/to/your/music -iname '*.mp3' -print0 | xargs -0 mp3info -rm -p '%r:%F\n' > transcode.kbps
Look at the file
transcode.kbps
and make sure it looks something like this (bitrate:filename):128:/path/to/your/music/dir1/file.mp3 256:/path/to/your/music/dirX/fileX.mp3 320:/path/to/your/music/dirY/fileA.mp3
When that looks good execute this awk command, to create a playlist containing only the files higher than a specified bitrate (here all files with bitrate > 160 will be put into the m3u playlist):
awk -F: '$1 > 160 { print $2; }' transcode.kbps > transcode.m3u
Check the file
transcode.m3u
and make sure it looks OK. When it's good, your ready to transcode!
Clementine Transcode Solution
- On the Playlist menu, select "Load Playlist" and open transcode.m3u.
- Click in the list of your files and type CTRL-A to select all files in the playlist.
- Right-click on the playlist and select the context-menu item "Add file(s) to transcoder."
- Set your desired parameters in the Transcoder window, remember to set the options. Probably you want something like "Optimize for bitrate 128kbps, constant bitrate, standard quality".
- Click "Start Transcoding"
Wait for your transcoding to finish.
The main problem with using Clementine at least on Ubuntu 10.04 Trusty with Clementine 1.2, the only option is to create a new file alongside the old file. I think if you have a music player connected, Clementine would let you transcode directly to the music player.
Since the files you want to convert are already on the music player, that presents a problem, because the new files may fill up your player.
Script Transcode Solution
It's a fairly trivial script to process the transcode.m3u
with lame
to transcode the files and remove the old files as it goes. Save this into a file named transcode.sh
:
#!/bin/sh -e
# transcode.sh -- read filenames from standard input and transcode files
while read file
do
if lame -h "$file" "$file.new"
then
mv "$file.new" "$file"
else
rm -f "$file.new"
fi
done
Now you can execute:
sh transcode.sh < transcode.m3u
and the script will transcode all the files, deleting the old file each time after the new one is successfully created by lame.
You can edit the lame command parameters in the transcode.sh script to do any other transcoding parameters you like.

- 224
-
I can't install it. Installing
awks
gives an option to installmawk
gawk
ororiginal-awk
. Any idea? I'm usingapt-get
instead ofaptitude
. If I useaptitude
it will remove some of my apps and games :) – diamondburned Oct 28 '15 at 06:49 -
Also any ways to find in all folders? I got my musics in seperated folders (for example
/Artist1/Album1/song1.mp3
and/Artist1/Album2/song3.mp3
) – diamondburned Oct 28 '15 at 06:54 -
This is a simple
awk
script so any should work. I've gotgawk
, so probably best to go withgawk
.apt-get
andaptitude
should be the same as far as finding packages. – RobertL Oct 28 '15 at 06:54 -
If you use /Artist1 as the
/path/to/your/music
it will find the songs for all Albums under /Artist1. It traverses all the way down to find all the mp3 files in all the subdirectories. Run the find/mp3info pipeline as many times as you want to see how it works, the only thing it changes is the output text file. Also, if necessary,find
takes any number of directories as the initial arguments. But your directory will probably be something more like/media/xxxx-xxx/
to get to your walkman, right? – RobertL Oct 28 '15 at 07:01 -
/media/diamond/WALKMAN/
to be exact. Can you explain more? Like doingawk
would work but can you explain it step by step again? Do I just need to use the path/media/diamond/WALKMAN/music/
? – diamondburned Oct 28 '15 at 07:13 -
-