forked from laurensorensen/DPDP_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeaccess
More file actions
executable file
·94 lines (94 loc) · 3.4 KB
/
makeaccess
File metadata and controls
executable file
·94 lines (94 loc) · 3.4 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
#!/bin/bash
# makeyoutube, makes a file appropriate for uploading to youtube
version="1.0"
scriptdir=$(dirname $(which "$0"))
. "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};
dependencies=(ffmpeg)
_initialize_make
usage(){
echo
echo "$(basename ${0}) ${version}"
echo "This application will create a high quality h264 file from a video file or package input with the following options."
echo "Dependencies: ${dependencies[@]}"
echo "Usage: $(basename $0) [ -d /path/to/deliver/to/ ] fileorpackage1 [ fileorpackage2 ...]"
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 ":o:d:e:E:nh" opt ; do
case "${opt}" in
o) outputdir_forced="$OPTARG" && _check_outputdir_forced ;;
d) deliverdir="$OPTARG" && check_deliverdir ;;
e) emailaddress_delivery="$OPTARG" ;;
E) emailaddress_outcome="$OPTARG" ;;
n) DRYRUN=true;;
h) usage ;;
*) echo "bad option -$OPTARG" ; usage ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
[ "${emailaddress_outcome}" ] && check_emailaddress "${emailaddress_outcome}"
[ "${emailaddress_delivery}" ] && check_emailaddress "${emailaddress_delivery}"
while [ "${*}" != "" ] ; do
# get context about the input
input="$1"
if [ -z "${outputdir_forced}" ] ; then
[ -d "${input}" ] && { outputdir="${input}/objects/access" && logdir="${input}/metadata/submissionDocumentation/logs" ;};
[ -f "${input}" ] && { outputdir=$(dirname "${input}")"/access" && logdir="$(dirname "${input}")/access/logs" ;};
[ ! "${outputdir}" ] && { outputdir="${input}/objects/access" && 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%.*}.mp4"
[ -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_codectagstring "${sourcefile}"
# clear local arrays
unset inputoptions
unset middleoptions
# encoding options
inputoptions+=(-vsync 0 -nostdin)
if [[ "${codec_tag_string}" == "mjp2" ]] ; then
inputoptions+=(-vcodec libopenjpeg)
middleoptions+=(-movflags faststart)
middleoptions+=(-pix_fmt yuv420p)
middleoptions+=(-c:v libx264)
middleoptions+=(-b:v 750k)
if [ "${height}" -eq "486" -a "${width}" -eq "720" ] ; then
middleoptions+=(-vf "crop=720:480:0:4,yadif")
elif [ "${height}" -eq "512" -a "${width}" -eq "720" ] ;then
middleoptions+=(-vf "crop=720:480:0:32,yadif")
else
middleoptions+=(-vf yadif)
fi
middleoptions+=(-c:a libfaac)
middleoptions+=(-ac 2)
middleoptions+=(-b:a 128k)
middleoptions+=(-f mp4)
get_audio_mapping "${sourcefile}"
middleoptions+=(${audiomapping_ffmpeg[@]})
_prep_ffmpeg_log
_run_critical ffmpeg ${inputoptions[@]} -i "${sourcefile}" ${middleoptions[@]} "${output}"
echo
_summarize_make
_deliver_output
shift
_log -e
done