forked from mediamicroservices/mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakepodcast
executable file
·59 lines (52 loc) · 2.21 KB
/
makepodcast
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
#!/bin/bash
# makepodcast
# makes a file appropriate for podcasting
version="1.0"
scriptdir=`dirname "$0"`
. "$scriptdir/mmvariables"
. "$scriptdir/mmfunctions"
[ ! -f "$scriptdir/mmvariables" -o ! -f "$scriptdir/mmfunctions" ] && { echo "Missing '$scriptdir/mmvariables' and/or '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};
usage(){
echo
echo "$(basename $0) ${version}"
echo "This script may be run interactively by running it with no arguments or may be used with the following options."
echo "Usage: $(basename $0) [ -m mediaid ] [ -f sourcefile ]"
echo " -m mediaid"
echo " -f sourcefile"
exit
}
# command-line options to set mediaid and original variables
while getopts ":hm:f:" opt; do
case "$opt" in
h) usage ;;
m) mediaid="$OPTARG";;
f) sourcefile="$OPTARG";;
\?) echo "Invalid option: -$OPTARG" ; exit 1 ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
[ "$#" = 0 ] && { ask_input ; once="y" ;};
while [ "$*" != "" -o "$once" = "y" ] ; do
once="n"
[ "$#" != 0 ] && input="$1"
[ -d "$input" ] && { outputdir="$input/objects/access/podcast" && logdir="$input/metadata/submissionDocumentation/logs" ;};
[ -f "$input" ] && { outputdir=`dirname "$input"`"/access/podcast" && logdir="`dirname "$input"`/access/logs" ;};
[ ! "$outputdir" ] && { outputdir="$input/objects/access/podcast" && logdir="$input/metadata/submissionDocumentation/logs" ;};
find_input "$input"
filename=`basename "$sourcefile"`
mediaid=`basename "$input" | cut -d. -f1`
podcastoutput="$outputdir/${mediaid%.*}_podcast.mov"
[ -s "$podcastoutput" ] && { report -wt "WARNING $podcastoutput already exists, skipping transcode" ; exit 1 ;};
mkdir -p "$outputdir"
middleoptions="-movflags faststart -pix_fmt yuv420p -c:v libx264 -b:v 1500k -maxrate:v 3000k -minrate:v 375k -bufsize:v 6000k -vf 'yadif,scale=640:trunc(ow/dar/2)*2:interl=1' -c:a libfaac -b:a 96k "
if [ "$logdir" != "" ] ; then
mkdir -p "$logdir"
export FFREPORT="file=${logdir}/%p_%t_$(basename $0)_${version}.txt"
inputoptions+=" -report"
fi
makepodcastcommand="ffmpeg $inputoptions -i \"$sourcefile\" $middleoptions \"$podcastoutput\""
report -dt "Running: $makepodcastcommand"
eval "$makepodcastcommand"
shift
done