Updated for Ubuntu 22.04. Also fixed merge videos cmin check
[videoscripts/.git] / mkv2dvd
1 #!/bin/bash
2
3 SRC=$1
4 NAME="${SRC%.*}"
5 MPG="${NAME}.mpg"
6 DVD="${NAME}.dvd"
7 ISO="${NAME}.iso"
8
9 export VIDEO_FORMAT=NTSC
10
11 if [[ -z $SRC ]] || [[ ! -r $SRC ]]; then
12     echo "-E- You need to specify a valid src video file as an argument"
13     exit 1
14 fi
15
16 if [[ ! -e "$MPG" ]]; then
17     echo "-> Converting \"$SRC\" -> \"$MPG\""
18     # Convert the SRC video into a DVD compatible mpg2 file
19     ffmpeg -i "$SRC" -target ntsc-dvd -aspect 16:9 "$MPG"
20     if [[ $? != 0 ]]; then
21         echo "-> ffmpeg encountered an error. aborting..."
22         rm "$MPG"
23         exit 1;
24     fi
25 fi
26
27 echo "-> Creating DVD ISO: $ISO"
28 # Create an intermediate DVD dir
29 mkdir -p "$DVD"
30 # Define the title file
31 dvdauthor -o "$DVD" -t "$MPG"
32 # Create a table of contents
33 dvdauthor -o "$DVD" -T
34 # Convert the DVD dir into an ISO image
35 genisoimage -dvd-video -o "$ISO" "$DVD"
36 # Remove the intermediate DVD dir
37 rm -rf "$DVD"
38 # Remove the intermediate MPG file
39 rm "$MPG"