Posts Tagged ‘wav’

Suse 11.1 bash script to convert files mp4 to mp3

Monday, January 3rd, 2011

Find below script that converts MP4 files into MP3 :

Using mplayer and lameĀ :


#! /bin/bash
#
# Converts all MP4 files in the current directory to MP3s.
#
for f in *.mp4; do
newname=`echo $f | tr ' ' '_' `
mv "$f" $newname
f=$newname
mplayer $f -ao pcm:file=tmp.wav
lame -b 128 -q 2 tmp.wav ${f/.mp4/.mp3}
rm -f tmp.wav
done

Source page is here.

Batch converting audio files :

Sunday, May 16th, 2010

This script may be of interest and value :

File: convertomp3
#!/bin/bash
#
# Usage: convertomp3 fileextention
#
if [ $1 = "" ];then
  echo 'Please give a audio file extention as argument.'
  exit 1
fi

for i in *.$1
do
  if [ -f "$i" ]; then
  rm -f "$i.wav"
  mkfifo "$i.wav"
  mplayer \
   -quiet \
   -vo null \
   -vc dummy \
   -af volume=0,resample=44100:0:1 \
   -ao pcm:waveheader:file="$i.wav" "$i" &
  dest=`echo "$i"|sed -e "s/$1$/mp3/"`
  lame -V0 -h -b 160 --vbr-new "$i.wav" "$dest"
  rm -f "$i.wav"
fi
done

Running convertomp3 wma will covert every .wma file in the current folder to .mp3.