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?
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.kbpsand 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.m3uand 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
