mirror of
https://github.com/mpv-player/mpv
synced 2025-01-20 21:07:29 +01:00
Updated to support resampling audio and multiple cds.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5634 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
6d8cc6f3e9
commit
6fbbfc9e17
167
TOOLS/mencvcd
167
TOOLS/mencvcd
@ -1,28 +1,42 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Version: 0.1.1
|
# Version: 0.1.2
|
||||||
#
|
#
|
||||||
# Licence: GPL
|
# Licence: GPL
|
||||||
#
|
#
|
||||||
# 2002/05/11 Jürgen Hammelmann <juergen.hammelmann@gmx.de>
|
# 2002/04/14 Jürgen Hammelmann <juergen.hammelmann@gmx.de>
|
||||||
#
|
#
|
||||||
# Script: MPlayer Sources (DVD) to (S)VCD ripping and burning
|
# Script: MPlayer Sources (DVD) to (S)VCD ripping and burning
|
||||||
#
|
#
|
||||||
# requires: newest mplayer cvs version
|
# requires: newest mplayer cvs version
|
||||||
# mjpegtools v1.6 beta
|
# mjpegtools v1.6 beta
|
||||||
# toolame
|
|
||||||
# vcdimager
|
# vcdimager
|
||||||
# cdrdao
|
# cdrdao
|
||||||
|
# lame
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# global options section, change them to your needs!
|
# 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!
|
||||||
|
|
||||||
TMPDIR="." # path to directory for creating temporary files, recommended 2-3GB space
|
TMPDIR="." # path to directory for creating temporary files, recommended 2-3GB space
|
||||||
|
|
||||||
CDDRV="generic-mmc" # cdrdao: cdwriter driver
|
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
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
AUDIO="audiodump.wav"
|
||||||
|
VIDEO="stream.yuv"
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
@ -30,20 +44,22 @@ function usage() {
|
|||||||
echo
|
echo
|
||||||
echo "$HOWCALLED options:"
|
echo "$HOWCALLED options:"
|
||||||
echo
|
echo
|
||||||
echo "-w outputs in wide screen format 16:9"
|
echo "-h|-? help"
|
||||||
echo "-abr <n> audio bitrate in kbs [224]"
|
echo "-w outputs in wide screen format 16:9"
|
||||||
echo "-asr <n> audio sample rate in Hz [44100]"
|
echo "-abr <n> output audio bitrate in kbs [224]"
|
||||||
echo "-blank cleans cd-rw before burning"
|
echo "-asr <n> output audio sample rate in Hz [48000]"
|
||||||
echo "-burn enables burning [default]"
|
echo "-blank cleans cd-rw before burning"
|
||||||
echo "-denoise denoises mpeg stream"
|
echo "-cdsize <n> maximal size of cd images [646]"
|
||||||
echo "-noburn disables burning"
|
echo "-denoise denoises mpeg stream"
|
||||||
echo "-mpg don't encode from source, multiplex/burn only the mpeg stream"
|
echo "-noburn disables burning"
|
||||||
echo "-vcdout encode to VCD format [default]"
|
echo "-mp3 outputs audio in mp3 instead of mp2 format"
|
||||||
echo "-svcdout encode to SVCD 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"
|
||||||
echo
|
echo
|
||||||
echo "example:"
|
echo "example:"
|
||||||
echo "'$HOWCALLED crazy -dvd 3 -w' encodes and burns dvd title 3 to VCD in wide"
|
echo "'$HOWCALLED crazy -dvd 3 -w' encodes and burns dvd title 3 to VCD in 16:9."
|
||||||
echo " screen format."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HOWCALLED=`basename $0`
|
HOWCALLED=`basename $0`
|
||||||
@ -55,47 +71,58 @@ fi
|
|||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
cd $TMPDIR
|
cd $TMPDIR
|
||||||
rm -f stream.yuv
|
rm -f $VIDEO
|
||||||
rm -f audiodump.pcm
|
rm -f $AUDIO
|
||||||
rm -f audiodump.wav
|
# create a named pipe for video stream
|
||||||
mkfifo -m 660 stream.yuv
|
mkfifo -m 660 $VIDEO
|
||||||
mkfifo -m 660 audiodump.pcm
|
|
||||||
mkfifo -m 660 audiodump.wav
|
|
||||||
|
|
||||||
|
# some inits
|
||||||
params=""
|
params=""
|
||||||
wide=""
|
wide=""
|
||||||
blank=0
|
blank=0
|
||||||
burn=1
|
burn=1
|
||||||
|
mp3=0
|
||||||
mkstream=1
|
mkstream=1
|
||||||
abr=224
|
abr=224
|
||||||
masr=44100
|
abrset=0
|
||||||
|
asr=44100
|
||||||
denoise="cat -"
|
denoise="cat -"
|
||||||
norm="VCD"
|
norm="VCD"
|
||||||
mplexnorm="-f 2 -V"
|
mplexnorm="-f 2 -m 1 -V"
|
||||||
mpegnorm="-f 2 -b 1152"
|
max=646
|
||||||
|
mpegnorm="-f 2 -b 1152 -B 260"
|
||||||
imaget="-t vcd2"
|
imaget="-t vcd2"
|
||||||
while [ "$1"x != "x" ]; do
|
while [ "$1"x != "x" ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-w)
|
-w)
|
||||||
wide="-M WIDE2STD"
|
wide="-M WIDE2STD"
|
||||||
;;
|
;;
|
||||||
|
-h|-?)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
-abr)
|
-abr)
|
||||||
abr=$2
|
abr=$2
|
||||||
|
abrset=1
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-asr)
|
-asr)
|
||||||
masr=$2
|
asr=$2
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
-cdsize)
|
||||||
|
max=$2
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
-blank)
|
-blank)
|
||||||
blank=1
|
blank=1
|
||||||
;;
|
;;
|
||||||
-burn)
|
|
||||||
burn=1
|
|
||||||
;;
|
|
||||||
-noburn)
|
-noburn)
|
||||||
burn=0
|
burn=0
|
||||||
;;
|
;;
|
||||||
|
-mp3)
|
||||||
|
mp3=1
|
||||||
|
;;
|
||||||
-mpg)
|
-mpg)
|
||||||
mkstream=0
|
mkstream=0
|
||||||
;;
|
;;
|
||||||
@ -104,14 +131,14 @@ while [ "$1"x != "x" ]; do
|
|||||||
;;
|
;;
|
||||||
-vcdout)
|
-vcdout)
|
||||||
norm="VCD"
|
norm="VCD"
|
||||||
mplexnorm="-f 2 -V"
|
mplexnorm="-f 2 -m 1 -V"
|
||||||
mpegnorm="-f 2 -b 1152"
|
mpegnorm="-f 2 -b 1152 -B 260"
|
||||||
imaget="-t vcd2"
|
imaget="-t vcd2"
|
||||||
;;
|
;;
|
||||||
-svcdout)
|
-svcdout)
|
||||||
norm="SVCD"
|
norm="SVCD"
|
||||||
mplexnorm="-f 4 -V"
|
mplexnorm="-f 4 -m 2 -V"
|
||||||
mpegnorm="-f 4"
|
mpegnorm="-f 4 -b 2500 -B 260"
|
||||||
imaget="-t svcd"
|
imaget="-t svcd"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -121,6 +148,7 @@ while [ "$1"x != "x" ]; do
|
|||||||
shift 1
|
shift 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# some configs
|
||||||
if [ -n "$wide" ]; then
|
if [ -n "$wide" ]; then
|
||||||
if [ "$norm" == "SVCD" ]; then
|
if [ "$norm" == "SVCD" ]; then
|
||||||
wide=""
|
wide=""
|
||||||
@ -128,46 +156,71 @@ if [ -n "$wide" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
# encode streams
|
# encode streams
|
||||||
if [ $mkstream -eq 1 ]; then
|
if [ $mkstream -eq 1 ]; then
|
||||||
# start mplayer
|
# start mplayer
|
||||||
mplayer -noframedrop -aop list=resample:fout=$masr -vo yuv4mpeg -ao pcm \
|
mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader $params &
|
||||||
-waveheader $params &
|
|
||||||
|
|
||||||
# mjpegtools / sox
|
# mjpegtools
|
||||||
($denoise < stream.yuv | \
|
($denoise < $VIDEO | \
|
||||||
yuvscaler -v 0 $wide -O $norm | \
|
yuvscaler -v 0 $wide -O $norm | \
|
||||||
mpeg2enc -v 0 -s $mpegnorm -g 6 -G 15 -r 16 -o $NAME.mpv) &
|
mpeg2enc -v 0 -s $mpegnorm -S $max -g 6 -G 15 -r 16 -o $NAME.mpv) &
|
||||||
|
|
||||||
# we have to use toolame, mp2enc don't understand audiodump.wav directly, no RIFF header?!
|
|
||||||
(toolame -m s -b $abr audiodump.wav $NAME.mpa) &
|
|
||||||
|
|
||||||
# wait for finishing the subprocesses
|
# wait for finishing the subprocesses
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove pipes
|
# remove pipe and wav file, won't need anymore!
|
||||||
rm -f stream.yuv
|
rm -f $VIDEO
|
||||||
rm -f audiodump.pcm
|
rm -f $AUDIO
|
||||||
rm -f audiodump.wav
|
|
||||||
|
|
||||||
# multiplex streams
|
# multiplex streams
|
||||||
[ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1
|
[ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1
|
||||||
rm -f $NAME.mpg
|
rm -f ${NAME}*.mpg
|
||||||
mplex $mplexnorm $NAME.mpv $NAME.mpa -o $NAME.mpg
|
mplex $mplexnorm $NAME.mpv $NAME.mpa -o ${NAME}%d.mpg
|
||||||
|
|
||||||
# create cd image
|
# create cd images
|
||||||
[ -f $NAME.mpg ] || exit 1
|
for mpg in ${NAME}*.mpg; do
|
||||||
rm -f $NAME.cue $NAME.bin
|
[ -f $mpg ] || exit 1
|
||||||
vcdimager $imaget -c $NAME.cue -b $NAME.bin $NAME.mpg
|
cue="`basename $mpg .mpg`.cue"
|
||||||
|
bin="`basename $mpg .mpg`.bin"
|
||||||
|
rm -f $cue $bin
|
||||||
|
vcdimager $imaget -c $cue -b $bin $mpg
|
||||||
|
done
|
||||||
|
|
||||||
# burn the vcd
|
# burn the (s)vcd's
|
||||||
[ $burn -eq 0 ] && exit 0
|
[ $burn -eq 0 ] && exit 0
|
||||||
[ -f $NAME.bin -a -f $NAME.cue ] || exit 1
|
|
||||||
|
|
||||||
if [ $blank -eq 1 ]; then
|
for cue in ${NAME}*.cue; do
|
||||||
cdrdao blank --reload $CDDEV --driver $CDDRV --blank-mode minimal
|
bin="`basename $cue .cue`.bin"
|
||||||
fi
|
[ -f $bin -a -f $cue ] || exit 1
|
||||||
cdrdao write --reload $CDDEV --driver $CDDRV $NAME.cue
|
|
||||||
|
|
||||||
|
echo "please insert a cd in your cdwriter, after a keypress we start:"
|
||||||
|
read -n 1 i
|
||||||
|
|
||||||
|
if [ $blank -eq 1 ]; then
|
||||||
|
cdrdao blank --reload $CDDEV --driver $CDDRV --blank-mode minimal
|
||||||
|
fi
|
||||||
|
cdrdao write --reload $CDDEV --driver $CDDRV $cue
|
||||||
|
done
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user