Quantcast FFmpeg: Need a Good Script for Mencoder - digitalFAQ.com Forums [Archives]
  #1  
04-12-2004, 06:25 AM
sertinell sertinell is offline
Free Member
 
Join Date: Jul 2003
Location: spain
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Hello

I'm a newbabe in linux and I don't understand the english forum full.

I have opened a post in spanish forum about mencoder.
http://www.kvcd.net/forum/viewtopic.php?p=72937

I'm trying this script
Code:
#!/bin/bash
#
# Copyright (C) 2003-2038 russiansexpat
#
# script:       mpeg(1,2,3,4) conversion to (S,X)VCD with quantisation matrix
#               and auto-splitting into multiple CDs and writing them.
#
# requires:     mencoder(1.0pre3) mplayer mplex vcdimager cdrdao
# optional:     normalize toolame(0.2k)
#
# does not require: microsoft. This script has not been tested on animals.
#
# version 0.3
#
# Changeslog
#
# - Added subtitle suport (Alexandre Possebom(otzi))
#

for exe in mencoder mplayer mplex vcdim
ager cdrdao; do
   if [ -z "`which $exe`" ]; then
      echo "ERROR: $exe must be in your path $PATH"
      exit 1
   fi
done

MATRIX="\
intra_matrix=\
8,9,12,22,26,27,29,34,\
9,10,14,26,27,29,34,37,\
12,14,18,27,29,34,37,38,\
22,26,27,31,36,37,38,40,\
26,27,29,36,39,38,40,48,\
27,29,34,37,38,40,48,58,\
29,34,37,38,40,48,58,69,\
34,37,38,40,48,58,69,79:\
inter_matrix=\
16,18,20,22,24,26,28,30,\
18,20,22,24,26,28,30,32,\
20,22,24,26,28,30,32,34,\
22,24,26,30,32,32,34,36,\
24,26,28,32,34,34,36,38,\
26,28,30,32,34,36,38,40,\
28,30,32,34,36,38,42,42,\
30,32,34,36,38,40,42,44\
"

Q="6" # constant video quality
      # best=2 excellent<=4 good<=7 even=11 for mpeg1  VCD resolution
      #        excellent<=6 good<=9 even=13 for mpeg2 SVCD resolution

#---------- below you can edit parameters ----------

# audio bitrate
AUDIORATE=112 # constant
#AUDIORATE=384 # variable with frequency 48kHz in 112-384kbs band

# frame rate conversion (has to be first in processing chain)
#FRC="-fps 29.97 -ofps 29.97 -vf telecine,lavcdeint," # example to increase fps
#FRC="-fps 29.97 -ofps 29.97 -vf "                    # NTSC
FRC="-fps 25 -ofps 25 -vf "                          # PAL
#FRC="-fps 23.976 -ofps 23.976 -vf "                  # NTSC pulldowned
#FRC="-fps 29.97 -ofps 23.976 -vf filmdint=fast=3,"   # example to decrease fps
#FRC="-vf " # fps not changed

# video filters
#vfilter="pp=de,denoise3d,eq,"

# aspect view of output;
# it should be the same as aspect view of the source mpeg(1,2)
# or equal to width/length if source aspect undefined (example: avi, capture)
# and your player has to be capable to process chosen aspect
#
#ASPECT="1" # 1:1 where have you seen square TV ?!
ASPECT="1.3333" # 4:3 standard TV or monitor
#ASPECT="1.7777" # 16:9 wide screen TV
#ASPECT="1.85" # film academy flat
#ASPECT="2.35" # cinema scope

#crop="crop=320:240,"     # crop, cut out black bands
#expand="expand=320:240," # expand to match aspect view, black bands added

# for xvcd
#XY="352:240"
XY="352:576"
VCODEC=mpeg1video
VBuffer=376 # Kbits = 46*1024*8/1000
#MUXMODE="-f 2 -V -b 46"
#IMAMODE="-t vcd2"

