View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 1 post ] 
Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject: Export NUV To KVCD
PostPosted: Thu Jun 17, 2004 7:39 pm 
Offline
Joined: Fri Dec 05, 2003 2:08 am
Posts: 6
Location: Houston, Texas
Here's a script that I've modified a bit. I've customized it so it can be used to generate KVCD compatible mpeg files. Using this script you can fit about an hour and a half of really good quality video on ONE CD --which then can be played in most? standalone DVD players.

In order to use this script for NUV files you need to have a patched version of mplayer.
The patched version of mplayer that comes with knoppmyth isn't recent enough so you'll need to apply this patch:

http://dijkstra.csh.rit.edu:8088/~mdz/mythtv/

to a recent version (I used MPlayer 1.0pre4-3.3.3)

Once you have patched (I got a couple of errors when patching --the patch is for an older version of mplayer, but still worked) , compiled and installed mplayer you invoke the script like this:

./movie output movie.nuv (I called it movie, guess you can call it whatever you want...)

or if you install the movie script in /usr/bin just:

movie output movie.nuv


the script does a lot of other stuff --stuff I disabled during testing. If you get it working good you might think about re-enabling some of these things.

anyway, here's the script:
#!/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 sox toolame(0.2k)
#
# does not require: microsoft. This script has not been tested on animals.
#
# further modified by dtm (#mplayer)
# and even further modified by DogBoy (#knoppmyth)
#
# use of this script with knoppmyth or mythtv _requires_ a version of mplayer that
# has been patched for .nuv
# patch available here: http://dijkstra.csh.rit.edu:8088/~mdz/mythtv/
# since this script also requires the use of at least mencoder(1.0pre3)
# and the patch was written for an older version of mplayer,
# you will have to apply the patch to the newer version
# this _does_ result in a couple of errors while patching but
# the resulting patched version of mplayer _did_ compile and was able to play .nuv
# it also installed in /usr/local/bin/mplayer so if used with knoppmyth you'll have two versions of mplayer
# and mencoder installed as the normal mplayer for knoppmyth resides at /usr/bin/mplayer
# anyway, the path in this script reflects this
# again... this script will only work with a recent version of mplayer patched for .nuv

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


## Logobuster added by DogBoy

## Logobuster placement for DogBoy's Box:
#Sundance="273:244:73:20:0"
#AdultSwim="253:244:73:20:0"
#SciFi="350:396:81:37:0"
#IFC="208:250:150:49:0"


#Logobuster placement for 640x480 res (I think...)
Sundance="340:405:92:25:0"
SciFi="350:396:81:37:0"
AdultSwim="371:410:68:23:0"
IFC="371:410:68:23:0"

### Logo filter selection
JackLogo=""
LogoJacker=""
clear
echo
echo
echo "1. Sundance Channel"
echo "2. Scifi Channel"
echo "3. Adult Swim"
echo "4. IFC"
echo
echo -n "Select logo filter [none]:"
read JackLogo
if [ "$JackLogo" = 1 ]
then
LogoJacker=",delogo=$Sundance"
elif [ "$JackLogo" = 2 ]
then
LogoJacker=",delogo=$SciFi"
elif [ "$JackLogo" = 3 ]
then
LogoJacker=",delogo=$AdultSwim"
elif [ "$JackLogo" = 4 ]
then
LogoJacker=",delogo=$IFC"
fi

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="2" # 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 ----------

## subtitles added by DogBoy
## if you want to do a subtitled film comment the following line
## and edit and uncomment the one after that...
Subtitle=""
#Subtitle="-sub SomeForeignFilm.sub"

# audio bitrate
# adjust if you need to squeeze a little more onto that cd
#AUDIORATE=128
#AUDIORATE=112
AUDIORATE=96
#AUDIORATE=64
##AUDIORATE=224 # variable with frequency 48kHz in 112-384kbs band

# frame rate conversion (has to be first in processing chain)
## for some reason I was only able to get this script to work _if_ the framerate is converted
## if no framerate conversion, then no video output
## I generally set this to pal (25 fps)
## less frames means more movie fits on cd...

#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
#FRC="-fps 29.97 -ofps 25 -vf "
FRC="-fps 23.976 -ofps 25 -vf "

# video filters
#VFILTER="pp=de,denoise3d,"
VFILTER="pp=fd,pp=de,denoise3d$LogoJacker,"

# 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 (and mythtv...)
#ASPECT="1.7777" # 16:9 wide screen TV
#ASPECT="1.85" # film academy flat
#ASPECT="2.35" # cinema scope

#XcYc="346:282" # crop, cut out black bands
#XcYc="352:195"
#XeYe="376:282" # expand to match aspect view, black bands added
#XeYe="352:240"

# for xvcd
#XY="352:156"
######################XY="352:198"
XY="352:288"
#####XY="352:264"
VCODEC=mpeg1video
VBuffer=376 # Kbits = 46*1024*8/1000
MUXMODE="-f 2 -m 1 -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 -m 2 -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 # 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=":vlelim=-4:vcelim=7:vqblur=0.5:vrc_eq=tex:vmax_b_frames=2:vb_strategy=1"
ULAVCOPTS2=":naq:lumi_mask=0.05:dark_mask=0.01:tcplx_mask=0.05:scplx_mask=0.05:preme=1:predia=2:dia=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="--overburn --reload --eject"
CDDEV="--device 0,0,0" # SCSI id

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

function usage() {
echo
echo "Usage: $HOWCALLED <shrunk name> <file or mplayer source> [quality [$Q]]"
echo
echo "quality: 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="/usr/local/bin/mencoder \
-srate 44100 -lavdopts idct=0 \
-af resample=44100 $FRC${VFILTER}crop=$XcYc,scale=$XY,expand=$XeYe -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}$pass \
$COMMAND_LINE_MENCODER $Subtitle $FILE -o $MOVIE"

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

### added by john to stop the script from creating those demuxing files...
exit 0

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

if [ $AUDIORATE != 384 ]; then
# fixed audio rate
eval "mplayer -noframedrop -dumpvideo -dumpfile $NAME.mpv $MOVIE &> /dev/null &"
eval "mplayer -noframedrop -dumpaudio -dumpfile $NAME.mpa $MOVIE &> /dev/null &"
else
# re-encoding into variable audio rate
eval "mplayer -noframedrop -srate 48000 -dumpvideo -dumpfile $NAME.mpv $MOVIE &> /dev/null &"
AUDIO=$NAME.wav
###rm -f $AUDIO
###mkfifo -m 660 $AUDIO
eval "mplayer -noframedrop -vo null -vc dummy -ao pcm -waveheader -af resample=48000 -aofile $AUDIO $MOVIE &> /dev/null"
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

### added by john
exit 0

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

# imaging
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

#rm -f $NAME?.mpv $NAME?.mpa $NAME?.mpg
echo -e "\n$HOWCALLED encoding is completed in $SECONDS seconds.\n"

# CD writing
for cue in $NAME?.cue; do
bin="`basename $cue .cue`.bin"
echo "PLEASE INSERT BLANK CD IN CD-WRITER and press any key to begin writing:"
read -n 1 null
eval "cdrdao write $CDOPT $CDDEV $cue"
echo "CD WRITING IS COMPLETED."
done

exit 0
# last line of this script


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu