Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: script to convert multiple *vdr to cd-sized *avi
without nasty line-wrapping
#!/bin/bash
#-------------------------------------------------------------------------------------------------------------
# command: "/usr/local/bin/vdr2avi.sh 16:9" OR "/usr/local/bin/vdr2avi.sh 4:3" in
# path of movie files (something like /video/${MOVIENAME}/${TIMECODE}/)
# author: Andreas Reichel
# email: andreas.reichel@i-kit.de
# url: http://www.i-kit.de
#-------------------------------------------------------------------------------------------------------------
#
# simple bash-script to transcode multiple *.vdr files to cd-sized avi-files in mpeg4-format
# use it, to convert videos recorded from dvb-cards
# use it for free, but please send me copies of modifications
#-------------------------------------------------------------------------------------------------------------
# simple howto:
#
# 1) record the movie using vdr [1] and the linux-dvb-drivers [2]
# 2) cut the movie using vdr [1]
# 3) run this skript to convert the pva-pes formatted movie-files to ps-formated mpegII-files using
# pvastrumento [3] and wine [4]
# 4) run this skript in directory of movie-files to transcode [5]
# 5) optional: burn the avi-files to cdrom
#-------------------------------------------------------------------------------------------------------------
# sources and references:
# [1] http://www.cadsoft.de/people/kls/vdr/download.htm
# [2] http://www.linuxdvb.tv/download/
# [3] http://www.offeryn.de/dv.htm
# [4] http://www.winehq.org/download.shtml
# [5] http://www.theorie.physik.uni-goettingen.de/~ostreich/transcode/#download
#-------------------------------------------------------------------------------------------------------------
EXT="vdr"
NICELEVEL=10 # run it in background
RM_TMP_FILES=1 # set it "1" if instant removing of obsolete temporary files wanted
# to save disk space
# set it "0" to safe transcoding without deleting temporary files
AF="" # initialise empty, will hold concanated filesnames later
CODEC="mpeg2" # input-codec
OUT_MCODEC="xvid" # xvid|divx|opendivx
MBITRATE="1400,1000,100" # bitrate, key-frames, crispness
RES169="640x360"
RES43="640x480"
ABITRATE="128" # vbr using lame seems to bee broken
CDSIZE="700" # use 700mb splitting
WINE=`which wine` # path to wine
TRANSCODE=`which transcode` # path to transcode
CPVAS='/usr/local/bin/cPVAS.exe' # path to cPVAS.exe
case "${1}" in
"16:9") Y=80
RES=${RES169}
;;
"4:3") Y=0
RES=${RES43}
;;
*) echo "Usage: /usr/local/bin/mpeg2avi.sh 16:9|4:3"
exit 1
;;
esac
# test, if all needed programs are found
if test -z ${WINE}
then
echo "Error: Wine not found in PATH"
exit 1
fi
if test -z ${TRANSCODE}
then
echo "Error: Wine not found in PATH"
exit 1
fi
if test ! -s ${CPVAS}
then
echo "Error: cPVAS.exe not found"
exit 1
fi
for F in `ls *.${EXT}`
do
FN=`basename ${F} .${EXT}`
if `test $[${FN}] -gt 0`
then
#demux video, first create job-file
echo -e "offeryn pvas job v002016 # DO NOT DELETE THIS LINE\n\044JOB\ndemux ${FN}.${EXT} ${FN}.mpv ${FN}.mpa\naudio 1\nvideo 1\n\044PARMS\nloglevel 2\nfixstart 1\nsync 1\ndropgop 1\ndropwronggop 1\nstrongaudio 1\nshortscan 0\nscanseq 200\nsetbr 1\nsetvbr 1\nsetavg 1\nadjusttc 1\npacksize 0\nsplitsize 0\noverlap 1\nspliteven 0\nsplitaudioFMT 1\ngoppts 1" > ${FN}.ajb
chmod 0644 ${FN}.ajb
nice -n ${NICELEVEL} ${WINE} -- ${CPVAS} ${FN}.ajb > ${FN}.log
#get video-frames in movie
FRAMES=`awk '/^Video:[ 0123456789.]+/ {match($0,/[0123456789.]+/); print substr($0,RSTART,RLENGTH)}' ${FN}.log`
test $? -ne 0 && (echo "ERROR: ${F}, demuxing"; exit 1)
test ${RM_TMP_FILES} -gt 0 && rm -f ${FN}.${EXT}
test ${RM_TMP_FILES} -gt 0 && rm -f ${FN}.ajb
#first loop, get vbr-settings and the -s option from astat-plugin
NORMALIZE=`nice -n ${NICELEVEL} transcode -x ${CODEC} -y ${OUT_MCODEC} -i ${FN}.mpv -p ${FN}.mpa -R 1 -O -V -M 2 -c 0-${FRAMES} -w ${MBITRATE} -j ${Y},0,${Y},0 -Z ${RES} -J astat -b ${ABITRATE} | awk '/-s[ 0123456789.]/ {match($0,/-s [0123456789.]+/); print substr($0,RSTART,RLENGTH)}'`
test $? -ne 0 && (echo "ERROR: ${F}, first loop"; exit 1)
#second loop, make the movie using the calculated settings
nice -n ${NICELEVEL} transcode -x ${CODEC} -y ${OUT_MCODEC} -i ${FN}.mpv -p ${FN}.mpa -o ${FN}.avi -R 2 -O -V -M 2 -c 0-${FRAMES} -w ${MBITRATE} -j ${Y},0,${Y},0 -Z ${RES} -b ${ABITRATE} ${NORMALIZE}
test $? -ne 0 && (echo "ERROR: ${F}, second loop"; exit 1)
test ${RM_TMP_FILES} -gt 0 && rm -f ${FN}.mpv ${FN}.mpa # remove temp-files
AF="${AF} ${FN}.avi" # concanate filenames
fi
done
#get name of parent-dir as moviename
DIRNAME=`(cd ..; pwd)`
TOP_DIRNAME=`(cd ../.. ; pwd)`
MOVIENAME=`basename ${DIRNAME} ${TOP_DIRNAME}`
# merge avifiles and remove them
avimerge -i ${AF} -o ${MOVIENAME}.avi
#test $? -eq 0 && exit 1
test ${RM_TMP_FILES} -gt 0 && rm -f ${AF}
#split in cd-sized chunks and clean up
avisplit -i ${MOVIENAME}.avi -o ${MOVIENAME} -s ${CDSIZE}
test ${RM_TMP_FILES} -gt 0 && rm -f ${MOVIENAME}.avi *.log
exit 0
--
_________________________________________________________________________
Andreas Reichel +49 0174-3262-499 :Phone
Hasenweg 2c andreas.reichel@i-kit.de :Email
D-04463 Grosspoesna, Germany www.i-kit.de :HTTP
_________________________________________________________________________
-- No attachments (even text) are allowed --
-- Type: application/pgp-signature
Home |
Main Index |
Thread Index