All pastes #553398 Raw Edit

to_mpg.sh

public text v1 · immutable
·published 2007-06-09 18:25 UTC
rendered paste body
#!/bin/sh
DEFBITRATE=1150
#if the first argument is an integer, then it is BITRATE 
x=$1 
case $x in 
*[!0-9]*)
#echo It is not an integer
;; *)
#echo It is an integer
DEFBITRATE=$1 
shift 
;; 
esac 

for ARG in "$@"; do
# check BITRATE from source (VMW doesn't have this info)
BITRATE=$DEFBITRATE aux=`mplayer -vo null -ao null -frames 0 -identify "$ARG" \
     2>/dev/null | grep -e ^VIDEO` 
if [ "`echo "$aux" | awk -F " " '{print $8}'`" = "kbps" ]; then
  aux1=`echo "$aux" | awk -F " " '{print $7}' | awk -F "." '{print $1}'`
  aux2=`echo "$aux" | awk -F " " '{print $7}' | awk -F "." '{print $2}'`
  if [ $aux1 -eq 0 ]; then
    aux1=$DEFBITRATE
  else
    BITRATE=$aux1
    if [ $aux2 -ge 5 ]; then BITRATE=`expr $BITRATE + 1`; fi
  fi 
fi 
nice -n 19 \ 
mencoder "$ARG" -of mpeg -o "${ARG}.mpg" -vf pp=de,harddup,softskip -ovc lavc -lavcopts vcodec=mpeg2video:vhq:vbitrate=$BITRATE:autoaspect -ofps 25.0 -oac mp3lame -lameopts br=128:q=9:aq=9:cbr:mode=1
done