2002-04-11 22:53:48 +00:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# Version: 0.1.2
|
2002-04-11 22:53:48 +00:00
|
|
|
|
#
|
|
|
|
|
# Licence: GPL
|
|
|
|
|
#
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# 2002/04/14 J<>rgen Hammelmann <juergen.hammelmann@gmx.de>
|
2002-04-11 22:53:48 +00:00
|
|
|
|
#
|
|
|
|
|
# Script: MPlayer Sources (DVD) to (S)VCD ripping and burning
|
|
|
|
|
#
|
|
|
|
|
# requires: newest mplayer cvs version
|
|
|
|
|
# mjpegtools v1.6 beta
|
|
|
|
|
# vcdimager
|
|
|
|
|
# cdrdao
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# lame
|
2002-04-11 22:53:48 +00:00
|
|
|
|
#
|
|
|
|
|
################################################################################
|
|
|
|
|
#
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# 2002/04/11 v0.1.0: first version
|
|
|
|
|
# 2002/04/12 v0.1.1:
|
|
|
|
|
# 2002/04/14 v0.1.2:
|
|
|
|
|
# - handles now multiple vcd's
|
|
|
|
|
# - support's mp3 audio as option
|
|
|
|
|
# - use of mp2enc/lame instead of toolame because of support
|
|
|
|
|
# of resampling and mp3
|
|
|
|
|
#
|
|
|
|
|
################################################################################
|
|
|
|
|
#
|
|
|
|
|
# global config section, change them to your needs!
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
|
|
|
|
TMPDIR="." # path to directory for creating temporary files, recommended 2-3GB space
|
|
|
|
|
|
|
|
|
|
CDDRV="generic-mmc" # cdrdao: cdwriter driver
|
|
|
|
|
CDDEV="--device 0,1,0" # or comment out and create link /dev/cdrecorder to your cdwriter dev
|
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
AUDIO="audiodump.wav"
|
|
|
|
|
VIDEO="stream.yuv"
|
2002-04-11 22:53:48 +00:00
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
|
echo "usage: $HOWCALLED <filename> [options] [mplayer options]"
|
|
|
|
|
echo
|
|
|
|
|
echo "$HOWCALLED options:"
|
|
|
|
|
echo
|
2002-04-15 14:01:07 +00:00
|
|
|
|
echo "-h|-? help"
|
|
|
|
|
echo "-w outputs in wide screen format 16:9"
|
|
|
|
|
echo "-abr <n> output audio bitrate in kbs [224]"
|
|
|
|
|
echo "-asr <n> output audio sample rate in Hz [48000]"
|
|
|
|
|
echo "-blank cleans cd-rw before burning"
|
|
|
|
|
echo "-cdsize <n> maximal size of cd images [646]"
|
|
|
|
|
echo "-denoise denoises mpeg stream"
|
|
|
|
|
echo "-noburn disables burning"
|
|
|
|
|
echo "-mp3 outputs audio in mp3 instead of mp2 format"
|
|
|
|
|
echo "-mpg don't encode from source, multiplex/burn"
|
|
|
|
|
echo " only the encoded mpg stream"
|
|
|
|
|
echo "-vcdout encode to VCD format [default]"
|
|
|
|
|
echo "-svcdout encode to SVCD format"
|
2002-04-11 22:53:48 +00:00
|
|
|
|
echo
|
|
|
|
|
echo "example:"
|
2002-04-15 14:01:07 +00:00
|
|
|
|
echo "'$HOWCALLED crazy -dvd 3 -w' encodes and burns dvd title 3 to VCD in 16:9."
|
2002-04-11 22:53:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HOWCALLED=`basename $0`
|
|
|
|
|
NAME=$1
|
|
|
|
|
if [ $# -le 1 ]; then
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
|
|
cd $TMPDIR
|
2002-04-15 14:01:07 +00:00
|
|
|
|
rm -f $VIDEO
|
|
|
|
|
rm -f $AUDIO
|
|
|
|
|
# create a named pipe for video stream
|
|
|
|
|
mkfifo -m 660 $VIDEO
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# some inits
|
2002-04-11 22:53:48 +00:00
|
|
|
|
params=""
|
|
|
|
|
wide=""
|
|
|
|
|
blank=0
|
|
|
|
|
burn=1
|
2002-04-15 14:01:07 +00:00
|
|
|
|
mp3=0
|
2002-04-11 22:53:48 +00:00
|
|
|
|
mkstream=1
|
|
|
|
|
abr=224
|
2002-04-15 14:01:07 +00:00
|
|
|
|
abrset=0
|
|
|
|
|
asr=44100
|
2002-04-11 22:53:48 +00:00
|
|
|
|
denoise="cat -"
|
|
|
|
|
norm="VCD"
|
2002-04-15 14:01:07 +00:00
|
|
|
|
mplexnorm="-f 2 -m 1 -V"
|
|
|
|
|
max=646
|
|
|
|
|
mpegnorm="-f 2 -b 1152 -B 260"
|
2002-04-11 22:53:48 +00:00
|
|
|
|
imaget="-t vcd2"
|
|
|
|
|
while [ "$1"x != "x" ]; do
|
|
|
|
|
case $1 in
|
|
|
|
|
-w)
|
|
|
|
|
wide="-M WIDE2STD"
|
|
|
|
|
;;
|
2002-04-15 14:01:07 +00:00
|
|
|
|
-h|-?)
|
|
|
|
|
usage
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
2002-04-11 22:53:48 +00:00
|
|
|
|
-abr)
|
|
|
|
|
abr=$2
|
2002-04-15 14:01:07 +00:00
|
|
|
|
abrset=1
|
2002-04-11 22:53:48 +00:00
|
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
-asr)
|
2002-04-15 14:01:07 +00:00
|
|
|
|
asr=$2
|
|
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
-cdsize)
|
|
|
|
|
max=$2
|
2002-04-11 22:53:48 +00:00
|
|
|
|
shift 1
|
|
|
|
|
;;
|
|
|
|
|
-blank)
|
|
|
|
|
blank=1
|
|
|
|
|
;;
|
|
|
|
|
-noburn)
|
|
|
|
|
burn=0
|
|
|
|
|
;;
|
2002-04-15 14:01:07 +00:00
|
|
|
|
-mp3)
|
|
|
|
|
mp3=1
|
|
|
|
|
;;
|
2002-04-11 22:53:48 +00:00
|
|
|
|
-mpg)
|
|
|
|
|
mkstream=0
|
|
|
|
|
;;
|
|
|
|
|
-denoise)
|
|
|
|
|
denoise="yuvdenoise"
|
|
|
|
|
;;
|
|
|
|
|
-vcdout)
|
|
|
|
|
norm="VCD"
|
2002-04-15 14:01:07 +00:00
|
|
|
|
mplexnorm="-f 2 -m 1 -V"
|
|
|
|
|
mpegnorm="-f 2 -b 1152 -B 260"
|
2002-04-11 22:53:48 +00:00
|
|
|
|
imaget="-t vcd2"
|
|
|
|
|
;;
|
|
|
|
|
-svcdout)
|
|
|
|
|
norm="SVCD"
|
2002-04-15 14:01:07 +00:00
|
|
|
|
mplexnorm="-f 4 -m 2 -V"
|
|
|
|
|
mpegnorm="-f 4 -b 2500 -B 260"
|
2002-04-11 22:53:48 +00:00
|
|
|
|
imaget="-t svcd"
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
params="$params $1"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
shift 1
|
|
|
|
|
done
|
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# some configs
|
2002-04-11 22:53:48 +00:00
|
|
|
|
if [ -n "$wide" ]; then
|
|
|
|
|
if [ "$norm" == "SVCD" ]; then
|
|
|
|
|
wide=""
|
|
|
|
|
mpegnorm="$mpegnorm -a 3"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# with mp3 audio set the default audio bitrate to 128 kbs
|
|
|
|
|
if [ $mp3 -eq 1 -a $abrset -eq 0 ]; then
|
|
|
|
|
abr=128
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# audio sample rate in kHz
|
|
|
|
|
((a=$asr / 1000))
|
|
|
|
|
((b=$asr % 1000))
|
|
|
|
|
[ $b -le 9 ] && b="00$b00"
|
|
|
|
|
[ $b -le 99 ] && b="0$b00"
|
|
|
|
|
kasr="$a.$b"
|
|
|
|
|
|
2002-04-11 22:53:48 +00:00
|
|
|
|
# encode streams
|
|
|
|
|
if [ $mkstream -eq 1 ]; then
|
|
|
|
|
# start mplayer
|
2002-04-15 14:01:07 +00:00
|
|
|
|
mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader $params &
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# mjpegtools
|
|
|
|
|
($denoise < $VIDEO | \
|
2002-04-11 22:53:48 +00:00
|
|
|
|
yuvscaler -v 0 $wide -O $norm | \
|
2002-04-15 14:01:07 +00:00
|
|
|
|
mpeg2enc -v 0 -s $mpegnorm -S $max -g 6 -G 15 -r 16 -o $NAME.mpv) &
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
|
|
|
|
# wait for finishing the subprocesses
|
|
|
|
|
wait
|
2002-04-15 14:01:07 +00:00
|
|
|
|
|
|
|
|
|
if [ $mp3 -eq 0 ]; then
|
|
|
|
|
# mp2enc/lame can't read audiodump.wav directly from named pipe,
|
|
|
|
|
# we have to read the whole file.
|
|
|
|
|
mp2enc -b $abr -r $asr -o $NAME.mpa < $AUDIO
|
|
|
|
|
else
|
|
|
|
|
lame -b $abr --resample $kasr - $NAME.mpa < $AUDIO
|
|
|
|
|
fi
|
2002-04-11 22:53:48 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# remove pipe and wav file, won't need anymore!
|
|
|
|
|
rm -f $VIDEO
|
|
|
|
|
rm -f $AUDIO
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
|
|
|
|
# multiplex streams
|
|
|
|
|
[ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1
|
2002-04-15 14:01:07 +00:00
|
|
|
|
rm -f ${NAME}*.mpg
|
|
|
|
|
mplex $mplexnorm $NAME.mpv $NAME.mpa -o ${NAME}%d.mpg
|
|
|
|
|
|
|
|
|
|
# create cd images
|
|
|
|
|
for mpg in ${NAME}*.mpg; do
|
|
|
|
|
[ -f $mpg ] || exit 1
|
|
|
|
|
cue="`basename $mpg .mpg`.cue"
|
|
|
|
|
bin="`basename $mpg .mpg`.bin"
|
|
|
|
|
rm -f $cue $bin
|
|
|
|
|
vcdimager $imaget -c $cue -b $bin $mpg
|
|
|
|
|
done
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
# burn the (s)vcd's
|
2002-04-11 22:53:48 +00:00
|
|
|
|
[ $burn -eq 0 ] && exit 0
|
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
for cue in ${NAME}*.cue; do
|
|
|
|
|
bin="`basename $cue .cue`.bin"
|
|
|
|
|
[ -f $bin -a -f $cue ] || exit 1
|
|
|
|
|
|
|
|
|
|
echo "please insert a cd in your cdwriter, after a keypress we start:"
|
|
|
|
|
read -n 1 i
|
2002-04-11 22:53:48 +00:00
|
|
|
|
|
2002-04-15 14:01:07 +00:00
|
|
|
|
if [ $blank -eq 1 ]; then
|
|
|
|
|
cdrdao blank --reload $CDDEV --driver $CDDRV --blank-mode minimal
|
|
|
|
|
fi
|
|
|
|
|
cdrdao write --reload $CDDEV --driver $CDDRV $cue
|
|
|
|
|
done
|
2002-04-11 22:53:48 +00:00
|
|
|
|
exit 0
|