#!/bin/bash # Just a sample script. Use at your own risk! # # Usage: nuv2dvd [-d] [-r] [ ...] # # -d Only make a dvd directory structure: do not burn. Resulting # file structure can be found in ./dvd.tempdir/dvd # -r Requantize video only using tcrequant with requantization # factor N. This will reduce the space taken for video by a # factor of N. E.g. -r2.0 will result in video that takes # about half the original space. Does not affect audio. DEVICE="/dev/sr0" # DVD burner device. Make sure it's umounted! STREAM_BASE="stream" PROJECTX_BIN="/opt/ProjectX_Source/src/projectX.jar" # Compiled ProjectX .jar PROJECTX_INI="/opt/ProjectX_Source/src/X.ini" # Use an unchanged default X.ini! TEMP_DIR="./dvd.tempdir" function Error () { echo "ERROR: $1" exit 1 } mkdir $TEMP_DIR || Error "Could not make tempdir: $TEMP_DIR" COUNT=0; RVAL=""; BURN="yes" for ARG in $* do echo "Argument: $ARG" case $ARG in -r*) # Requantize RVAL=${ARG##*-r} echo "Requantization factor: $RVAL" ;; -d) # Just write dvd file structure BURN="no" echo "Burn: $BURN" ;; *) # Process the file if [ -s $ARG ]; then echo "Demultiplexing file: $ARG" let "COUNT=$COUNT+1" java -jar $PROJECTX_BIN -c $PROJECTX_INI -n "$STREAM_BASE$COUNT" -o $TEMP_DIR $ARG BNAME="$TEMP_DIR/$STREAM_BASE$COUNT" if [ ! -z $RVAL ]; then mv "$BNAME.mpv" "$BNAME.tmp.mpv" mkfifo "$BNAME.mpv" echo "Starting requantization at factor $RVAL" tcrequant -i "$BNAME.tmp.mpv" -o "$BNAME.mpv" -d2 -f $RVAL & fi mkfifo "$BNAME.mpg" echo "Remultiplexing file: $ARG" mplex -f 8 -V -o "$BNAME.mpg" "$BNAME.mp2" "$BNAME.mpv" & else Error "Not a good file: $ARG" fi ;; esac done echo "Creating dvd file structure with dvdauthor..." dvdauthor -o "$TEMP_DIR/dvd" -f "$TEMP_DIR/$STREAM_BASE"*.mpg dvdauthor -o "$TEMP_DIR/dvd" -T if [ $BURN = "yes" ]; then echo "Burning file structure to dvd device: $DEVICE" growisofs -Z $DEVICE -dvd-video "$TEMP_DIR/dvd" fi echo "Cleaning up temporary files..." rm -v "./$TEMP_DIR/$STREAM_BASE"* if [ $BURN = "yes" ]; then rm -rv "./$TEMP_DIR/dvd" rmdir "./$TEMP_DIR" fi