166,10 → 166,6 |
#declare -r TAB=$'\011' # Tab |
|
# New in 1.13 |
# Set to 1 to disable blank frame evasion |
declare -i DISABLE_EVASION=0 |
# Threshold to consider a frame blank (see capture_and_evade) |
declare -i BLANK_THRESHOLD=10 |
# Offsets to try when trying to avoid blank frames |
# See capture() and capture_and_evade() |
declare -a EVASION_ALTERNATIVES=( -5 +5 -10 +10 -30 +30 ) |
2413,21 → 2409,13 |
error "Internal error" |
return $EX_SOFTWARE |
fi |
if [[ $CAPTURER_HAS_MS -eq 0 ]]; then |
inc=$(keepdecimals_lower $inc 0) |
else |
# Keep three decimals, round to lower to avoid exceeding the video length |
inc=$(keepdecimals_lower $inc 3) |
fi |
|
if fptest $inc -gt ${VID[$LEN]}; then |
error "Capture interval is longer than video length, skipping '$f'" |
error "Interval is longer than video length, skipping $f" |
return $EX_USAGE |
fi |
if fptest $inc -eq 0; then |
error "Capture interval is too low, skipping '$f'" |
return $EX_UNAVAILABLE |
fi |
|
local stamp=$st |
local -a LTC |
2532,8 → 2520,9 |
error "Failed to capture frame at $(pretty_stamp $stamp) (${stamp}s)" |
return $EX_SOFTWARE |
fi |
# **XXX: EXPERIMENTAL: Blank frame evasion, initial test implementation |
# **XXX: EXPERIMENTAL: Blank frame evasion test |
local blank_val=$(convert "$ofile" -colorspace Gray -format '%[fx:image.mean*100]' info:) |
local BLANK_THRESHOLD=10 |
local upper=$(( 100 - $BLANK_THRESHOLD )) |
if fptest $blank_val -lt $BLANK_THRESHOLD || fptest $blank_val -gt $upper ; then |
local msg=" Blank (enough) frame detected." |
2554,13 → 2543,11 |
|
# Capture a frame, intermediate-level implementation, use capture() instead. |
# Sets $RESULT to '$timestamp:$output' |
# Sets $CAPTURED_FROM_CACHE to 1 if it was already captured |
# capture_impl($1 = filename, $2 = second, $3 = output file) |
capture_impl() { |
trace $@ |
local f=$1 stamp=$2 ofile=$3 |
RESULT='' |
CAPTURED_FROM_CACHE=0 |
|
# Avoid recapturing if timestamp is already captured. |
# The extended set includes the standard set so when using the extended mode |
2575,11 → 2562,10 |
else |
key=$(awkex $stamp) |
fi |
local cached=$(grep "^$key:" <<<"$CAPTURES" | head -1) |
local cached=$(grep "^$key:" <<<"$CAPTURES") |
if [[ $cached ]]; then |
notice "Skipped capture at $(pretty_stamp $key)" |
cp "${cached#*:}" "$ofile" # TODO: Is 'cp -s' safe? |
CAPTURED_FROM_CACHE=1 |
else |
local capfn=${CAPTURER}_capture |
if [[ $DVD_MODE -eq 1 ]]; then |
3776,7 → 3762,6 |
hlcapfile=$(new_temp_file "-hl-$(pad 6 $n).png") |
|
capture "$f" "$hlcapfile" $stamp '1' || return $? |
[[ $CAPTURED_FROM_CACHE -eq 1 ]] ||\ |
filter_vidcap "$hlcapfile" $pretty $vidcap_width $vidcap_height $CTX_HL $n || { |
local r=$? |
error "Failed to apply transformations to the capture." |
3810,12 → 3795,11 |
# identified by capture number, padded to 6 characters |
tfile=$(new_temp_file "-cap-$(pad 6 $n).png") |
|
capture "$f" "$tfile" $stamp $DISABLE_EVASION || return $? |
capture "$f" "$tfile" $stamp || return $? |
if [[ $RESULT != "$stamp" ]]; then |
stamp=$RESULT |
pretty=$(pretty_stamp $RESULT) |
fi |
[[ $CAPTURED_FROM_CACHE -eq 1 ]] ||\ |
filter_vidcap "$tfile" $pretty $vidcap_width $vidcap_height $CTX_STD $n || return $? |
|
capfiles=( "${capfiles[@]}" "$tfile" ) |
3857,8 → 3841,7 |
pretty=$(pretty_stamp $stamp) |
capfile=$(new_temp_file "-excap-$(pad 6 $n).png") |
inf "Generating capture from extended set: ${n}/${#TIMECODES[*]} ($pretty)..." |
capture "$f" "$capfile" $stamp $DISABLE_EVASION || return $? |
[[ $CAPTURED_FROM_CACHE -eq 1 ]] ||\ |
capture "$f" "$capfile" $stamp || return $? |
filter_vidcap "$capfile" $pretty $w $h $CTX_EXT $n || return $? |
|
capfiles=( "${capfiles[@]}" "$capfile" ) |
5112,10 → 5095,6 |
else |
usrcap='{default}' |
fi |
evasion="Enabled (${EVASION_ALTERNATIVES[*]})" |
if [[ $DISABLE_EVASION -eq 1 ]]; then |
evasion='Disabled' |
fi |
cat >&2 <<-EOD |
=== Setup === |
GETOPT: $GETOPT |
5130,7 → 5109,7 |
Chosen capturer: $usrcap |
Filterchain: [ ${FILTERS_IND[*]} ] |
Safe step: $QUIRKS_LEN_STEP |
Blank evasion: $evasion |
Blank evasion: $prevent_evasion |
=== Versions === |
Bash: $BASH_VERSION |
Getopt: $($GETOPT --version)$awkv$sedv |