44,6 → 44,9 |
# Info: <http://www.gnu.org/manual/gawk/html_node/Conversion.html> |
#export POSIXLY_CORRECT=1 # Immitate behaviour in newer gawk |
export LC_NUMERIC=C |
# All output from tools is either removed or parsed. |
# Standardise on the C locale. |
export LANG=C |
|
# Fail soon if this version of bash is too old for the syntax, don't expose bash to the newer |
# syntax |
155,7 → 158,7 |
|
# Used for feedback |
declare -r NL=$'\012' # Newline |
declare -r TAB=$'\011' # Tab |
#declare -r TAB=$'\011' # Tab |
|
# }}} # End of constants |
|
1318,24 → 1321,21 |
# to re-evaluate them, which appears to be enough to make them decimal. |
# This is the only place where leading zeroes have no meaning. |
# sed expressions: |
# 1: quote numbers with units (leading-zeroes workaround) |
# 2: quote secs.ms |
# 3: quote SECSs.ms |
# 4: quote secs at end of string |
# ... from hereon add the products and additions |
# 5: h * 3600 |
# 6: m * 60 |
# 7: s (* 1) |
# 8: strip trailing, empty, addition |
NEWCODETEST=$(echo $s | sed \ |
-e 's/\([0-9]*\)\([hms]\)/"\1"\2/g' \ |
-e 's/\([0-9]*\.[0-9]*\)/"\1"/g' \ |
-e 's/\(\([0-9][0-9]*\)s?\.\([0-9][0-9]\)*\)$/"\2"s"\3"/' \ |
-e 's/\([0-9][0-9]*\)$/"\1"s/' \ |
# 1: add spaces after h,m,s and before '.' |
# 2: quote numbers preceded by a space |
# 3: quote the first number |
# 4: replace h with a product by 3600 and an addition |
# 5: replace m with a product by 60 and an addition |
# 6: replace s with an addition |
# 7: remove last empty addition |
NEWCODETEST=$(echo "$s" | sed \ |
-e 's/\([hms]\)/\1 /g' -e 's/\./ ./g' \ |
-e 's/ \([0-9.][0-9.]*\)/ "\1"/g' \ |
-e 's/^\([0-9.][0-9.]*\)/"\1"/' \ |
-e 's/h/ * 3600 + /g' \ |
-e 's/m/ * 60 + /g' \ |
-e 's/s/ + /g' \ |
-e 's/ + $//' \ |
-e 's/+ *$//' \ |
) |
for item in $(echo "$s" | grep -o '[0-9]*[hms]') ;do |
n="\"$(echo $item | grep -o '[0-9]*')\"" # Number, quoted |
2832,9 → 2832,9 |
# clean_timestamps($1 = space separated timestamps) |
clean_timestamps() { |
trace $@ |
# Note AFAIK sort only sorts lines, that's why I replace spaces by newlines |
# Note sort works on lines, hence the stonl |
local s=$1 |
stonl "$s" | sort -n | uniq |
echo "$s" | stonl | sort -n | uniq |
} |
|
# Test the video at a given timestamp (to see if it can be reached) |
5005,11 → 5005,15 |
else |
pc='not set' |
fi |
# AWK version can't be checked in all variants |
# AWK and sed version can't be checked in all variants |
awkv=$(awk --version 2>/dev/null | head -1) || true |
if [[ -n $awkv ]]; then |
awkv="${NL}AWK: $awkv" |
fi |
sedv=$(sed --version 2>/dev/null | head -1) || true |
if [[ -n $sedv ]]; then |
sedv="${NL}sed: $sedv" |
fi |
cat >&2 <<-EOD |
=== Setup === |
GETOPT: $GETOPT |
5016,6 → 5020,7 |
MPLAYER: $MPLAYER_BIN |
FFMPEG: $FFMPEG_BIN |
AWK: $(realpathr $(type -pf awk)) |
sed: $(realpathr $(type -pf sed)) |
Filterchain: [ ${FILTERS_IND[*]} ] |
Decoder: $d |
Capturers (av.): [ ${CAPTURERS_AVAIL[*]} ] |
5025,7 → 5030,7 |
POSIXLY_CORRECT: $pc |
=== Versions === |
Bash: $BASH_VERSION |
Getopt: $($GETOPT --version)$awkv |
Getopt: $($GETOPT --version)$awkv$sedv |
EOD |
exit |
fi |