#!/bin/bash # # mk_vmgm - Create Main menu of the DVD (VMGM) # for authoring a DVD with dvdauthor >= 0.6 # # Version 0.4 written by Wolfgang Wershofen (mailto: itconsult at wershofen.de) # 0.5 - changed whole layout of menu # - support for multiple languages (-M) # - added subtitle button # - code cleanup # # See TOOLS in the dvdwizard tarball for info about needed tools and programs # usage() { cat <0 - suppress vmgm menu and loop all titles endlessly, starting from specified title -MS | --vmgmsound Soundfile to be used as background sound for all menus (may be overwritten for specific titlesets with -ms|--vtsmsound). If empty, a silent audio track will be produced. Can be any format, ffmpeg recognizes and will be converted to ac3, if neccessary. Title-specific options: ----------------------- -t | --vts Titlestring for titleset. repeat for each titleset Will be ignored for single-titleset DVDs, if -T is given -b | --vtsmbg Image to use as thumbnail for the vtsm in a Multi-Titleset-DVD -ms | --vtsmsound see -MS, but only applies to this title --hasaudio Title has multiple audio tracks. A button to jump to the audio selection menu will be created --hassubtitle Title has at least one Subtitle-Stream which may be activated in a subsequent subtitle-menu --hasinfo Title has EPG-Informations available. A button to jump to the info panel will be created Note: Every new "-t" marks a new titleset on the DVD. Subsequent options -b, -ms, --hasaudio, --hassubtitle and --hasinfo apply only to that titleset. EOF exit 1 } # ------------------------------------------ # Initialize constants troughout the whole script # init_proc() { for i in HEADER DUMMY ABOUT ABOUT1 ABOUT2; do eval txt_$i=\"\$TXT_VMGM_${i}_$MENU\" done # # Init sizes # # offsets of title strings offsetX1=20 offsetX2=40 return 0 } # ------------------------------------------------------------- # Create the button bar background # mk_button_bar() { let maxButtons="$maxAddButtons+2" btnbarbg="$(mktemp -t png.XXXXXXXXXX)" let pW="pictWidth+10" let pH="(($pictHeight+6)*$maxButtons)+6" round=20 convert -size "$(( $pW+$round ))"x"$(( $pH+$round ))" xc:"$transparent" \ -fill "$TRANSLUCENT" \ -draw 'gravity NorthWest roundrectangle 0,0,'$(( $pW+$round-1 ))','$(( $pH-1 ))' '$round','$round'' \ -crop "$pW"x"$(( $pH+$round ))"+"$round" \ \( -size "$round"x"$round" xc:"$TRANSLUCENT" -fill gray \ -draw 'gravity NorthWest roundrectangle 0,0,'$(( $round*2 ))','$(( $round*2 ))' '$round','$round'' \ -transparent gray \ \) \ -gravity SouthWest -composite \ png:"$btnbarbg" || error_out barHeight=$(identify -format %h "$btnbarbg") return 0 } # ------------------------------------------------------------- # Create Title container # mk_title_container() { titleBG="$(mktemp -t png.XXXXXXXXXX)" let stepY="$MFONTSIZE+($MFONTSIZE/4)" let tbgW="$TVWidth/2" ###################################### (( vtsLESS=vts>7?7:$vts )) ######################################### let tbgH="($vtsLESS+2)*$stepY+$HFONTSIZE*2+$stepY/2" [ $tbgH -lt $barHeight ] && tbgH=$barHeight convert -size $(( $tbgW+$pW ))x$tbgH xc:"$transparent" \ \( -size "$tbgW"x"$tbgH" xc:"$TRANSLUCENT" \ $HFONT -pointsize $HFONTSIZE -gravity NorthWest \ -fill "$shadow" -annotate +12+12 "$txt_HEADER:" \ -draw 'line 12,'$(( $HFONTSIZE+17 ))','$(( $tbgW-8 ))','$(( $HFONTSIZE+17 ))'' \ -draw 'line 12,'$(( $HFONTSIZE+18 ))','$(( $tbgW-8 ))','$(( $HFONTSIZE+18 ))'' \ -fill "$HEADCOLOR" -annotate +10+10 "$txt_HEADER:" \ -draw 'line 10,'$(( $HFONTSIZE+15 ))','$(( $tbgW-10 ))','$(( $HFONTSIZE+15 ))'' \ -draw 'line 10,'$(( $HFONTSIZE+16 ))','$(( $tbgW-10 ))','$(( $HFONTSIZE+16 ))'' \ \) \ -gravity northwest -composite \ "$btnbarbg" \ -gravity northeast -composite \ \( +clone -bordercolor transparent -border 10 \ -negate -blur 0x8 \) \ +swap -gravity center -compose src-atop -composite \ png:"$titleBG" || error_out let offsettbgY="($TVHeight-$tbgH)+$offsetTVY" # -stroke "$shadow" -strokewidth 2 \ # -stroke "$HEADCOLOR" -strokewidth 2 \ # # Container for button masks # btnMasktrans="$(mktemp -t png.XXXXXXXXXX)" let bmH="tbgH+10" let bmW="tbgW+pW+tWidth+15" convert -size "$bmW"x"$bmH" xc:"$transparent" png:"$btnMasktrans" || error_out return 0 } # ------------------------------------------------------------- # Create the VTS-Tile with thumbnail, buttons and titlestring # place_buttons() { indx=$1 # # Create Button-Bar, Highlighted and Selected Masks # defList=( "1" "1" ) eval defList[2]=\$VTSAUDIO_$indx eval defList[3]=\$VTSSUB_$indx eval defList[4]=\$VTSINFO_$indx btnDef=( "Play" "Chapter root" "Audio audio" "Subs subtitle" "Info ptt" ) for s in 0 1; do pictDef=( "${pictPlay[s]}" "${pictMenu[s]}" "${pictAudio[s]}" "${pictSubs[s]}" "${pictInfo[s]}" ) pictList=( "${pictDef[0]}" "${pictDef[1]}" ) btnList=( "${btnDef[0]}" "${btnDef[1]}" ) pnum=2 for n in 2 3 4; do if [ "${defList[n]}" == "1" ]; then pictList[$pnum]="${pictDef[n]}" btnList[$pnum]="${btnDef[n]}" let "pnum+=1" fi done bbar[s]="$(mktemp -t png.XXXXXXXXXX)" tileSize=$(identify -format %wx%h "${pictPlay[s]}") || error_out montage \ -background none -geometry ${tileSize}+3+3 -tile 1x$pnum \ "${pictList[@]}" png:"${bbar[s]}" if [ $s -eq 0 ]; then convert "$thistbg" \ -gravity northeast -draw 'image over 13,13 0,0 "'"${bbar[s]}"'"' \ png:"$thistbg" || error_out else convert "${thisbmt[s]}" \ -gravity northeast -draw 'image copy 10,13 0,0 "'"${bbar[s]}"'"' \ png:"${thisbmt[s]}" || error_out fi done # # Write xml-Definition of used buttons # let "pnum-=1" for b in $(seq 0 $pnum); do set -- ${btnList[b]} bname=$1 if [ -z "$2" ]; then target="title $indx" else target="titleset $indx menu entry $2" fi echo -e "\t\t\t\t" >> "$XMLFILE" [ $b -eq 0 ] && p=$b || let "p=$b-1" [ $b -eq $pnum ] && n=$b || let "n=$b+1" pname=$(echo "${btnList[p]}" | cut -d' ' -f1) nname=$(echo "${btnList[n]}" | cut -d' ' -f1) echo -e "\t\t\t EOF x0=$2 y0=$3 let x1="$tbgW+$x0" let y1="$y0+$stepY-1" [ $j -ne $about ] && right="Play" || right="Title_$1" cat << EOF >> "$thisspuxml" EOF [ $1 -ne $about ] && paction="g0=button; jump title $1;" || paction="g5=101; jump menu entry title;" cat << EOF >> "$XMLFILE" { $paction } EOF cat << EOF >> "$thisspuxml" EOF return 0 } # # Close vmgm xml definition # xml_finish() { cat << EOF >> "$XMLFILE" EOF return 0 } case "$1" in start) xml_start ;; begin_pgc) shift xml_begin_pgc $1 ;; title) shift xml_title "$@" ;; end_pgc) shift xml_end_pgc $1 ;; finish) xml_finish ;; *) error_out ;; esac return 0 } xml_half_title() { if [ $1 -eq $thisvts ]; then if [ $1 -ne $about ]; then baction="g0=button; jump title $1;" else baction="jump menu entry title;" fi else baction="g0=button; g5=$(( $1+100 )); jump menu entry title;" fi cat << EOF >> "$XMLFILE" EOF xxxx0=$2 yyyy0=4 let xxxx1="2+$xxxx0" let yyyy1="6" [ $j -ne $about ] && right="Play" || right="Title_$1" cat << EOF >> "$thisspuxml"