# for svcd
#XY="480:480"
#XY="480:576"
#VCODEC=mpeg2video
#VBuffer=917 # Kbits = 112*1024*8/1000
MUXMODE="-f 5 -V -b 112"
#IMAMODE="-t svcd"

# scaling algorithm
#SWS=0 # fast bilinear
#SWS=2 # bicubic, for upscaling
SWS=9 # lanczos, quality

# macroblock decision algorithm
#MBD=0 # compare blocks, fast
#MBD=1 # fewest bits
MBD=2 # best rate distortion

# group of pictures length - the longer is better compression, but
# it relies on a player decoder and so resulting playback quality
GOP=25 # dvd pal gop <=15, ntsc <=18 but in practice gop can be longer

# various mencoder -lavcopts parameters
ulavcopts1=":vmax_b_frames=2:vb_strategy=1:vqblur=0.3:vqcomp=0.7:vrc_eq=tex"
ulavcopts2=":naq:lumi_mask=0.05:dark_mask=0.01:tcplx_mask=0.1:scplx_mask=0.1"
ulavcopts3=":preme=1:precmp=2:cmp=2:subcmp=2:mbcmp=2:predia=2:dia=2:trell:cbp"

PASS="single"
#PASS="1st 2nd"

# mencoder verbosity
#NOTverbose="2> /dev/null"
#NOTverbose="&> /dev/null"

#CDSIZE=735 # 74min CD
CDSIZE=795 # 80min CD
#CDSIZE=895 # 90min CD

# cdrdao parameters
CDOPT="--overburn --reload --eject"
CDDEV="--device 0,1,0" # SCSI id

# Subtitle settings
blur=4
subpos=75
textscale=4
outline=4
autoscale=2

#---------- above you can edit parameters ----------
FILE=$2
tmp=`echo $FILE | sed s/\....$//`
SUB=""
[ -f "${tmp}".sub ] && SUB="-sub ${tmp}.sub -subpos ${subpos} -subfont-autoscale ${autoscale} -subfont-outline ${outline} -subfont-text-scale
${textscale}"
[ -f "${tmp}".srt ] && SUB="-sub ${tmp}.srt -subpos ${subpos} -subfont-autoscale ${autoscale} -subfont-outline ${outline} -subfont-text-scale ${textscale}"
tmp=""



function usage() {
   echo
   echo "Usage:  $HOWCALLED <shrunk name> <file or mplayer source> [quality [$Q]]"
   echo
   echo "qualilty: best=2 excellent<=4 good<=7 even=11 - XVCD"
   echo "                 excellent<=6 good<=9 even=13 - SVCD"
   echo
   echo "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED."
   echo
exit 1
}

# command line parsing
HOWCALLED=`basename $0`
[ $# -lt 2 ] && usage

case $1 in
   -*)
      usage
   ;;
   *)
      NAME=$1
      shift 1
   ;;
esac

DIR="`pwd`"
FILE=$1
if [ "$1" == "`basename \"$1\"`" ]; then
   FILE="$DIR/$1"
fi
shift 1

if [ "$1"x != "x" ]; then
   Q=$1
   shift 1
fi
COMMAND_LINE_MENCODER=$*

# encoding
rm -f divx2pass.log
rm -f frameno.avi

for word in $PASS ; do
   MOVIE=$NAME.mpg
   [ "$word" == "single" ] && pass=""
   [ "$word" == "1st"  ] && pass=":vpass=1"
   [ "$word" == "1st"  ] && MOVIE="/dev/null"
   [ "$word" == "2nd"  ] && pass=":vpass=2"

   command="mencoder $SUB \
   -forceidx -srate 44100 -af resample=44100 \
   -lavdopts er=1:idct=0 $FRC${vfilter}${crop}${expand}scale=$XY -sws $SWS \
   -of mpeg -oac lavc -ovc lavc \
   -lavcopts acodec=mp2:abitrate=$AUDIORATE:aspect=$ASPECT:vcodec=$VCODEC:$MATRIX:idct=0:mbd=$MBD:vqscale=$Q:vrc_minrate=300:vrc_maxrate=2300:vrc_buf_size=$VBuffer:keyint=$GOP${ulavcopts1}${ulavcopts2}${ulavcopts3}$pass \
   $COMMAND_LINE_MENCODER $FILE -o $MOVIE"

   echo "$command $NOTverbose"
   eval "$command $NOTverbose"
