Monday, December 24, 2007

'WAVing' Your Videos

A friend asked tonight if I knew how to strip out the audio from videos, for conversion to things like .ogg and .mp3 formats. This is one of those things I remember doing, but not the details, so below is a script for creating a .wav file for each video .avi file in a directory. Just look up the parameters in man mplayer for a detailed explination.

--

#!/bin/bash

# Script to extract .wav audios from .avi files # 04 Sept. 2007 d.e.l.

USAGE="$0 [-h]"

shopt -q nocasematch # - this seems to be inoperative

# if [[ '-h' = ${1:0:2} ]] # then # echo ${USAGE} # exit # fi

case ${1:0:2} in -h | -H | -? | /h | /H | /? ) echo ${USAGE} exit ;; -- ) case ${1:2:1} in h | H | ? ) echo ${USAGE} exit ;; * ) esac ;; * ) esac

set -o braceexpand ;

aviconvert () {

PATIENT=${1} ; CURED="${1%.avi}.wav" ; echo "Converting: ${PATIENT}" ; #\mplayer -ao pcm:waveheader:fast:file=charley1.wav -vc null -vo null \ # charly.01.avi

nice -20 \ /usr/bin/mplayer \ -ao pcm:waveheader:fast:file=${CURED} \ -vc null -vo null \ ${PATIENT}

return ;

}

for i in *.avi do

aviconvert ${i} ;

done ; # for

Addenda 30 Dec. 2007

I located this article I'd seen before after a bit of surfing:

http://www.linuxjournal.com/article/9719

which gives what might be considered an intermediate action, conversion to Black and White. Example from the above link:

$mencoder color-video.avi -o black-white-video.avi -vf hue=0:0 -oac copy -ovc lavc

The only problem I noticed was that the final video froze up on playback unless I turned any mplayer.conf video filtering off, but then my computer is somewhat marginal for playing videos to begin with. Besides the Ansel Adams/film noir effect a test on a random video reduced it to 20% of it's original size. I'm unaware of any "LSD/light show" filter that drops the chiaroscuro and spatial forms and keeps the colors. ;-)

1 comment:

Anonymous said...

Awesome!

Thanks for putting it online. That will let it get more exposure etc. :)