forked from laurensorensen/DPDP_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakedvd
More file actions
executable file
·130 lines (123 loc) · 5.66 KB
/
makedvd
File metadata and controls
executable file
·130 lines (123 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# makedvd
version="1.0"
scriptdir=$(dirname $(which "$0"))
. "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};
dependencies=(ffmpeg dvdauthor mkisofs)
_initialize_make
usage(){
echo
echo "$(basename ${0}) ${version}"
echo "This application will create a DVD .iso file from a video file or package input with the following options."
echo "Dependencies: ${dependencies[@]}"
echo "Usage: $(basename $0) [ -v dvd_label_prefix ] fileorpackage1 [ fileorpackage2 ...]"
echo " -v dvdlabelprefix (optional)"
echo " -d directory ( directory to deliver the resulting file to )"
echo " -o directory ( directory to write the resulting file to )"
echo " -n (dry-run mode, show the commands that would be run but don't do anything)"
echo " -e emailaddress ( send an email about the delivery, only valid if -d is used )"
echo " -E emailaddress ( send an email about process outcome )"
echo " -h ( display this help )"
echo
exit
}
[ "${#}" = 0 ] && usage
# command-line options to set mediaid and original variables
OPTIND=1
while getopts ":v:o:d:e:E:nh" opt ; do
case "${opt}" in
v) DVDLABELPREFIX="$OPTARG";;
o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;;
d) deliverdir="$OPTARG" && check_deliverdir ;;
e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;;
E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;;
n) DRYRUN=true;;
h) usage ;;
*) echo "bad option -$OPTARG" ; usage ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
while [ "${*}" != "" ] ; do
# get context about the input
input="$1"
if [ -z "${outputdir_forced}" ] ; then
[ -d "${input}" ] && { outputdir="${input}/objects/access/dvd" && logdir="${input}/metadata/submissionDocumentation/logs" ;};
[ -f "${input}" ] && { outputdir=$(dirname "${input}")"/access/dvd" && logdir="$(dirname "${input}")/access/logs" ;};
[ ! "${outputdir}" ] && { outputdir="${input}/objects/access/dvd" && logdir="${input}/metadata/submissionDocumentation/logs" ;};
else
outputdir="${outputdir_forced}"
logdir="${outputdir}/logs"
fi
_find_input "${input}"
mediaid=$(basename "${input}" | cut -d. -f1)
# set up output
_log -b
output="${outputdir}/${mediaid%.*}.iso"
[ -s "${output}" ] && { report -wt "WARNING ${output} already exists, skipping transcode" ; shift ; continue ;};
_run mkdir -p "${outputdir}"
# get information on the input
get_height "${sourcefile}"
get_width "${sourcefile}"
get_dar "${sourcefile}"
darratio=$(echo "scale=3 ; $dar" | bc)
if [ $(echo "scale=5 ; $darratio > 1.5" | bc -l) = 1 ] ;then
aspect="16/9"
dvdaspect="16:9"
else
aspect="4/3"
dvdaspect="4:3"
fi
get_maxdvdbitrate "$sourcefile"
# clear local arrays
unset inputoptions
unset middleoptions
# encoding options
middleoptions+=(-r:v ntsc)
middleoptions+=(-c:v mpeg2video)
middleoptions+=(-c:a ac3)
middleoptions+=(-f dvd)
middleoptions+=(-qscale:v 2)
middleoptions+=(-mbd rd)
middleoptions+=(-s 720x480)
middleoptions+=(-pix_fmt yuv420p)
middleoptions+=(-g 18)
middleoptions+=(-b:v $MAXDVDBITRATE)
middleoptions+=(-bt 400k)
middleoptions+=(-maxrate $MAXDVDBITRATE)
middleoptions+=(-minrate 0)
middleoptions+=(-bufsize 3600k)
middleoptions+=(-packetsize 2048)
middleoptions+=(-muxrate 10080000)
middleoptions+=(-lmin 1)
middleoptions+=(-lmax 200000)
middleoptions+=(-b:a 448000)
middleoptions+=(-ar 48000)
if [[ "${height}" == 486 && "${width}" == 720 ]] ; then
middleoptions+=(-vf "fieldorder=bff,crop=720:480:0:4,setdar=${aspect}" -aspect ${aspect})
elif [[ "{$height}" == 480 && "${width}" == 720 ]] ; then
middleoptions+=(-vf "fieldorder=bff,setdar=${aspect}" -aspect ${aspect})
elif [[ "${height}" == 512 && "${width}" == 720 ]] ; then
middleoptions+=(-vf "fieldorder=bff,crop=720:480:0:32,setdar=${aspect}" -aspect ${aspect})
else
middleoptions+=(-vf "fieldorder=bff,scale=720:480:interl=1,setdar=${aspect}" -aspect ${aspect})
fi
inputoptions+=" -y"
_prep_ffmpeg_log
# making the initial mpeg2 for the dvd
_run ffmpeg ${inputoptions[@]} -i "${sourcefile}" ${middleoptions[@]} "${outputdir}/${mediaid%.*}.mpeg"
# Making DVD VIDEO_TS folder, chapters every 5 minutes, dvdauthor will ignore chapter markers greater than duration
export VIDEO_FORMAT=NTSC
_run_critical dvdauthor --title -v "ntsc+${dvdaspect}" -a ac3+en -c 0,5:00,10:00,15:00,20:00,25:00,30:00,35:00,40:00,45:00,50:00,55:00,1:00:00,1:05:00,1:10:00,1:15:00,1:20:00,1:25:00,1:30:00,1:35:00,1:40:00,1:45:00,1:50:00,1:55:00,2:00:00,2:05:00,2:10:00,2:15:00,2:20:00,2:25:00,2:30:00,2:35:00,2:40:00,2:45:00,2:50:00,2:55:00,3:00:00,3:05:00,3:10:00,3:15:00,3:20:00,3:25:00,3:30:00,3:35:00,3:40:00,3:45:00,3:50:00,3:55:00 -f "${outputdir}/${mediaid%.*}.mpeg" -o "${outputdir}/${mediaid%.*}/" 2> "${logdir}/dvdauthor_$(get_iso8601_c)_$(basename $0)_${version}.txt"
_run rm "${outputdir}/${mediaid%.*}.mpeg"
_run_critical dvdauthor -T -o "${outputdir}/${mediaid%.*}/"
# Making DVD image file.
volname=$(echo "${DVDLABELPREFIX}${mediaid}")
_run_critical mkisofs -f -dvd-video -udf -V "${volname:0:32}" -v -v -o "${output}" "${outputdir}/${mediaid%.*}" 2> "${logdir}/mkisofs_$(get_iso8601_c)_$(basename $0)_${version}.txt"
_run rm -r "${outputdir}/${mediaid%.*}/"
echo
_summarize_make
_deliver_output
shift
_log -e
done