done

echo -e "\nyou will wait :p\n"

if [ $AUDIORATE != 384 ]; then
   # fixed audio rate
   eval "mplayer -noframedrop -dumpvideo -dumpfile $NAME.mpv $MOVIE $NOTverbose "
   eval "mplayer -noframedrop -dumpaudio -dumpfile $NAME.mpa $MOVIE $NOTverbose "
else
   # re-encoding into variable audio rate
   eval "mplayer -noframedrop -srate 48000 -dumpvideo -dumpfile $NAME.mpv $MOVIE $NOTverbose"
   AUDIO=$NAME.wav
   ###rm -f $AUDIO
   ###mkfifo -m 660 $AUDIO
   eval "mplayer -noframedrop -vc dummy -vo null -ao pcm -waveheader -af resample=48000 -aofile $AUDIO $MOVIE $NOTverbose"
   eval "normalize -v --fractions $AUDIO" # normalize can't work from pipe
   command="cat $AUDIO | toolame -s 48 -m s -v -1 - $NAME.mpa"
   echo "$command"
   eval "$command"
fi

wait

#rm -f $MOVIE
#rm -f $AUDIO
# end of encoding

# multiplexing
#rm -f $NAME?.mpg
eval "mplex $MUXMODE -S $CDSIZE -o $NAME%d.mpg $NAME.mpv $NAME.mpa"
#rm -f $NAME.mpv $NAME.mpa

exit 0
# last line of this script
And I have this error:
Code:
$ ./ofkvcd.sh corte.avi
./ofkvcd.sh: line 21: syntax error near unexpected token `ager'
./ofkvcd.sh: line 21: `ager cdrdao; do'
Wath is the problem? Sorry I am rokkie in linux

If you are trying other script, give me it !!

Thanks from spain!!

P.S. excuse me for my bad english
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
04-14-2004, 06:27 AM
Peder Peder is offline
Free Member
 
Join Date: Feb 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
./ofkvcd.sh: line 21: syntax error near unexpected token `ager'
means : "There's an error on line 21 in the script ofkvcd.sh"
Your posted code says
Code:
for exe in mencoder mplayer mplex vcdim 
ager cdrdao; do
It should be
Code:
for exe in mencoder mplayer mplex vcdimager cdrdao; do
Reply With Quote
  #3  
04-14-2004, 11:17 AM
sertinell sertinell is offline
Free Member
 
Join Date: Jul 2003
Location: spain
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Ok Thanks
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
FFMPEG: My really good experience and settings with FFVFW marcellus Video Encoding and Conversion 37 02-09-2004 07:09 AM
FFMPEG: Do ffvfw and mencoder/ffmpeg give the same results? Razorblade2000 Video Encoding and Conversion 4 02-06-2004 04:23 PM
FFMPEG: Piping from Mencoder to FFmpeg ak47 Video Encoding and Conversion 7 01-04-2004 04:35 PM
FFMPEG: Mencoder/ffmpeg aspect-ratio tetra Video Encoding and Conversion 10 12-11-2003 11:19 AM
FFMPEG: New script encode2kvcd using ffmpeg/mencoder el_mozo Video Encoding and Conversion 4 11-27-2003 07:25 AM

Thread Tools



 
All times are GMT -5. The time now is 01:42 PM  —  vBulletin © Jelsoft Enterprises Ltd