#!/bin/bash #set -vx ####################################################################### # # Name: svcd.sh # # Call: ./svcd.sh # This script is normaly started from the commands.conf # # Function: This script is looking into into a TASKLIST file and loops # through all the mentioned directories. It creates a ./tmp # directory and links the ???.vdr files and the index.vdr # file to it. The script the loops according to the timestamp # pairs in the marks.vdr to build the SVCD MPEG2 streams. # Out of the original marks.vdr file it takes always a pair # of timestamps to create a new marks.vdr in this tmp # directory. From the summary text file it creates some still # video files for the possibility to create a start menu for # the mastered SVCD. # # Author: Manfred Schmidt-Voigt, Hamburg 2002 # # History: 13.09.2002 created # 19.09.2002 Initialisation of NEWDIR # 03.10.2002 Logfilestructure changed # 08.06.2003 Patch for Series (Thanks to Mark2 from VDR-PORTAL) # 08.06.2003 Funcionality of vcdbatch completly integrated # ####################################################################### MPEG_DIR=/mpeg TASKLIST=/video/toconvert.txt PROGRESS=${MPEG_DIR}/status INTRO=_intro.mpg OUTRO=zouttro.mpg ( #set -vx > ${PROGRESS} DATE="date +%d.%m-%T" while [ `cat ${TASKLIST} | wc -l` -ne 0 ] do # First directory MOVIE_DIR=`head -1 ${TASKLIST}` NEWDIR='' # this part scraps all specialcharacters from the directory name to # get an ISO 9660 Characterset with upper and lower case D=`dirname ${MOVIE_DIR}` N=`basename ${D}` # ML start: original script did't work correctly for series recordings # where NEWDIR became '' and mkdir failed so encoded # recordings were overwritten if [ $N = "_" ] || [ $N = "%_" ] then D=`dirname ${D}` N=`basename ${D}` fi # ML end for i in `echo ${N}|sed -e "s/ä/ae/g" \ -e "s/ö/oe/g" \ -e "s/ü/ue/g" \ -e "s/\#.../_/g" \ -e "s/,/_/g" \ -e "s/?/_/g" \ -e "s/\./_/g" \ -e "s/;/_/g" \ -e "s/%/_/g" \ -e "s/ß/ss/g" \ -e "s/ /_/g" \ -e "s/-/_/g" \ -e "s/__*/_/g" \ -e "s/^_//" \ -e "s/_/ /g"` do # For readability I like to have Names with Capitals inbetween # (something from the HungarianNotation) #echo $i a=`echo $i|cut -c1|tr "[:lower:]" "[:upper:]"` b=`echo $i|cut -c2-` NEWDIR=${NEWDIR}$a$b done # ML start: unify NEWDIR for series recordings typeset -i num=0 while ( [ $num -eq 0 ] && [ -e ${MPEG_DIR}/${NEWDIR} ] ) || [ -e ${MPEG_DIR}/${NEWDIR}${num} ] do let num++ done if [ $num -gt 0 ] then NEWDIR=${NEWDIR}${num} fi # ML end # work only if this directory realy contains VDR files if [ -d ${MOVIE_DIR} ] && [ `ls ${MOVIE_DIR}/0*.vdr 2>/dev/null|wc -l` != '0' ] then cd ${MOVIE_DIR}/ # prepare the new Imagedirectory IMGDIR=${MPEG_DIR}/${NEWDIR} mkdir ${IMGDIR} cd ${IMGDIR} ln -s ${MOVIE_DIR}/index.vdr ln -s ${MOVIE_DIR}/???.vdr . # How many SVCDS shall be created ? let NUMOFMPGS=`cat ${MOVIE_DIR}/marks.vdr|wc -l|sed -e "s/ //g"`/2 ACTMPG=${NUMOFMPGS} NAME=1 # steps backward through the markfile and creates the SVCD mpegs # with the tosvcd program but without creating images while [ ${ACTMPG} -ne "0" ] do let STARTLINE=${ACTMPG}*2 tail -n${STARTLINE} ${MOVIE_DIR}/marks.vdr|head -2 > marks.vdr echo `${DATE}`" ...creating ${NEWDIR}/${NAME} ..." | tee -a ${PROGRESS} tosvcd -M -s1000 -q4 -w1 -o ${NAME} . let ACTMPG=${ACTMPG}-1 let NAME=${NAME}+1 done # If there is a summary file (it should!!) we go to create some # still Mpegs from it if [ -f ${MOVIE_DIR}/summary.vdr ] then # First we have to format the summary text (18line X 50Char) # Because I use always epg2timers to progam my VDR the # summary file contains only paragraphs with out linebreaks. # The keywords like "REGIE, ..." end always with a ":" # So its good to start here with two linebreaks to start a new # Paragraph sed -e "s/\([[:upper:]][[:upper:]]*: \)/\\ \\ \1/g" -e "/(epg2timers)/d" -e "/^ *$/d" ${MOVIE_DIR}/summary.vdr | fmt -w 50 > sss # Now the whole text is splittet into pages with 18 lines and # a menu help ( Please press to start Video ) COUNT=0 while [ `cat sss| wc -l` -ne 0 ] do echo `${DATE}`" ...creating ${NEWDIR}/summary_${COUNT}.mpeg ..." | tee -a ${PROGRESS} let COUNT=$COUNT+1 head -18 sss > ttt # to make all screens of the same size the page must be # padded with empty lines for (( I=`cat ttt|wc -l|tr -d " "`; $I != "18" ; I++ )) do echo " " >> ttt done echo "=============================================" >> ttt echo " Bitte drücken zum Starten " >> ttt # Now we use the commands from the netpbm package to create # the still MGEGS. The colors are exchangable cat ttt | pbmtext | pnmscale --width 704 --height 576 | pgmtoppm black-burlywood | ppmtoy4m -Ip -F25:1 | yuvscaler -O SIZE_704x576 | mpeg2enc -f 7 -T 120 -a 2 -o summary.m2v mplex -f 7 -o summary_${COUNT}.mpeg summary.m2v # next 18 lines sed 1,18d sss > sss.tmp mv sss.tmp sss done fi ####################################################################### # # This is the old functionality of vcdbatch.sh # # This part is looking into current directory and # creates the necessary XML files for creating the image files # n the mpeg directory for SVCDs. If there is are files called # summary_?.mpeg it creates also a menu structure on the # first SVCD of a directory. # The MPEG2 files itself should have an extension of .mpg ####################################################################### if [ `ls *.mpg 2>/dev/null|wc -l` != '0' ]; then # if current directory contains *.mpg files # Volume-Id must be up to 30 Characters and all uppercase VOLUME_ID=`echo ${NEWDIR} |cut -c1-30 | tr '[:lower:]' '[:upper:]'` COUNT=0 for MPEGFILE in `ls *.mpg` do let COUNT=${COUNT}+1 echo "... working on "`pwd`"/"${MPEGFILE} | tee -a ${PROGRESS} ####################################################################### # Headerpart of the resulting XML File cat > ${IMGDIR}/vcd${COUNT}.xml << XML1