Archive for January, 2015

Bulk extract MP3 from MKV

Because I always spend too much time on finding this script and some computers I have I cannot really update ffmpeg anymore, here is a conversion method using an old mplayer & lame I thought I would share;

  1. #!/usr/bin/perl
  2.  
  3. @x = `find .|grep mkv\$`;
  4. print `mkdir encdir`;
  5. foreach(@x) {
  6. chomp;
  7. $f = $_;
  8. /.*\/(.*).mkv/;
  9. print "$1\n";
  10. $wav = "encdir/$1.wav";
  11. $mp3 = "encdir/$1.mp3";
  12. next if -f $mp3;
  13. $mplayer = "mplayer -vc dummy -vo null -ao pcm:file=\"$wav\",fast \"$f\"";
  14. print `$mplayer`;
  15. $lame = "lame -h -b128 \"$wav\" \"$mp3\"";
  16. print `$lame`;
  17. print `rm "$wav"`;
  18. }