Skip to content

Commit 0665a1d

Browse files
committed
update find_input to id av files via ffmpeg rather than extension
1 parent 01cae86 commit 0665a1d

11 files changed

+44
-55
lines changed

makebroadcast

+2-4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ while [ "${*}" != "" ] ; do
7272
OUTPUTDIR="${OUTPUTDIR_FORCED}"
7373
LOGDIR="${OUTPUTDIR}/logs"
7474
fi
75+
_unset_variables
7576
_find_input "${INPUT}"
7677
MEDIAID=$(_readingestlog "media ID")
7778
if [[ ! "${MEDIAID}" ]] ; then
@@ -90,7 +91,6 @@ while [ "${*}" != "" ] ; do
9091
OUTTIME=""
9192
audio_adjustment=""
9293

93-
_unset_variables
9494
_get_broadcastduration "${SOURCEFILE}"
9595
_get_videostreamcount "${SOURCEFILE}"
9696
_get_audiostreamcount "${SOURCEFILE}"
@@ -339,8 +339,6 @@ while [ "${*}" != "" ] ; do
339339
_prep_ffmpeg_log
340340
if [ "${CONCATSOURCE}" != "" ] ; then
341341
FFMPEGINPUT="${CONCATSOURCE}"
342-
else
343-
FFMPEGINPUT="${SOURCEFILE}"
344342
fi
345343

