[MPlayer-users] cropdetect accuracy with mplayer-1.0pre6a

RC rcooley at spamcop.net
Fri Feb 18 20:57:22 CET 2005


On Thu, 17 Feb 2005 16:29:53 -0800
Yan Seiner <yan at seiner.com> wrote:

> My one other (so far unarticulated)
> gripe about cropdetect is that it should skip through the movie - say
> 30 frames at a time - and cumulatively pick the smallest crop window
> it encounters.  It would be nice if it did this in a script-friendly
> fasion(sorry if this has been implemented)....

Because I kept occasionally getting bad crop parameters, I wrote a
script to do exactly that.  I've used it on literally thousands of
videos at this point, so if it doesn't work, make sure it isn't a
line-wrap problem.  This is part of a larger script, so you'll have to
set a couple values manually...

SOURCE="Video.avi"
# CHAPTER="-chapter 2"  # when source is "dvd://1"
CROP="1"
TOTAL_LOOPS="15"
VF_OPTS="ivtc=1,pp=lb"

if [ "$CROP" == "1" ]; then
  echo "Please wait.  It make take a couple minutes to detect crop
parameters."  
  A=0
  while [ "$A" -lt "$TOTAL_LOOPS" ] ; do
    A="$(( $A + 1 ))"
    SKIP_SECS="$(( 30 * $A ))"
  
    nice -n $NICE_PRI nohup mplayer "$SOURCE" $CHAPTER -ss $SKIP_SECS \
     -identify -frames 20 -vo md5sum -ao null \
     -vf ${VF_OPTS}cropdetect=20:16  2>&1 > mplayer.log < /dev/null

# echo "DEBUG INFO" ; cat mplayer.log
  
    CROP[$A]=`awk -F 'crop=' '/crop/ {print $2}' < mplayer.log\
     | awk -F ')' '{print $1}' | tail -n 1`

    SOURCE_AUDIORATE=`awk -F '=' '/ID_AUDIO_BITRATE/ \
      {print $2}'< mplayer.log`

  done
  rm md5sums mplayer.log 

  B=0
  while [ "$B" -lt "$TOTAL_LOOPS" ] ; do
    B="$(( $B + 1 ))"
  
    C=0
    while [ "$C" -lt "$TOTAL_LOOPS" ] ; do
      C="$(( $C + 1 ))"
  
      if [ "${CROP[$B]}" == "${CROP[$C]}" ] ; then
        COUNT_CROP[$B]="$(( ${COUNT_CROP[$B]} + 1 ))"
      fi
    done  
  done
  
  HIGHEST_COUNT=0
  
  D=0
  while [ "$D" -lt "$TOTAL_LOOPS" ] ; do
     D="$(( $D + 1 ))"
  
       if [ "${COUNT_CROP[$D]}" -gt "$HIGHEST_COUNT" ] ; then
         HIGHEST_COUNT="${COUNT_CROP[$D]}"
         GREATEST="$D"
       fi
  done
  
  CROP="crop=${CROP[$GREATEST]}"
  
  echo -e "\n\n\nCrop Setting is: $CROP ... \n\n" 
fi




More information about the MPlayer-users mailing list