mencvcd 0.2 by Juergen Hammelmann <juergen.hammelmann@gmx.de>

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8050 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
jaf 2002-11-02 17:27:23 +00:00
parent 67759cc850
commit 0d031d29e9
1 changed files with 109 additions and 60 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Version: 0.1.10
# Version: 0.2
#
# Licence: GPL
#
@ -8,12 +8,13 @@
#
# Script: MPlayer Sources (DVD) to (S)VCD ripping and burning
#
# requires: newest mplayer cvs version
# mjpegtools v1.6 beta
# requires: mplayer
# mjpegtools
# vcdimager
# cdrdao
# lame
#
# lame (optionally)
# toolame (optionally)
# sox (optionally)
for exe in mplayer mpeg2enc mp2enc mplex yuvscaler ; do
if [ -z "`which $exe`" ]; then
@ -21,7 +22,7 @@ for exe in mplayer mpeg2enc mp2enc mplex yuvscaler ; do
exit 1
fi
done
for exe in vcdimager lame cdrdao yuvdenoise ; do
for exe in vcdimager lame cdrdao yuvdenoise sox toolame ; do
if [ -z "`which $exe`" ]; then
echo "WARNING: $exe is not found in your path $PATH!"
fi
@ -62,6 +63,11 @@ done
# - bug fixes
# - tests now, if the commands are in path and give warnings
# and errors.
# 2002/11/01 v0.2
# - bug fixes
# - new options: "-sox", "-volume", "-toolame"
# - renamed "-mpg" to "-mpegsrc"
# - default cd size changed to 800mb
#
################################################################################
#
@ -70,8 +76,9 @@ done
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
CDDEV="--device 0,1,0" # or comment out and create link /dev/cdrecorder
# to your cdwriter dev
CDMAXSIZE=800
################################################################################
AUDIO="audiodump.wav"
@ -81,30 +88,42 @@ SVCDMODE=5
################################################################################
function usage() {
echo "usage: $HOWCALLED <name> [options] [mplayer options]"
echo "Usage: $HOWCALLED <name> [$HOWCALLED options] [mplayer options]"
echo
echo "For mplayer options see mplayer help and manual."
echo
echo "$HOWCALLED options:"
echo
echo "-?|-h help."
echo "-a <n> sets the aspect ratio (for SVCD):"
echo " 1 - 1:1 display"
echo " 2 - 4:3 display"
echo " 3 - 16:9 display"
echo " 4 - 2.21:1 display"
echo "-abr <n> output audio bitrate in kbs [224]."
echo "-asr <n> output audio sample rate in Hz [44100]."
echo "-blank cleans cd-rw before burning."
echo "-burnonly burn only the premastered <name>*.cue/<name>*.bin images."
echo "-cdsize <n> maximal size of cd images [700]."
echo "-cdsize <n> maximal size of cd images [800 = 80min raw cd]."
echo "-denoise denoises mpeg stream."
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 "-mpegsrc don't encode from source, multiplex/burn the "
echo " encoded mpg stream."
echo "-mpgonly do only encoding to mpeg 1/2 format."
echo "-noburn disables burning."
echo "-ratio <s> output ratio size of frames, see yuvscaler (1)."
echo "-size <X>x<Y> sets output size of frames."
echo "-sox use sox for audio resampling."
echo "-svcdout encode to SVCD format [VCD default]."
echo "-sync <n> set the presentation timestamp offset of video"
echo " stream w.r.t. audio stream (video-audio) in mSec."
echo "-toolame use toolame instead of mp2enc."
echo "-v <volume> change amplitude (floating point); less than 1.0"
echo " decreases, greater than 1.0 increases. Use that only"
echo " together with sox!"
echo "-vbr <n> output video bitrate in kbs [VCD:1152, SVCD:2500]."
echo "-vfr <n> sets the frame-rate of the output-stream. Currently"
echo " only the standard MPEG rates are supported."
echo " only the standard MPEG rates are supported:"
echo " 0 - illegal"
echo " 1 - 24000.0/1001.0 (NTSC 3:2 pulldown converted FILM)"
echo " 2 - 24.0 (NATIVE FILM)"
@ -114,17 +133,20 @@ function usage() {
echo " 6 - 50.0 (PAL FIELD RATE)"
echo " 7 - 60000.0/1001.0 (NTSC FIELD RATE)"
echo " 8 - 60.0"
echo "-vnorm p|n|s sets the input video norm p, n or s:"
echo "-vnorm <p|n|s> sets the input video norm p, n or s:"
echo " forces the input stream to be treated as PAL|NTSC|SECAM"
echo " regardless of what the stream header might suggest."
echo "-w outputs in wide screen format 16:9."
echo
echo "examples:"
echo
echo "'$HOWCALLED teneriffa teneriffa.avi'"
echo "this creates a VCD from an avi file."
echo
echo "'$HOWCALLED crazy -dvd 3 -w':"
echo "encodes and burns dvd title 3 to VCD in 16:9."
echo
echo "'mencvcd carter -dvd 1 -sid 0 -aid 128 -ss 3:00 -frames 1500 \\"
echo "'$HOWCALLED carter -dvd 1 -sid 0 -aid 128 -ss 3:00 -frames 1500 \\"
echo " -noburn -vnorm n -vfr 1':"
echo "this encodes 1500 frames of dvd title 1 with subtitle 0 and audio stream"
echo "128 starting from 3:00 with frame rate 29.97 fps and input video norm NTSC"
@ -148,6 +170,7 @@ mkfifo -m 660 $VIDEO
# some inits
sub=""
size=""
aratio=""
ratio=""
params=""
wide=""
@ -165,15 +188,20 @@ vbrset=0
denoise="cat -"
norm="VCD"
mplexnorm="-f $VCDMODE -m 1 -V -b 46"
max=700
mpegnorm="-f $VCDMODE -b $vbr -B 260 -V 46"
imaget="-t vcd2"
yuvin=""
framerate=""
sync=""
sox=0
toolame=0
volume="1.0"
while [ "$1"x != "x" ]; do
case $1 in
-a)
aratio="-a $2"
shift 1
;;
-w)
wide="-M WIDE2STD"
;;
@ -191,7 +219,7 @@ while [ "$1"x != "x" ]; do
shift 1
;;
-cdsize)
max=$2
CDMAXSIZE=$2
shift 1
;;
-blank)
@ -211,7 +239,7 @@ while [ "$1"x != "x" ]; do
-mp3)
mp3=1
;;
-mpg)
-mpegsrc)
mkstream=0
;;
-mpgonly)
@ -221,6 +249,10 @@ while [ "$1"x != "x" ]; do
yuvin="-n $2"
shift 1
;;
-volume)
volume="$2"
shift 1
;;
-denoise)
denoise="yuvdenoise"
;;
@ -243,6 +275,12 @@ while [ "$1"x != "x" ]; do
sync="-O $2"
shift 1
;;
-sox)
sox=1
;;
-toolame)
toolame=1
;;
-vbr)
vbr=$2
vbrset=1
@ -256,15 +294,11 @@ while [ "$1"x != "x" ]; do
done
# some configs
mpegnorm="-f $VCDMODE -b $vbr -B 260 -V 46"
if [ "$norm" == "SVCD" ]; then
[ $vbrset -eq 0 ] && vbr=2500
mplexnorm="-f $SVCDMODE -m 2 -V -b 230"
if [ -n "$wide" ]; then
wide=""
mpegnorm="-f $SVCDMODE -b $vbr -B 260 -V 230 -a 3"
else
mpegnorm="-f $SVCDMODE -b $vbr -B 260 -V 230 -a 2"
fi
mpegnorm="-f $SVCDMODE -b $vbr -B 260 -V 230 $aratio"
imaget="-t svcd"
fi
@ -287,23 +321,38 @@ if [ $burnonly -eq 0 ]; then
# encode streams
if [ $mkstream -eq 1 ]; then
# start mplayer
mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader -benchmark \
-v -osdlevel 0 $sub $params &
command="mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader -v -osdlevel 0 $sub $params"
echo "$command"
$command &
# mjpegtools
($denoise < $VIDEO | \
yuvscaler -v 0 $wide -O $norm $size $yuvin | \
mpeg2enc -v 0 -s $mpegnorm -S $max -g 6 -G 15 -r 16 \
mpeg2enc -v 0 -s $mpegnorm -S $CDMAXSIZE -g 6 -G 15 -r 16 \
$framerate $yuvin -4 2 -2 1 -o $NAME.mpv) &
# wait for finishing the subprocesses
wait
if [ $mp3 -eq 0 ]; then
# do resampling with sox
if [ $sox -ne 0 ]; then
echo "wait, do resampling with sox..."
sox $AUDIO -v $volume -r $asr $NAME.wav resample -qs
mv -f $NAME.wav $AUDIO
fi
if [ $toolame -ne 0 -a $mp3 -eq 0 ]; then
# do mp2 encoding with toolame
echo "wait, encoding to mp2 audio with toolame..."
toolame -b $abr $AUDIO
mv -f `basename $AUDIO .wav`.mp2 $NAME.mpa
elif [ $toolame -eq 0 -a $mp3 -eq 0 ]; then
# mp2enc/lame can't read audiodump.wav directly from named pipe,
# we have to read the whole file.
echo "wait, encoding to mp2 audio with mp2enc..."
mp2enc -b $abr -r $asr -o $NAME.mpa < $AUDIO
else
elif [ $mp3 -ne 0 ]; then
echo "wait, encoding to mp3 audio with lame..."
lame -b $abr --resample $kasr - $NAME.mpa < $AUDIO
fi
fi