346344
# slate process
@@ -375,7 +373,7 @@ MIDDLEOPTIONS+=(-map "[with_slate_video]" -map "[with_slate_stereo1]" -map "[wit
375373
#MIDDLEOPTIONS: ${MIDDLEOPTIONS[@]}
376374
#OUTPUT: ${OUTPUT}")
377375

378-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
376+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
379377
echo
380378
_summarize_make
381379
_deliver_output "${MAKEBROADCAST_DELIVERY_EMAIL_TO}"

makedvd

+2-5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ while [ "${*}" != "" ] ; do
6060
OUTPUTDIR="${OUTPUTDIR_FORCED}"
6161
LOGDIR="${OUTPUTDIR}/logs"
6262
fi
63+
_unset_variables
6364
_find_input "${INPUT}"
6465
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
6566

@@ -80,8 +81,6 @@ while [ "${*}" != "" ] ; do
8081
_get_maxdvdbitrate "${SOURCEFILE}"
8182

8283
# clear local arrays
83-
_unset_variables
84-
8584
_get_videostreamcount "${SOURCEFILE}"
8685
_get_audiostreamcount "${SOURCEFILE}"
8786

@@ -150,13 +149,11 @@ while [ "${*}" != "" ] ; do
150149
# making the initial mpeg2 for the dvd
151150
if [ "${CONCATSOURCE}" != "" ] ; then
152151
FFMPEGINPUT="${CONCATSOURCE}"
153-
else
154-
FFMPEGINPUT="${SOURCEFILE}"
155152
fi
156153

157154
_filter_to_middle_option
158155

159-
_run_critical ffmpeg ${INPUTOPTIONS[@]} -i "${FFMPEGINPUT}" ${MIDDLEOPTIONS[@]} "${OUTPUTDIR}/${MEDIAID%.*}.mpeg"
156+
_run_critical ffmpeg ${INPUTOPTIONS[@]} "${FFMPEGINPUT[@]}" ${MIDDLEOPTIONS[@]} "${OUTPUTDIR}/${MEDIAID%.*}.mpeg"
160157
# Making DVD VIDEO_TS folder, chapters every 5 minutes, dvdauthor will ignore chapter markers greater than duration
161158
export VIDEO_FORMAT=NTSC
162159
_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"

makeflv

+2-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ while [ "${*}" != "" ] ; do
5656
OUTPUTDIR="${OUTPUTDIR_FORCED}"
5757
LOGDIR="${OUTPUTDIR}/logs"
5858
fi
59+
_unset_variables
5960
_find_input "${INPUT}"
6061
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
6162

6263
_set_up_output
6364

64-
# clear local arrays
65-
_unset_variables
66-
6765
# encoding options
6866
_get_codectagstring "${SOURCEFILE}"
6967
_get_videostreamcount "${SOURCEFILE}"
@@ -111,13 +109,11 @@ while [ "${*}" != "" ] ; do
111109
_prep_ffmpeg_log
112110
if [ "${CONCATSOURCE}" != "" ] ; then
113111
FFMPEGINPUT="${CONCATSOURCE}"
114-
else
115-
FFMPEGINPUT="${SOURCEFILE}"
116112
fi
117113

118114
_filter_to_middle_option
119115

120-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
116+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
121117
echo
122118
_summarize_make
123119
_deliver_output

makeframes

+2-6
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ while [ "${*}" != "" ] ; do
4444
[ -d "${INPUT}" ] && { OUTPUTDIR="${INPUT}/objects/access/images" && LOGDIR="${INPUT}/metadata/logs" ;};
4545
[ -f "${INPUT}" ] && { OUTPUTDIR=$(dirname "${INPUT}")"/access/images" && LOGDIR="$(dirname "${INPUT}")/access/logs" ;};
4646
[ ! "$OUTPUTDIR" ] && { OUTPUTDIR="${INPUT}/objects/access/images" && LOGDIR="${INPUT}/metadata/logs" ;};
47+
_unset_variables
4748
_find_input "${INPUT}"
4849

4950
MEDIAID=$(basename "${1}" | cut -d. -f1)
5051

51-
# clear local arrays
52-
_unset_variables
53-
5452
# encoding options
5553
_get_codectagstring "${SOURCEFILE}"
5654
INPUTOPTIONS+=(-vsync 0)
@@ -75,11 +73,9 @@ while [ "${*}" != "" ] ; do
7573
_prep_ffmpeg_log -q
7674
if [ "${CONCATSOURCE}" != "" ] ; then
7775
FFMPEGINPUT="${CONCATSOURCE}"
78-
else
79-
FFMPEGINPUT="${SOURCEFILE}"
8076
fi
8177

82-
_run_critical ffmpeg -y ${INPUTOPTIONS[@]} -v warning -ss "$START" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
78+
_run_critical ffmpeg -y ${INPUTOPTIONS[@]} -v warning -ss "$START" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
8379
done
8480
echo
8581
if [ -d "${DELIVERDIR}" ] ; then

makemp3

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ while [ "${*}" != "" ] ; do
5959
LOGDIR="${OUTPUTDIR}/logs"
6060
fi
6161

62+
_unset_variables
6263
_find_input "${INPUT}"
6364

6465
FILENAME=$(basename "${SOURCEFILE}")
@@ -68,8 +69,6 @@ while [ "${*}" != "" ] ; do
6869

6970
_set_up_output
7071

71-
_unset_variables
72-
7372
INPUTOPTIONS+=(-nostdin)
7473
MIDDLEOPTIONS+=(-map 0:a:0)
7574
MIDDLEOPTIONS+=(-ac 2)
@@ -84,7 +83,7 @@ while [ "${*}" != "" ] ; do
8483
INPUTOPTIONS+=(-v warning -stats)
8584
fi
8685
_report -dt "Working on $(basename "${OUTPUT}")."
87-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${SOURCEFILE}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
86+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
8887
_report -dt "Adjusting highest audio peak to full scale..."
8988
normalize --peak -v "${OUTPUT}"
9089
echo

makepodcast

+2-6
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ while [ "${*}" != "" ] ; do
5454
OUTPUTDIR="${OUTPUTDIR_FORCED}"
5555
LOGDIR="${OUTPUTDIR}/logs"
5656
fi
57+
_unset_variables
5758
_find_input "${INPUT}"
5859
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
5960

6061
_set_up_output
6162

62-
# clear local arrays
63-
_unset_variables
64-
6563
# encoding options
6664
_get_codectagstring "${SOURCEFILE}"
6765
_get_videostreamcount "${SOURCEFILE}"
@@ -90,13 +88,11 @@ while [ "${*}" != "" ] ; do
9088
_prep_ffmpeg_log
9189
if [ "${CONCATSOURCE}" != "" ] ; then
9290
FFMPEGINPUT="${CONCATSOURCE}"
93-
else
94-
FFMPEGINPUT="${SOURCEFILE}"
9591
fi
9692

9793
_filter_to_middle_option
9894

99-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
95+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
10096
echo
10197
_summarize_make
10298
_deliver_output "${MAKEYOUTUBE_DELIVERY_EMAIL_TO}"

makeprores

+2-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ while [ "${*}" != "" ] ; do
5656
OUTPUTDIR="${OUTPUTDIR_FORCED}"
5757
LOGDIR="${OUTPUTDIR}/logs"
5858
fi
59+
_unset_variables
5960
_find_input "${INPUT}"
6061
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
6162

6263
_set_up_output
6364

64-
# clear local arrays
65-
_unset_variables
66-
6765
# encoding options
6866
_get_codectagstring "${SOURCEFILE}"
6967
_get_videostreamcount "${SOURCEFILE}"
@@ -103,10 +101,8 @@ while [ "${*}" != "" ] ; do
103101
_prep_ffmpeg_log
104102
if [ "${CONCATSOURCE}" != "" ] ; then
105103
FFMPEGINPUT="${CONCATSOURCE}"
106-
else
107-
FFMPEGINPUT="${SOURCEFILE}"
108104
fi
109-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
105+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
110106
echo
111107
_summarize_make
112108
_deliver_output

makeresourcespace

+2-6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ while [ "${*}" != "" ] ; do
5959
else
6060
OUTPUTDIR="${OUTPUTDIR_FORCED}"
6161
fi
62+
_unset_variables
6263
_find_input "${INPUT}"
6364
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
6465

@@ -69,9 +70,6 @@ while [ "${*}" != "" ] ; do
6970
_get_width "${SOURCEFILE}"
7071
_get_seconds "${SOURCEFILE}"
7172

72-
# clear local arrays
73-
_unset_variables
74-
7573
# encoding options
7674
_get_codectagstring "${SOURCEFILE}"
7775
_get_videostreamcount "${SOURCEFILE}"
@@ -116,13 +114,11 @@ while [ "${*}" != "" ] ; do
116114

117115
if [ "${CONCATSOURCE}" != "" ] ; then
118116
FFMPEGINPUT="${CONCATSOURCE}"
119-
else
120-
FFMPEGINPUT="${SOURCEFILE}"
121117
fi
122118

123119
_filter_to_middle_option
124120

125-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
121+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
126122
echo
127123
_summarize_make
128124
_deliver_output

makewaveform

+2-6
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ while [ "${*}" != "" ] ; do
5454
OUTPUTDIR="${OUTPUTDIR_FORCED}"
5555
LOGDIR="${OUTPUTDIR}/logs"
5656
fi
57+
_unset_variables
5758
_find_input "${INPUT}"
5859
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
5960

6061
_set_up_output
6162

62-
# clear local arrays
63-
_unset_variables
64-
6563
# encoding options
6664
_get_audiostreamcount "${SOURCEFILE}"
6765
INPUTOPTIONS+=(-nostdin)
@@ -75,13 +73,11 @@ while [ "${*}" != "" ] ; do
7573
_prep_ffmpeg_log
7674
if [ "${CONCATSOURCE}" != "" ] ; then
7775
FFMPEGINPUT="${CONCATSOURCE}"
78-
else
79-
FFMPEGINPUT="${SOURCEFILE}"
8076
fi
8177

8278
_filter_to_middle_option
8379

84-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
80+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
8581
echo
8682
_summarize_make
8783
_deliver_output "${MAKEYOUTUBE_DELIVERY_EMAIL_TO}"

makeyoutube

+2-6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ while [ "${*}" != "" ] ; do
6262
OUTPUTDIR="${OUTPUTDIR_FORCED}"
6363
LOGDIR="${OUTPUTDIR}/logs"
6464
fi
65+
_unset_variables
6566
_find_input "${INPUT}"
6667
MEDIAID=$(basename "${INPUT}" | cut -d. -f1)
6768
INGESTLOG="${LOGDIR}/capture.log"
@@ -73,9 +74,6 @@ while [ "${*}" != "" ] ; do
7374
_get_width "${SOURCEFILE}"
7475
_get_seconds "${SOURCEFILE}"
7576

76-
# clear local arrays
77-
_unset_variables
78-
7977
# encoding options
8078
_get_codectagstring "${SOURCEFILE}"
8179
_get_videostreamcount "${SOURCEFILE}"
@@ -122,13 +120,11 @@ while [ "${*}" != "" ] ; do
122120

123121
if [ "${CONCATSOURCE}" != "" ] ; then
124122
FFMPEGINPUT="${CONCATSOURCE}"
125-
else
126-
FFMPEGINPUT="${SOURCEFILE}"
127123
fi
128124

129125
_filter_to_middle_option
130126

131-
_run_critical ffmpeg "${INPUTOPTIONS[@]}" -i "${FFMPEGINPUT}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
127+
_run_critical ffmpeg "${INPUTOPTIONS[@]}" "${FFMPEGINPUT[@]}" "${MIDDLEOPTIONS[@]}" "${OUTPUT}"
132128
echo
133129
_summarize_make
134130
_deliver_output "${MAKEYOUTUBE_DELIVERY_EMAIL_TO}"

mmfunctions

+24-1
Original file line numberDiff line numberDiff line change
@@ -571,14 +571,37 @@ _find_input (){
571571
CONCATSOURCE=""
572572
SOURCEFILE=""
573573
ISOBJECT=""
574+
unset FFMPEGINPUT
574575
if [ -f "${1}" ] ; then
575576
SOURCEFILE="${1}"
577+
FFMPEGINPUT+=(-i)
578+
FFMPEGINPUT+=("${SOURCEFILE}")
576579
elif [[ -f "${1}/objects/service/$(basename "${1}").mov" && "${ADDSLATE}" != "Y" ]] ; then
577580
ISOBJECT="N"
578581
SOURCEFILE="${1}/objects/service/$(basename "${1}").mov"
582+
FFMPEGINPUT+=(-i)
583+
FFMPEGINPUT+=("${SOURCEFILE}")
579584
elif [ -d "${1}/objects" ] ; then
580585
ISOBJECT="Y"
581-
SOURCEFILE=$(find "${1}/objects" -maxdepth 1 -mindepth 1 -type f ! -iname "*_SLATE.mov" \( -iname "*.mov" -o -iname "*.mxf" -o -iname "*.mp4" -o -iname "*.dv" -o -iname "*.mpeg" -o -iname "*.iso" -o -iname "*.mkv" -o -iname "*.m2ts" -o -iname "*.ts" \) ! -name ".*" | head -n 1)
586+
INPUTFILES=$(_maketemp)
587+
# find av files in a directory and output to a temp list
588+
find "${1}/objects" -type f ! -path "*/access/*" ! -path "*/service/*" ! -name ".DS_Store" | while read file ; do
589+
streamcount=$(ffprobe -loglevel quiet "$file" -show_entries format=nb_streams -of default=nw=1:nk=1)
590+
if [[ "$streamcount" > 0 ]] ; then
591+
_report -d "Input file: $file"
592+
echo "$file" >> "${INPUTFILES}"
593+
fi
594+
done
595+
INPUTFILECOUNT=$(wc -l "${INPUTFILES}" | awk '{print $1}')
596+
if [[ "${INPUTFILECOUNT}" = 0 ]] ; then
597+
_report -w "Error no audiovisual input files were found."
598+
_writeerrorlog "_find_input" "A valid source audiovisual file was not found, so the script could not proceed."
599+
exit 1
600+
elif [[ "${INPUTFILECOUNT}" = 1 ]] ; then
601+
SOURCEFILE=$(cat "${INPUTFILES}" | head -n 1)
602+
FFMPEGINPUT+=(-i)
603+
FFMPEGINPUT+=("${SOURCEFILE}")
604+
fi
582605
else
583606
_report -wt "A valid source file isn't found."
584607
_writeerrorlog "_find_input" "A valid source file was not found, so the script could not proceed."

0 commit comments

Comments
 (0)