-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmakebroadcast
executable file
·116 lines (103 loc) · 3.82 KB
/
makebroadcast
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
#!/bin/bash
# makebroadcast
# make broadcast version
scriptdir=`dirname "$0"`
. "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};
# command-line options to set mediaid and original
OPTIND=1
while getopts lc opt ; do
case $opt in
l) audiomapping=" -map_audio_channel 0:1:0:0:1:0 -map_audio_channel 0:1:0:0:1:1 " ;;
c) cropdetect="Y" ;;
f) input="$OPTARG" ; once="y" ;;
esac
done
shift $(( ${OPTIND} - 1 ))
[ "$#" = 0 -a ! "$input" ] && { ask_input ; once="y" ;};
version="1.2"
# history
# v 1.1 change from mov output to mxf output, force all output to hd
# v 1.2 revert to mov and ffmbc
cleanup(){
log -a "Process aborted"
exit 1
}
trap cleanup SIGHUP SIGINT SIGTERM
while [ "$*" != "" -o "$once" = "y" ] ; do
once="n"
[ "$#" != 0 ] && input="$1"
[ -d "$input" ] && { outputdir="$input/objects/service" && logdir="$input/metadata/submissionDocumentation/logs" ;};
[ -f "$input" ] && { outputdir=`dirname "$input"`"/service" && logdir="`dirname "$input"`/service/logs" ;};
[ ! "$outputdir" ] && { outputdir="$input/objects/service" && logdir="$input/metadata/submissionDocumentation/logs" ;};
find_input "$input"
filename=`basename "$sourcefile"`
mediaid=`basename "$input" | cut -d. -f1`
log -b
servicefile="$outputdir/${mediaid%.*}.mov"
[ -s "$servicefile" ] && { report -wt "WARNING $servicefile already exists, skipping transcode" ; shift ; continue ;};
report -dt "STATUS Transcoding for Omneon compliance."
ffmpeg_opts=" -r ntsc"
if [ -n "$audiomapping" ] ; then
ffmpeg_opts+=" $audiomapping"
else
has_first_two_tracks_mono "$sourcefile"
if [ "$MULTIMONO" = "Y" ] ; then
audiomapping=" -map_audio_channel 0.1:0:0.1:0 -map_audio_channel 0.2:0:0.1:1 "
ffmpeg_opts+=" $audiomapping"
fi
fi
# choose video encoding strategy, if source is xdcam 50 mb/sec ntsc then copy the video, else transcode
get_codectagstring "$sourcefile"
if [ "$codec_tag_string" = "xd5b" ] ; then
ffmpeg_opts+=" -c:v copy"
else
<<<<<<< HEAD
if [ "$cropdetect" = "Y" ] ; then
get_cropdetection "$sourcefile"
echo YEAHYAEAH
if [ -n "$CROPADJ" ] ;then
ffmpeg_opts+=" -vf '${CROPADJ},pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'"
else
ffmpeg_opts+=" -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'"
fi
else
ffmpeg_opts+=" -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'"
fi
ffmpeg_opts+=" -target xdcamhd422 -vtag xd5b -tff -aspect 16:9 -threads 4"
=======
ffmpeg_opts+=" -vf 'pad=ih*16/9/sar:ih:(ow-iw)/2:(oh-ih)/2,scale=1920:1080:interl=1'"
ffmpeg_opts+=" -target xdcamhd422 -vtag xd5b -tff -threads 8"
>>>>>>> makebroadcast: consider sar while scaling
fi
# add audio options
ffmpeg_opts+=" -acodec pcm_s24le -ar 48k -ac 2"
# set input options for ffmpeg
<<<<<<< HEAD
inputoptions=" -y -threads 4"
=======
inputoptions=" -y"
inputoptions+=" -threads 8"
inputoptions+=" -loglevel verbose"
>>>>>>> makebroadcast: enable multi-threading and increase verbosity
mkdir -p "$outputdir"
ffmpeg_command="ffmbc $inputoptions -i \"$sourcefile\" $ffmpeg_opts \"$servicefile\""
# log ffmpeg process
if [ "$logdir" != "" ] ; then
mkdir -p "$logdir"
reportfile="ffmbc_$(date '+%Y%m%d-%H%M%S')_$(basename $0)_${version}.txt"
echo "ffmbc started on $(date '+%F at %T')" > "${logdir}/${reportfile}"
echo "Report written to \"${reportfile}\"" >> "${logdir}/${reportfile}"
echo "Command line:" >> "${logdir}/${reportfile}"
fi
report -dt "Running: ${ffmpeg_command}"
echo "$ffmpeg_command" >> "${logdir}/${reportfile}"
eval "$ffmpeg_command"
ffmpeg_err="$?"
<<<<<<< HEAD
[ "$ffmpeg_err" -gt "0" ] && { report -wt "ffmpeg failed with error ${ffmpeg_err}" && exit 1;};
=======
[ "$ffmpeg_err" -gt "0" ] && { report "${RED}ffmbc failed with error ${ffmpeg_err}${NC}" && exit 1;};
>>>>>>> makebroadcast: remove logging for now
shift
done
log -e