aboutsummaryrefslogtreecommitdiff
path: root/devscripts/generate-testfile.sh
diff options
context:
space:
mode:
Diffstat (limited to 'devscripts/generate-testfile.sh')
-rwxr-xr-xdevscripts/generate-testfile.sh36
1 files changed, 18 insertions, 18 deletions
diff --git a/devscripts/generate-testfile.sh b/devscripts/generate-testfile.sh
index e8bcbe8..fab91cd 100755
--- a/devscripts/generate-testfile.sh
+++ b/devscripts/generate-testfile.sh
@@ -125,7 +125,7 @@ readonly EXIT_OK EXIT_RUNTIME_FAILURE EXIT_USAGE_ERROR EXIT_CONFIG_ERROR EXIT_MI
# OUTPUT HELPERS
###############################################################################
-emit() {
+function emit() {
local prefix="$1"
local color="$2"
shift 2
@@ -151,29 +151,29 @@ emit() {
printf "\n"
}
-error() {
+function error() {
emit "==> ERROR:" "$RED" "$@" >&2
}
-msg() {
+function msg() {
if [[ $QUIET -eq 0 ]]; then
emit "==>" "$GREEN" "$@"
fi
}
-warn() {
+function warn() {
if [[ $QUIET -eq 0 ]]; then
emit "==>" "$YELLOW" "$@"
fi
}
-verbose() {
+function verbose() {
if [[ $VERBOSE -eq 1 && $QUIET -eq 0 ]]; then
emit "==>" "$BLUE" "$@"
fi
}
-debug() {
+function debug() {
if [[ $DEBUG -eq 1 ]]; then
emit "==> DEBUG:" "$MAGENTA" "$@"
fi
@@ -183,7 +183,7 @@ debug() {
# HELP AND VERSION OUTPUT
###############################################################################
-print_help() {
+function print_help() {
printf "${BOLD}${MAGENTA}%s${ALL_OFF} - ${BOLD}${CYAN}%s${ALL_OFF} - ${BOLD}%s${ALL_OFF}
${BOLD}${BLUE}Usage:${ALL_OFF} ${BOLD}${MAGENTA}%s${ALL_OFF} ${BOLD}${YELLOW}[OPTION]...${ALL_OFF} ${BOLD}${GREEN}[OUTPUT]${ALL_OFF}
@@ -221,7 +221,7 @@ ${BOLD}${BLUE}Examples:${ALL_OFF}
"$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME"
}
-print_version() {
+function print_version() {
printf "${RED}${BOLD}Scriptname:${ALL_OFF} %s
${GREEN}${BOLD}Version:${ALL_OFF} %s
${YELLOW}${BOLD}Description:${ALL_OFF} %s
@@ -272,7 +272,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" \
# disabled. If FORCE_COLOR is set, colors are always enabled.
###############################################################################
-setup_colors() {
+function setup_colors() {
if [[ "$ENABLE_COLOR" -eq 1 ]]; then
if tput setaf 0 >/dev/null 2>&1; then
debug "Setting colors via tput"
@@ -313,7 +313,7 @@ setup_colors() {
# GENERATION HELPERS
###############################################################################
-require_command() {
+function require_command() {
local command_name="$1"
command -v "$command_name" >/dev/null 2>&1 || {
@@ -322,28 +322,28 @@ require_command() {
}
}
-validate_resolution() {
+function validate_resolution() {
if [[ ! "$RESOLUTION" =~ ^[1-9][0-9]*x[1-9][0-9]*$ ]]; then
error "Resolution must use WIDTHxHEIGHT format:" "$RESOLUTION"
exit $EXIT_USAGE_ERROR
fi
}
-validate_length() {
+function validate_length() {
if [[ "$LENGTH" =~ ^- ]]; then
error "Length must be a positive ffmpeg duration:" "$LENGTH"
exit $EXIT_USAGE_ERROR
fi
}
-validate_frame_rate() {
+function validate_frame_rate() {
if [[ ! "$FRAME_RATE" =~ ^[1-9][0-9]*([.][0-9]+)?$ ]]; then
error "Frame rate must be a positive number:" "$FRAME_RATE"
exit $EXIT_USAGE_ERROR
fi
}
-extension_for_codec() {
+function extension_for_codec() {
case "$CODEC" in
libvpx | libvpx-vp9)
printf "webm"
@@ -357,7 +357,7 @@ extension_for_codec() {
esac
}
-sanitized_name_part() {
+function sanitized_name_part() {
local value="$1"
value="${value//\//-}"
value="${value//:/-}"
@@ -365,7 +365,7 @@ sanitized_name_part() {
printf "%s" "$value"
}
-default_output_path() {
+function default_output_path() {
local extension codec_part length_part
extension="$(extension_for_codec)"
codec_part="$(sanitized_name_part "$CODEC")"
@@ -374,13 +374,13 @@ default_output_path() {
printf "%s/%s-%s-%ss.%s" "$OUTPUT_DIR" "$codec_part" "$RESOLUTION" "$length_part" "$extension"
}
-print_command() {
+function print_command() {
local quoted_command
printf -v quoted_command '%q ' "${FFMPEG_COMMAND[@]}"
printf "%s\n" "${quoted_command% }"
}
-generate_test_file() {
+function generate_test_file() {
local output_file="$1"
if [[ -e "$output_file" && $OVERWRITE -eq 0 ]]; then