[Home]MplayerProbe

Showing revision 36

mplayerprobe.sh

 #!/bin/sh
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # Name: mplayerprobe.sh
 #
 # Script takes filename as argument, returns transcode
 # -g, -f, and --import_asr options ready to paste.
 #
 # Author: Phil Ehrens <phil@slug.org>
 #
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ##
 # run mplayer in -identify mode and capture output
 ##
  foo=`mplayer -identify -frames 0 -vo null -ao null\
              $1 2>/dev/null | grep =[1-9]`
 eval "$foo";
 ##
 # Parse results
 ## 
 geometry=${ID_VIDEO_WIDTH}x$ID_VIDEO_HEIGHT;
 asr=0;
 framerate=$ID_VIDEO_FPS;
 index=0;
 [ $framerate = 23.976 ] && index=1;
 [ $framerate = 25     ] && index=3;
 [ $framerate = 29.970 ] && index=4;
 ##
 # Use "bc" to calculate likely asr
 ##
asr=`bc -l << _EOF
define asr(w,h) {
if (w/h >= 2.0) return (4);
if (w/h >= 1.6) return (3);
if (w/h >= 0.0) return (2);
}
asr($ID_VIDEO_WIDTH,$ID_VIDEO_HEIGHT)
_EOF
`
 ##
 # Report geometry, aspect ratio, and framerate in format
 # usble in a transcode invocation.
 ## 
 echo "-g $geometry --import_asr $asr -f $framerate,$index"

fortyeightk.sh

 #!/bin/sh
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # Name: fortyeightk.sh
 #
 # Emits an audiodump.wav file suitable for
 # processing by transcode no matter WHAT you
 # feed it!
 #
 # Usage:
 #          -p audiodump.wav
 #          -x mplayer,raw
 #          -y ffmpeg
 #          -m $file.ac3
 # 
 # Author Phil Ehrens <phil@slug.org>
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 mplayer -ao pcm \
         -vo null \
         -vc dummy \
         $1 > /dev/null 2>&1
 #
 # if the sound turns out to be 8 bit, then sox
 # needs extra options to handle it correctly.
 # thanks to Kenneth Stailey for this patch!
 #
 file audiodump.wav | grep -qs 'PCM, 8 bit'
 if [ $? = 0 ]; then
    B=-b
    W=-w
 else
    B=
    W=
 fi
 #
 # If the samplerate is already 48k, sox will
 # drop a 44 byte stub output.wav file.
 #
 if sox $B audiodump.wav -r 48000 $W output.wav resample ; then
    mv -f output.wav audiodump.wav
 else
    rm -f output.wav
 fi

Transcode Wiki | Recent Changes | Preferences
Password required to edit | View other revisions | View current revision
Edited July 17, 2007 7:11 pm by tarazed.ligo.caltech.edu (diff)
Search: