feat: add first demuxer function

Still WIP, not working
demuxer-file
Davide Polonio 2021-09-06 11:48:25 +02:00
parent 98b9a03c42
commit 0be58cabb4
1 changed files with 100 additions and 0 deletions

100
kioskgen.sh Normal file
View File

@ -0,0 +1,100 @@
#!/bin/env bash
set -e
LONG_ARGUMENTS=(
"output:"
"debug"
"help"
)
SHORT_ARGUMENTS=(
"o:"
"d"
"h"
)
OPTS=$(getopt \
--longoptions "$(printf "%s," "${LONG_ARGUMENTS[@]}")" \
--options "$(printf "%s," "${SHORT_ARGUMENTS[@]}")" \
--name "$(basename "${0}")" \
-- "${@}"
)
eval set -- "${OPTS}"
### Utility functions ###
print_help() {
echo "$(basename "${0}") [FLAGS...] FOLDER
<description>
Parameters:
-d --debug Enable debug output
-h --help This very help
"
}
err() {
echo "${@}" >&2
}
create_demuxer_file() {
local demuxer_file="$(mktemp)"
local entry_template=<<EOF
file '${FILE_PATH}'
duration ${DURATION_SECOND}
EOF
local last_entry_template=<<EOF
file '${FILE_PATH}'
duration ${DURATION_SECOND}
file '${FILE_PATH}'
EOF
local last_img=""
for img_to_demux in "${INPUT_FOLDER}"/*.jpeg "${INPUT_FOLDER}"/*.jpg "${INPUT_FOLDER}"/*.png
do
last_img="${img_to_demux}"
local random_duration=$((${RANDOM}%${MAX_PHOTO_DURATION_SECONDS}))
echo <<EOF >> "${demuxer_file}"
file '${img_to_demux}'
duration ${random_duration}
EOF
done
echo "file '${last_img}'" >> "${demuxer_file}"
}
########################
### Config ###
VIDEO_TITLE="output"
MAX_PHOTO_DURATION_SECONDS=10
##############
while [[ $# -gt 0 ]]; do
case "${1}" in
--debug)
set -x
shift 1
;;
-d)
set -x
shift 1
;;
--help)
print_help
exit 0
;;
-h)
print_help
exit 0
;;
--)
shift 1
break
;;
esac
done
INPUT_FOLDER="${1}"
shift 1