Here is a script for automatically removing the last seconds of several mp3-files
Here is a script to automatically trim the last seconds of several mp3 files in Linux for the following scenario:
- In each file close to the end is a 1-2 sec break of silence and then about 7-12 secs of speaking. The silence and the speaking at the end should be removed.
- The tags of the original file should be kept.
- The shortened files shouldn't overwrite the existing ones but be saved to a new directory.
For splitting the mp3-files at the desired point mp3splt seems to be the best tool in the Linux world. Unfortunately has two shortcomings:
- No batch mode.
- The current version 2.1 has problems with keeping the tags of the original file. The second shortcoming is gone with version 2.2_rc1 which is available as installation file for several distros.
OK, here is the script
#!/bin/bashOne still unsolved problem is that mp3splt doesn't support a recent ID3 standard. This can result in shortened tag information. Theoretically another problem could happen with a mp3 file which has a longer break of silence in the middle than at the end. In this case you could try to modify the parameters for mp3splt (man mp3splt). However, I tried my script with several pieces of japanese zen-flute music with breaks in the middle and all were trimmed fine.
# Step 1: Split all mp3 files
for X in *.mp3
do
mp3splt -s -p nt=2,rm,min=1 "$X" -o "$X"_@n -d ./Shortened
done
# Step 2: Remove the unneeded ends of the original mp3 files
rm ./Shortened/*_2.mp3
UPDATE
I have used the script now for several hundred files and it worked with all of them. However, there is one album I once downloaded from Magnatune.com which for whatever reason resists to get circumcised. I played with several of mp3splts parameters - but no success. Hmm, I might decide to buy it... Otherwise I still could use Audacity...
Keine Kommentare:
Kommentar veröffentlichen