Quantcast KVCD Using Menkoder? - digitalFAQ.com Forums [Archives]
  #1  
12-02-2003, 07:17 AM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts


It is a template script, not interactive. If you are a developer (I'm a not) you can encapsulate into interactive script or GUI, gtk preferable.

In the script you have at least to chose resolution width*height, fps (if you change them), mpeg (1 or 2) and vcd type for multiplexing and imaging.
Video bitrate can be entered in commad line, so don't edit it.
Edit the section between dash lines. The script is capable to scale into NTSC/PAL dimensions if the source is fit - width is used as a base to scale (with original aspect ratio), so scaled height have to be within allowed height for NTSC or PAL.
It is assumed that you know xvcd and svcd specifications and familiar with mencoder options.

(I've just checked on a stream capture that telecine from 10fps to 27.97fps is bearable, but still the problems with video-audion sync. The same situation with inverse telecine from 27.97fps to 25fps).
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
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  
12-02-2003, 11:24 AM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
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 mplayer ffmpeg tcmplex vcdimager cdrdao

for exe in mencoder mplayer ffmpeg tcmplex vcdimager 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\
"

VBITRATE=1152 # 1 = 1000 bits

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

SWS=0 # fast bilinear
#SWS=2 # bicubic (for upscaling)
#SWS=9 # lanczos (quality? slow)

VFILTER="denoise3d,eq2,"

#FPS=",telecine,lavcdeint -fps 29.97 -ofps 29.97"
#FPS=" -ofps 29.97"  # NTSC
#FPS=" -ofps 25"     # PAL
#FPS=" -ofps 23.976" # NTSC pulldowned
#FPS=",ivtc=1 -ofps 23.976"
#FPS=" -ofps 10" # must for variable and progressive fps

# for vcd
WID=352
#HEI=240
HEI=288
VCODEC=mpeg1video
AUDIORATE=128
MUXMODE="-m 1 -F tcmplex.tmp"
IMAMODE="-t vcd2"

# for svcd
#WID=480
#HEI=480
#HEI=576
#VCODEC=mpeg2video
#AUDIORATE=224
#MUXMODE="-m s -F tcmplex.tmp"
#IMAMODE="-t svcd"

LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01"

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

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

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

CDOPT="--force --reload --eject"
CDDEV="--device 0,4,0"

#---------- above you can edit parameters ----------

function usage() {
   echo
   echo "Usage:  $HOWCALLED <shrunk name> <file or mplayer source> [variable video bitrate kbs [$VBITRATE]]"
   echo
   echo "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED."
   echo
exit 1
}

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
   VBITRATE=$1
   shift 1
fi

COMMAND_LINE_MENCODER=$*

rm -rf divx2pass.log
rm -rf frameno.avi

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

   command="mencoder -sws $SWS -vf ${VFILTER}scale=$WID:-3,expand=0:$HEI${FPS} \
   -forceidx -of mpeg -nosound \
   -ovc lavc -lavcopts vcodec=$VCODEC:$MATRIX:mbd=2:vbitrate=$VBITRATE:vrc_minrate=300:vrc_maxrate=2300:vrc_buf_size=320:keyint=25${LAVCOPTS}$pass \
   $COMMAND_LINE_MENCODER $FILE -o $VIDEO"

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

rm -rf $NAME.mpv
eval "mplayer -noframedrop -vc dummy -vo null -dumpvideo -dumpfile $NAME.mpv $VIDEO &> /dev/null &"

AUDIO="audio.wav"
rm -f $AUDIO
mkfifo -m 660 $AUDIO

eval "mplayer -noframedrop -vc dummy -vo null -ao pcm -waveheader -aofile $AUDIO $FILE &> /dev/null &"
eval "ffmpeg -y -i $AUDIO -ab $AUDIORATE -ar 44100 -ac 2 -f mp2 $NAME.mpa &"
#eval "lame -h --abr $AUDIORATE --resample 44.1 - $NAME.mpa < $AUDIO &"

wait

rm -f $VIDEO
rm -f $AUDIO

rm -f $NAME??.mpg
echo "maxFileSize = $CDSIZE" > tcmplex.tmp
eval "tcmplex $MUXMODE -i $NAME.mpv -p $NAME.mpa -o $NAME.mpg"
rm -f tcmplex.tmp

for i in $NAME??.mpg; do
   cue="`basename $i .mpg`.cue"
   bin="`basename $i .mpg`.bin"
   rm -f $cue $bin
   eval "vcdimager $IMAMODE -c $cue -b $bin $i"
done

echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n"

for cue in $NAME??.cue; do
   bin="`basename $cue .cue`.bin"
   echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:"
   read -n 1 null
   eval "cdrdao write $CDOPT $CDDEV $cue"
   echo "CD WRITING IS COMPLETED."
done

exit 0
# last line of this script
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #3  
12-05-2003, 02:33 AM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Scaling to correct VCD and SVCD aspects is not implemented in this script. There is useful page about video resolutions and aspect ratio conversions:
http://www.uwasa.fi/~f76998/video/conversion/
http://hkfanatic.com/widescreen/

Currently I use the script for pre- and post-processing for XVCD and SVCD.
If somebody can add scaling into the 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 mplayer ffmpeg tcmplex vcdimager cdrdao
#
# does not require: microsoft. This script has not been tested on animals.

for exe in mencoder mplayer ffmpeg tcmplex vcdimager 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\
"

VBITRATE=2300 # 1 = 1000 bits

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

#AUDIORATE=128
AUDIORATE=224

# see 'man mencoder'
LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01"
#

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

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

# for vcd
#VCODEC=mpeg1video
#MUXMODE="-m 1 -F tcmplex.tmp"
#IMAMODE="-t vcd2"

# for svcd
VCODEC=mpeg2video
MUXMODE="-m s -F tcmplex.tmp"
IMAMODE="-t svcd"

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

CDOPT="--force --reload --eject"
CDDEV="--device 0,4,0"

#---------- above you can edit parameters ----------

function usage() {
   echo
   echo "Usage:  $HOWCALLED <shrunk name> <file or mplayer source> [variable video bitrate kbs [$VBITRATE]]"
   echo
   echo "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED."
   echo
exit 1
}

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
   VBITRATE=$1
   shift 1
fi

COMMAND_LINE_MENCODER=$*

rm -rf divx2pass.log
rm -rf frameno.avi

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

   command="mencoder \
   -forceidx -of mpeg -nosound \
   -ovc lavc -lavcopts vcodec=$VCODEC:$MATRIX:mbd=2:vbitrate=$VBITRATE:vrc_minrate=300:vrc_maxrate=2300:vrc_buf_size=320:keyint=25${LAVCOPTS}$pass \
   $COMMAND_LINE_MENCODER $FILE -o $VIDEO"

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

rm -rf $NAME.mpv
eval "mplayer -noframedrop -vc dummy -vo null -dumpvideo -dumpfile $NAME.mpv $VIDEO &> /dev/null &"

AUDIO="audio.wav"
rm -f $AUDIO
mkfifo -m 660 $AUDIO

eval "mplayer -noframedrop -vc dummy -vo null -ao pcm -waveheader -aofile $AUDIO $FILE &> /dev/null &"
eval "ffmpeg -y -i $AUDIO -ab $AUDIORATE -ar 44100 -ac 2 -f mp2 $NAME.mpa &" 
#eval "lame -h --abr $AUDIORATE --resample 44.1 - $NAME.mpa < $AUDIO &"

wait

rm -f $VIDEO
rm -f $AUDIO 

rm -f $NAME??.mpg
echo "maxFileSize = $CDSIZE" > tcmplex.tmp
eval "tcmplex $MUXMODE -i $NAME.mpv -p $NAME.mpa -o $NAME.mpg"
rm -f tcmplex.tmp

for i in $NAME??.mpg; do 
   cue="`basename $i .mpg`.cue"
   bin="`basename $i .mpg`.bin"
   rm -f $cue $bin
   eval "vcdimager $IMAMODE -c $cue -b $bin $i"
done

echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n"

for cue in $NAME??.cue; do
   bin="`basename $cue .cue`.bin"
   echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:"
   read -n 1 null
   eval "cdrdao write $CDOPT $CDDEV $cue"
   echo "CD WRITING IS COMPLETED."
done

exit 0
# last line of this script
Just compared - two pass is slow 4 times compared to single pass, but it is still faster than using mpeg2enc form mjpegtools. Also, it appears that taking out video filters and scaling does not speed things up, i.e. most of the time spent by encoder itself. So, maybe to fall back to previous version with video filter, scaling and fps conversion?
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #4  
12-05-2003, 12:01 PM
Icarus3000 Icarus3000 is offline
Free Member
 
Join Date: Feb 2003
Posts: 258
Thanks: 0
Thanked 0 Times in 0 Posts
Russiansexpat:

You appear to be having an interesting discourse with yourself!

Can you or someone else explain what it is you are talking about?


Reply With Quote
  #5  
12-05-2003, 02:35 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Icarus3000
Russiansexpat:

You appear to be having an interesting discourse with yourself!
Not at all
This is an advanced topic, and very good information
This is related to Linux and Unix systems.

-kwag
Reply With Quote
  #6  
12-05-2003, 03:28 PM
Icarus3000 Icarus3000 is offline
Free Member
 
Join Date: Feb 2003
Posts: 258
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry, I guess this is just out of my league

I was just curious what he was talking about, as noone else was responding.
Reply With Quote
  #7  
12-05-2003, 04:09 PM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #8  
12-06-2003, 04:13 AM
Encoder Master Encoder Master is offline
Free Member
 
Join Date: Mar 2003
Location: (^_^)
Posts: 504
Thanks: 0
Thanked 0 Times in 0 Posts
Reply With Quote
  #9  
12-08-2003, 01:14 PM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by russiansexpat
two pass is slow 4 times compared to single pass, but it is still faster than using mpeg2enc form mjpegtools.
It doesn't have to be, a 2pass with mencoder/ffmpeg is about 1,5 slower than 1 pass, since you can use dev/null as output the first pass.
I use the following: (you need mplayer-cvs for this)
Code:
#!/bin/bash

keyint=24
scale="scale=352:240"
abitrate=112

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"

mencoder $1 -of mpeg -ovc lavc -oac lavc -lavcopts \
pass=1:acodec=mp2:abitrate=$abitrate:vcodec=mpeg1video:keyint=$keyint:mbd=2:vrc_minrate=64:vrc_maxrate=3000:vrc_buf_size=320:aspect=16/9:\
intra_matrix=$matrix:inter_matrix=$inter_matrix -vf $scale -o /dev/null
mencoder $1 -of mpeg -ovc lavc -oac lavc -lavcopts \
vpass=2:acodec=mp2:abitrate=$abitrate:vcodec=mpeg1video:keyint=$keyint:mbd=2:vrc_minrate=64:vrc_maxrate=3000:vrc_buf_size=320:aspect=16/9:\
intra_matrix=$matrix:inter_matrix=$inter_matrix -vf $scale -o divx2kvcd.mpg
Quote:
Originally Posted by russiansexpat
Also, it appears that taking out video filters and scaling does not speed things up, i.e. most of the time spent by encoder itself. So, maybe to fall back to previous version with video filter, scaling and fps conversion?
All you do will make encoding slower... (denoise the less and scaling the most)
__________________
Groetjes Japie
Reply With Quote
  #10  
12-08-2003, 03:51 PM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Below is a version of the script with constant quality encoding, and I put some comments in the code.
It appears to be faster and easy to use, just watch output line of mencoder - last field of this line is a current encoding bitrate, and also in this line you can see estimated time of completion and file size, so you can terminate the script if you don't like them.
Compression is improved, maybe because of ":naq:dia=2:last_pred=2" adaptive quantisation and motion prediction parameters. Currently I can fit 1.5 hour movie at SVCD resolution with vbitrate around 1200 kbps into single CD. Constant quality is less than 6.
(some minor problem with maxrate - when you select high quality, the maxrate is exceeded; nevertheless tcmplex clipped bitrates to 2300 max and vcdimager didn't complain.)

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 mplayer ffmpeg tcmplex vcdimager cdrdao
#
# does not require: microsoft. This script has not been tested on animals.

for exe in mencoder mplayer ffmpeg tcmplex vcdimager 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 XVCD
      #        excellent<=6 good<=9 even=13 for SVCD

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

# audio bitrate
AUDIORATE=128
#AUDIORATE=224

# scaling algorithm
#SWS=0 # fast bilinear
SWS=2 # bicubic (for upscaling)
#SWS=9 # lanczos (quality? slow)

# video filters
VFILTER="pp=de,denoise3d,"

# for frame rate conversions
#FPS=",telecine,lavcdeint -fps 29.97 -ofps 29.97" # to increase fps
#FPS=" -ofps 29.97"  # NTSC
#FPS=" -ofps 25"     # PAL
#FPS=" -ofps 23.976" # NTSC pulldowned
#FPS=",ivtc=1 -ofps 23.976" # to decrease fps

# 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

# for xvcd
#XY="352:240"
#XY="352:288"
#VCODEC=mpeg1video
#MUXMODE="-m 1 -F tcmplex.tmp"
#IMAMODE="-t vcd2"

# for svcd
#XY="480:480"
XY="480:576"
VCODEC=mpeg2video
MUXMODE="-m s -F tcmplex.tmp"
IMAMODE="-t svcd" 

# see 'man mencoder'
LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01:naq:dia=2:last_pred=2"
#

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="--force --reload --eject"
CDDEV="--device 0,4,0" # SCSI id

#---------- above you can edit parameters ----------

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
}

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=$*

rm -rf divx2pass.log
rm -rf frameno.avi

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

   command="mencoder -sws $SWS -vf ${VFILTER}scale=$XY${FPS} \
   -forceidx -of mpeg -nosound \
   -ovc lavc -lavcopts aspect=$ASPECT:vcodec=$VCODEC:$MATRIX:mbd=2:vqscale=$Q:vrc_minrate=300:vrc_maxrate=2300:vrc_buf_size=320:keyint=25${LAVCOPTS}$pass \
   $COMMAND_LINE_MENCODER $FILE -o $VIDEO"

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

rm -rf $NAME.mpv
eval "mplayer -noframedrop -vc dummy -vo null -dumpvideo -dumpfile $NAME.mpv $VIDEO &> /dev/null &"

AUDIO="audio.wav"
rm -f $AUDIO
mkfifo -m 660 $AUDIO

eval "mplayer -noframedrop -vc dummy -vo null -ao pcm -waveheader -aofile $AUDIO $FILE &> /dev/null &"
eval "ffmpeg -y -i $AUDIO -ab $AUDIORATE -ar 44100 -ac 2 -f mp2 $NAME.mpa &" 
#eval "lame -h --abr $AUDIORATE --resample 44.1 - $NAME.mpa < $AUDIO &"

wait

rm -f $VIDEO
rm -f $AUDIO 

rm -f $NAME??.mpg
echo "maxFileSize = $CDSIZE" > tcmplex.tmp
eval "tcmplex $MUXMODE -i $NAME.mpv -p $NAME.mpa -o $NAME.mpg"
rm -f tcmplex.tmp

for i in $NAME??.mpg; do 
   cue="`basename $i .mpg`.cue"
   bin="`basename $i .mpg`.bin"
   rm -f $cue $bin
   eval "vcdimager $IMAMODE -c $cue -b $bin $i"
done

echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n"

for cue in $NAME??.cue; do
   bin="`basename $cue .cue`.bin"
   echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:"
   read -n 1 null
   eval "cdrdao write $CDOPT $CDDEV $cue"
   echo "CD WRITING IS COMPLETED."
done

exit 0
# last line of this script
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #11  
12-09-2003, 06:32 AM
neturmel neturmel is offline
Free Member
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
That is a really nice thread, got some ideas. But to give you something back, here some thoughts:

if you use mplayer-cvs you can do it like japie wroteabove: audio encoding directly with mencoder, but can using a three pass method, in which you only encode audio once and get a prediction in the end of the first pass, which gives you an estimation of the bitrate one should use for video encoding.

This can be used for setting the vbitrate automatically (as this estimation isn't meant for kvcds, it probably must be trimmed somewhat).

Also, you can use cropdetect and crop to get rid of the black bands and the scale and expand to have your aspect ratio correct.

So here are my modifications of the vbr script for trying yourself:

Code:
#!/bin/bash
#
# Copyright (C) 2003-2038 russiansexpat
# Three pass encoding by neturmel (C) 2003
#
# 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 mplayer ffmpeg tcmplex vcdimager cdrdao

for exe in mencoder mplayer ffmpeg tcmplex vcdimager 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\
"

VBITRATE=1152 # 1 = 1000 bits

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

SWS=0 # fast bilinear
#SWS=2 # bicubic (for upscaling)
#SWS=9 # lanczos (quality? slow)

# Some possible filters
VFILTER="pp=de,denoise3d,"
#VFILTER="denoise3d,eq2,"
#VFILTER="noise=luma[h]:chroma[h],hqdn3d=4:3:6,"

# some LAVCOPTS
#LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01"
LAVCOPTS="mbd=2:vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01:naq:dia=2:last_pred=2"
#LAVCOPTS="mbd=2:mv0:trell:cbp:precmp=2:cmp=2:subcmp=2:predia=2:dia=2:preme=2:vme=5:naq"

#FPS=",telecine,lavcdeint -fps 29.97 -ofps 29.97"
#FPS=" -ofps 29.97"  # NTSC
#FPS=" -ofps 25"     # PAL
#FPS=" -ofps 23.976" # NTSC pulldowned
#FPS=",ivtc=1 -ofps 23.976"
#FPS=" -ofps 10" # must for variable and progressive fps

# for vcd
WID=352
#HEI=240
HEI=288
VCODEC=mpeg1video
AUDIORATE=128
MUXMODE="-m 1 -F tcmplex.tmp"
IMAMODE="-t vcd2"

# for svcd
#WID=480
#HEI=480
#HEI=576
#VCODEC=mpeg2video
#AUDIORATE=224
#MUXMODE="-m s -F tcmplex.tmp"
#IMAMODE="-t svcd"

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

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

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

CDOPT="--force --reload"
CDDEV="--device 0,0,0"

#---------- above you can edit parameters ----------

function usage() {
   echo
   echo "Usage:  $HOWCALLED <shrunk name> <file or mplayer source> [variable video bitrate kbs [$VBITRATE]]"
   echo
   echo "result: (S,X)VCD and mpeg(1,2) encoded with $HOWCALLED."
   echo
exit 1
}

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
   VBITRATE=$1
   shift 1
fi

COMMAND_LINE_MENCODER=$*

rm -rf divx2pass.log
#rm -rf frameno.avi

# First Pass, Audio
# If we had encoded audio in an earlier try, we won't do it again
# (then we must provide a vbitrate on command line)
if [ ! -f frameno.avi ]
then
  command="mencoder -ovc frameno -oac lavc -lavcopts acodec=mp2:abitrate=128 -o frameno.avi $FILE | tee /tmp/encode.$$"
  echo "$command $NOTverbose"
  eval "$command $NOTverbose"
  # Set the bitrate from estimation, heuristic: use bitrate for 650MB CD even if we use 700MB
  # here is a place for experiments!
  VBITRATE=`tail -n 10 /tmp/encode.$$ | grep "for 650MB CD" | awk -F ":" '/^/{print $2}' | sed '/\ /s///g'`
  rm -f /tmp/encode.$$
else
  echo "existing frameno.avi found!"
fi

# Crop Detection
mencoder -vf cropdetect,scale=$WID:-3,expand=-1:$HEI:-1:-1:1 -oac copy  -ovc lavc  "$FILE" -frames 50 > /tmp/f
CROP=`cat /tmp/f |grep vf | tail -n 1 | cut -d "=" -f 2 | tr -d ')'`

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

   if [ "$word" == "1st" ]
   then
     # vqscale=2 in first pass should give a better estimation for the second pass
     # which uses vbitrate
     command="mencoder -sws $SWS -vf ${VFILTER}crop=$CROP,scale=$WID:-3,expand=-1:$HEI:-1:-1:1  \
     -of mpeg -oac copy \
     -ovc lavc -lavcopts vcodec=$VCODEC:$MATRIX:vqscale=2:vrc_minrate=64:vrc_maxrate=2300:vrc_buf_size=320:keyint=25:${LAVCOPTS}$pass \
     $COMMAND_LINE_MENCODER $FILE -o $VIDEO"
   else
     command="mencoder -sws $SWS -vf ${VFILTER}crop=$CROP,scale=$WID:-3,expand=-1:$HEI:-1:-1:1  \
     -of mpeg -oac copy \
     -ovc lavc -lavcopts vcodec=$VCODEC:$MATRIX:vbitrate=$VBITRATE:vrc_minrate=64:\
vrc_maxrate=2300:vrc_buf_size=320:keyint=25:${LAVCOPTS}$pass \
     $COMMAND_LINE_MENCODER $FILE -o $VIDEO"
   fi
   echo "$command $NOTverbose"
   eval "$command $NOTverbose"
done

mv $VIDEO $NAME.mpg

for i in $NAME.mpg; do
   cue="`basename $i .mpg`.cue"
   bin="`basename $i .mpg`.bin"
   rm -f $cue $bin
   eval "vcdimager $IMAMODE -c $cue -b $bin $i"
done

echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n"

for cue in $NAME.cue; do
   bin="`basename $cue .cue`.bin"
   echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:"
   read -n 1 null
   eval "cdrdao write $CDOPT $CDDEV $cue"
   echo "CD WRITING IS COMPLETED."
done

exit 0
# last line of this script
This is not heavily tested, but should be used as a starting point for further tuning.

Have Fun with KVCD in Linux!

Greetings,

Neturmel
Reply With Quote
  #12  
12-10-2003, 06:46 AM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
crop=$CROP,scale=$WID:-3,expand=-1:$HEI:-1:-1:1
are you sure about expand parameters? you did not center and also render osd.
cropdetect is nice to have, but you looking only into for first 50 frames.
For ppl who wants to automate something in this cript,
try use http://mpgtx.sourceforge.net and tcscan for transcode to get inormation about the source.
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #13  
12-10-2003, 09:07 AM
neturmel neturmel is offline
Free Member
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,


in my case, expand just adds enough black bands (below and above the movie) to keep the original aspect ratio of the movie without the need for the player to get its aspect correct by itself (infamous "feature" of the windows media player). But honestly, that was only added by trial and error and by verifying the result on different hard- and software players.

So it is possible that it is utterly useless for anyone else...

Cropdetect on only 50 frames is no problem if you only encode the main movie. If there are trailers or menus etc. , you certainly should use more frames. Otherwise, the bands really shouldn't change in the main movie.

But if you really want to be sure that your crop parameters are correct, just do it for 10min of movie ( would be at most 30*60*10= 18000 frames )

2) By coincidence, I just started to test mpgtx myself (for splitting movies longer than the size of the CD before burning). Works well for mpeg1, but not for mpeg2.

P.S.: Since I make KVCDs out of VDR-Recordings, I have found vdrsync.pl (http://vdrsync.vdr-portal.de) for remultiplexing and joining of cutted VDR material extremely useful (also uses parts of transcode)

Hope that others won't find this just boring...

neturmel
Reply With Quote
  #14  
12-10-2003, 09:17 AM
neturmel neturmel is offline
Free Member
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Another hint:

it really seems that by using 2-pass encoding and vqscale=2 in the first pass,
you really hit your vbitrate value for the second pass pretty perfect, so it
should be possible to use the predicted bitrate for the planned CD size which
was printed in the first (audio encoding) pass, see above.

But have to test a little bit further...

Greetings,

neturmel
Reply With Quote
  #15  
12-10-2003, 12:16 PM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
"The audio stream must be MPEG-1 layer II, with a bit-rate ranging
from 32 to 384 kbits/sec bit-rate (i.e. the audio stream _is_ allowed
to be VBR!) with up to 2 stereo or 4 mono channels, or 1 extended
MPEG-1/2 multichannel (5+1) surround sound stream." --
http://www.vcdimager.org/pub/vcdimag.../vcdimager.txt

Thus the script now uses toolame for audio encoding,
http://mikecheng.d2.net.au/
also toolame can encode joint stereo and use diffrent acoustic models.
If you choose AUDIORATE in editable section equal "VAR"
the script will downsample frequency to 22050 Hz and encode with variable audio bitrate in 8 - 160 Kbps band.
Audio is still stereo! See results below in this thread.

mplex from http://mjpeg.sourceforge.net/ is used for multiplexing audio and video (tcmplex can't handle variable rate mp2) and it is not bad after all, you don't have to install heavyweight transcode package.

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 mplayer sox toolame(0.2k) mplex vcdimager cdrdao
#
# does not require: microsoft. This script has not been tested on animals.

for exe in mencoder mplayer sox toolame mplex vcdimager 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 XVCD
      #        excellent<=6 good<=9 even=13 for SVCD

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

# audio bitrate
#AUDIORATE=128 # constant
AUDIORATE="VAR" # frequency 22.05kHz in 8-160kbs band

# scaling algorithm
#SWS=0 # fast bilinear
SWS=2 # bicubic (for upscaling)
#SWS=9 # lanczos (quality? slow)

# video filters
VFILTER="pp=de,denoise3d,"

# for frame rate conversions
#FPS=",telecine,lavcdeint -fps 29.97 -ofps 29.97" # to increase fps
#FPS=" -ofps 29.97"  # NTSC
#FPS=" -ofps 25"     # PAL
#FPS=" -ofps 23.976" # NTSC pulldowned
#FPS=",ivtc=1 -ofps 23.976" # to decrease fps

# 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

# for xvcd
#XY="352:240"
#XY="352:288"
#VCODEC=mpeg1video
#MUXMODE="-f 2 -m 1 -V -b 46"
#IMAMODE="-t vcd2"

# for svcd
#XY="480:480"
XY="480:576"
VCODEC=mpeg2video
MUXMODE="-f 5 -m 2 -V -b 230"
IMAMODE="-t svcd" 

# see 'man mencoder'
LAVCOPTS=":vlelim=-4:vcelim=7:lumi_mask=0.05:dark_mask=0.01:naq:dia=2:last_pred=2"
#

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="--force --reload --eject"
CDDEV="--device 0,4,0" # SCSI id

#---------- above you can edit parameters ----------

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=$*

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

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

   command="mencoder -sws $SWS -vf ${VFILTER}scale=$XY${FPS} \
   -forceidx -of mpeg -nosound \
   -ovc lavc -lavcopts aspect=$ASPECT:vcodec=$VCODEC:$MATRIX:mbd=2:vqscale=$Q:vqcomp=1:vrc_minrate=300:vrc_maxrate=2300:vrc_buf_size=320:keyint=25${LAVCOPTS}$pass \
   $COMMAND_LINE_MENCODER $FILE -o $VIDEO"

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

eval "mplayer -noframedrop -vc dummy -vo null -dumpvideo -dumpfile $NAME.mpv $VIDEO &> /dev/null &"

# audio encoding
AUDIO="audio.wav"
rm -f $AUDIO
mkfifo -m 660 $AUDIO
eval "mplayer -noframedrop -vc dummy -vo null -ao pcm -waveheader -aofile $AUDIO $FILE &> /dev/null &"

if [ "$AUDIORATE" == "VAR" ]; then
   command="cat $AUDIO | sox -V -t .wav - -r 22050 -t .wav - resample -q | toolame -s 22.05 -m s -v 1 - $NAME.mpa &"
else
   command="cat $AUDIO | toolame -s 44.1 -m s -b $AUDIORATE - $NAME.mpa &"
fi
echo "$command"
eval "$command"
#eval "lame -h --abr $AUDIORATE --resample 44.1 - $NAME.mpa < $AUDIO &"
#eval "ffmpeg -y -i $AUDIO -ab $AUDIORATE -ar 44100 -ac 2 -f mp2 $NAME.mpa &" 

wait

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

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

for i in $NAME?.mpg; do 
   cue="`basename $i .mpg`.cue"
   bin="`basename $i .mpg`.bin"
   rm -f $cue $bin
   eval "vcdimager $IMAMODE -c $cue -b $bin $i"
done

echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n"

for cue in $NAME?.cue; do
   bin="`basename $cue .cue`.bin"
   echo "PLEASE INSERT BLANK CD IN CD-WRITER, after a keypress we start:"
   read -n 1 null
   eval "cdrdao write $CDOPT $CDDEV $cue"
   echo "CD WRITING IS COMPLETED."
done

exit 0
# last line of this script
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #16  
12-10-2003, 01:54 PM
japie japie is offline
Free Member
 
Join Date: Jul 2003
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
I've been doing some testing and must say that 2-pass encoding doesn't change much... (in the mencoder a+v commandline), it only broke a/v_sync (as reposted on mailinglist)
vbr mp2 is actualy very interesting, anyone now how to handle it with mencoder?
__________________
Groetjes Japie
Reply With Quote
  #17  
12-10-2003, 02:08 PM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
1) Just bumped into the ugly fact that tcmplex can't multiplex variable rate mp2 properly, so I'm switching to mplex usage.
Unfortunately, mplex rely on mpeg2enc to insert sequence break points.

mplex option:
-S
This option specifies the maximum size of output
files in MBytes (2^10). The default is 2000 Mbytes
(splitting output before 2G limits can hit). When
the limit is reached a new file is started.

Note: This option is _n_o_t suitable for splitting a
long video across multiple VCD's or SVCD's.

It simply splits a single long sequence into in a
way that prevents bits of a video GOP(group of pic*
tures) or audio frame being split between chunks.
frame reasonable. This is fine for formats like
that used for DVDs where all stream parameters
appear every GOP. However, for VCD / SVCD it won't
work as the players expect each file to start a new
MPEG sequence.

For VCD / SVCD a different technique is used. If
mplex encounters a sequence break (sequence end
followed by start) in the input video stream it
starts a new output stream and file at the sequence
start. Thus to split a long video across
VCD's/SVCD's you have to get the MPEG video encoder
to introduce sequence splits at the right points
(see mpeg2enc(1) for details of how to do this).

I just ignore suggested mpeg2enc and use -S option of mplex. It works.

2) Limitations of toolame encoding:
Bitrate Ranges
When making a VBR stream, the bitrate is only allowed to vary within set limits:
48kHz Stereo: 112-384kbps Mono: 56-192kbps
44.1kHz & 32kHz Stereo: 192-384kbps Mono: 96-192kbps
24kHz, 22.05kHz & 16kHz Stereo/Mono: 8-160kbps

It is expected in VCD and SVCD that sampling rate is 44.1 KHz; it is nice to have variable lower bitrates, so the question is: can we stretch VCD/SVCD standard by using 48kHz dvd standard?
Can standalone players handle that?

..Resampling from 44.1KHz to 48kHz is bad quality with standard tools, so I put resampling to 22kHz instead.

This is test on 1.5 hour film:
with stereo:
VBR stats:
8 16 24 32 40 48 56 64 80 96 112 128 144 160
186 0 16 31 138 494 1104 2025 8672 19671 38521 21557 2752 336
Avg slots/frame = 705.675; b/smp = 4.90; bitrate = 108.056 kbps

with joint stereo:
VBR stats:
8 16 24 32 40 48 56 64 80 96 112 128 144 160
186 0 16 40 153 544 1242 2260 9837 24930 42033 13886 376 0
Avg slots/frame = 681.046; b/smp = 4.73; bitrate = 104.285 kbps

The result is very good dispersion (not distortion) of audio bitrate.
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #18  
12-10-2003, 03:42 PM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by japie
I've been doing some testing and must say that 2-pass encoding doesn't change much... (in the mencoder a+v commandline), it only broke a/v_sync (as reposted on mailinglist)
I have the same experince when using two pass as it is.
However, if you do testing, maybe you can try
vrc_eq=
option mencoder, that is to specify rate control depends on the source.

Quote:
Originally Posted by japie
vbr mp2 is actualy very interesting, anyone now how to handle it with mencoder?
as I know, mencoder use libavcodec ffmpeg library for audio encoding; to use variable rate mp2, you have to use native mp2 encoder = toolame.
__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
  #19  
12-11-2003, 04:25 AM
neturmel neturmel is offline
Free Member
 
Join Date: Dec 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

yes, acknowledged, 2-pass encoding doesn't change much, so one pass can be dumped.

I just did a one pass encoding (first one pass audio) of a 90min movie using the mencoder predicted bitrate for a 650MB CD and hit (or should I say missed) the target with a bin file of 742MB. It is more than 50MB short of the CD capacity, so next time, I'll try the 700MB value and keep you informed.

VBR Audio encoding directly with mencoder (with lavc=ffmpeg) is not possible at the moment

Is VBR Audio encoding valid for a DVD ?
To meet DVD recommendations, a sample rate of 48kHz is a must, but what about VBR ?

Most DVD-Players play (S)VCD with 48kHz audio without any problem and
as I sometimes burn those mpegs to DVD, I only encode with 48kHz
audio, so that I don't have to reencode audio.

BTW: My cheapo DVD-Player also plays (S)VCD and DVD with MP3 (also VBR) Audio, but since I like to encode to be compatible with more than my
player, I don't use that.
Reply With Quote
  #20  
12-11-2003, 05:39 AM
russiansexpat russiansexpat is offline
Free Member
 
Join Date: Nov 2003
Posts: 123
Thanks: 0
Thanked 0 Times in 0 Posts
"Is Variable Bit Rate allowed in MPEG-1 Audio?
For Layer III, the answer is simply 'yes'. The average bit rate is the one given in the header of a Layer III frame, but as the bits may be distributed over several frames, this effectively implies a variable bit rate.
For Layers I and II, according to the standard, it is not mandatory for decoders to support Variable Bit Rate (VBR). However, in practice the majority of the decoders do support Variable Bit Rate, and it is perfectly in line with the standard to specify for a certain application that decoders should support VBR. This is implemented by specifying for each audio frame separately the bit rate at which it is encoded. " -- http://www.chiariglione.org/mpeg/faq...mp1-aud.htm#15

As for DVD Book: http://www.mpeg.org/MPEG/DVD/Book_B/Audio.html
it does not say that audio should be constant rate.

SVCD specifications explicitely state that audio bitrate can be variable.

So, if you see SVCD sticker on a DVD player and it does not play variable rate audio, you can take seller/vendor for legal ride. Of course, before that you have to purchase copy of
ISO/IEC 13818-3 (MPEG-2 Audio)
ISO/IEC 11172-3 (MPEG-1 Audio) Dolby AC-3 standard
from ISO baggers, CHF44 each.
As for DVD, you know, you are only allowed to play your region DVDs and pre-approved by Bill Hates.

__________________
are you ready for year 2038?
x+2038-1970 > (2^31+1)/(365.25*24*3600)
/dev/mem < /dev/null
Reply With Quote
Reply




Thread Tools



 
All times are GMT -5. The time now is 02:56 PM  —  vBulletin Jelsoft Enterprises Ltd