[MEncoder-users] DVD >> MKV with mencoder script.

Martin Collins martin at mkcollins.org
Thu Jun 2 20:37:45 CEST 2005


On Thu, 2 Jun 2005 19:05:16 +0200
"Federico 'Pain' Pistono" <fppain at gmail.com> wrote:

> (1) Audio is not synchronized. 
> Creating an mkv file with
> mkvmerge -o $TITLE.mkv -A output.avi audio.ogg
> makes the audio to daly a bit, even in a few seconds.
> 
> If I make an OGM, the dealy is terrible playing with mplayer, but
> it's perfect with xine. (??????)

Firstly, make sure you have an up to date version of mkvtoolnix (and
ogmtools).
Secondly, try it without -hardframedrop.
Thirdly, you could try harddup and/or -mc 0 in the video encoding.
Rich may have some input on this.
Fourthly, if you can't get rid of the desync but it is constant you
can specify an audio delay with mkvmerge.

> (2) What's the easiest way to grab the crop and inset into the
> script without making the person do the job before running the
> script?

RC is the expert on this. Here's his script:

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 MEncoder-users mailing list