Fixed various bugs in video copy and merge scripts
[videoscripts/.git] / mkv2dvd
diff --git a/mkv2dvd b/mkv2dvd
new file mode 100755 (executable)
index 0000000..cc07c43
--- /dev/null
+++ b/mkv2dvd
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+SRC=$1
+NAME="${SRC%.*}"
+MPG="${NAME}.mpg"
+DVD="${NAME}.dvd"
+ISO="${NAME}.iso"
+
+export VIDEO_FORMAT=NTSC
+
+if [[ -z $SRC ]] || [[ ! -r $SRC ]]; then
+    echo "-E- You need to specify a valid src video file as an argument"
+    exit 1
+fi
+
+if [[ ! -e "$MPG" ]]; then
+    echo "-> Converting \"$SRC\" -> \"$MPG\""
+    # Convert the SRC video into a DVD compatible mpg2 file
+    ffmpeg -i "$SRC" -target ntsc-dvd -aspect 16:9 "$MPG"
+    if [[ $? != 0 ]]; then
+       echo "-> ffmpeg encountered an error. aborting..."
+       rm "$MPG"
+       exit 1;
+    fi
+fi
+
+echo "-> Creating DVD ISO: $ISO"
+# Create an intermediate DVD dir
+mkdir -p "$DVD"
+# Define the title file
+dvdauthor -o "$DVD" -t "$MPG"
+# Create a table of contents
+dvdauthor -o "$DVD" -T
+# Convert the DVD dir into an ISO image
+genisoimage -dvd-video -o "$ISO" "$DVD"
+# Remove the intermediate DVD dir
+rm -rf "$DVD"
+# Remove the intermediate MPG file
+rm "$MPG"