سؤال

I am in the situation described in http://nerdbynature.de/s9y/?316. I have a file

$ file foo.mp3
foo.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer II, v1, 192 kbps, 44.1 kHz, Stereo

and I want to turn layer II to layer III and as well ID3 version 2.3.0 to ID3 version 2.4.0. For a single file, the described way works just perfect.

$ mv foo.{mp3,mp2}
$ lame --mp2input foo.mp2 foo.mp3
$ mid3iconv -d foo.mp3
$ rm foo.mp2
$ file foo.mp3
foo.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo
  1. How do I now write a (preferably shell) script that runs recursively through a huge folder containing music, and check each file. If it uses layer II, turn this into layer III using lame, and if it uses ID3 version 2.3.0, turn this into ID3 version 2.4.0 using mid3iconv.

  2. Also, how do I assure that I am not loosing quality (I see above that the input was 192kbps while the output is only 128kbps.

هل كانت مفيدة؟

المحلول

This should get you started

find -name '*.mp3' | while read ip
do
  file "$ip" | grep -q '2.4.0.*III' && continue
  ib=${ip%.*}
  ffmpeg -i "$ip" -q:a 0 "$ib"-iii.mp3
done
  • Noticed I have not used -print0, might be a good idea.

  • -q:a 0 will maintain the quality.

  • FFmpeg defaults to Layer III codec when you use output extension .mp3

  • FFmpeg writes 2.4.0 metadata by default

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top