DATE_BSD="date -r "
DATE_LINUX="date -d @"
-DATE="$DATE_BSD"
+DATE="$DATE_LINUX"
# Used as default 10 seconds pause before retrying
TARGET_DURATION=10
# Extract first stream from HLS Master-Playlist
function resolveFirstStream() {
local hls="$1"
- TMPFILE=$(mktemp -t "$SCRIPT_NAME") || fatal "Can not write tmp-file"
+ TMPFILE=$(mktemp "$SCRIPT_NAME.XXXXXXXX") || fatal "Can not write tmp-file"
url=$(curl $BASIC_CURL_PARAMS -o "$TMPFILE" "$hls" -w "%{url_effective}")
if [ $? -eq 0 ]; then
while IFS="" read line; do
real_time=$(date +%s)
stream_time=$(($real_time - $STREAM_TIME_SCREW))
- pretty_time=$($DATE ${stream_time%.*} +"%Y-%m-%d %H:%M:%S")
+ pretty_time=$($DATE${stream_time%.*} +"%Y-%m-%d %H:%M:%S")
echo "NOTICE: Using time-offset of -$STREAM_TIME_SCREW seconds so time is $pretty_time, real time is $(date ${realtime} +"%Y-%m-%d %H:%M:%S")"
echo "$pretty_time: Started monitoring using: $stream"
starttime=$(date +%s)
warn_not_a_playlist=1
- TMPFILE=$(mktemp -t "$SCRIPT_NAME") || fatal "Can not write tmp-file"
+ TMPFILE=$(mktemp "$SCRIPT_NAME.XXXXXXXX") || fatal "Can not write tmp-file"
curl $BASIC_CURL_PARAMS -o "$TMPFILE" "$stream"
if [ $? -eq 0 ]; then
while IFS="" read line; do
if [[ $curSeq -ge $nextSeq ]]; then # later sequence than we need
curLength=$(echo "$nextSegmentLength + $curLength" | bc)
stream_time=$(echo "$stream_time + $nextSegmentLength" | bc)
- pretty_time=$($DATE ${stream_time%.*} +"%Y-%m-%d %H:%M:%S")
+ pretty_time=$($DATE${stream_time%.*} +"%Y-%m-%d %H:%M:%S")
if [[ $curSeq -ne $nextSeq ]]; then
echo >&2 "$pretty_time: Skipped a segment by mistake ($curSeq > $nextSeq)"
fi