Subversion Repositories pub

Compare Revisions

Ignore whitespace Rev 535 → Rev 534

/video-contact-sheet/branches/1.13/dist/vcs
75,7 → 75,6
# 1.13 1.14 auto-loading ./vcs.conf (lesser version of profiles)
# -C :pwd will stay
# --------------------------------------------------------------------------------------------
# ? ?+1 decoder. Replaced by capturer, the syntax changes
# ? ?+1 --funky -> --profile
# * Variables cleanup:
# Variables will use a more uniform scheme, with prefixes where appropriate:
180,6 → 179,11
declare USERNAME=$(id -un)
# Which of the two methods should be used to guess the number of thumbnails
declare -i TIMECODE_FROM=$TC_INTERVAL
# Which of the two vidcappers should be used (see -F, -M)
# mplayer seems to fail for mpeg or WMV9 files, at least on my system
# also, ffmpeg allows better seeking: ffmpeg allows exact second.fraction
# seeking while mplayer apparently only seeks to nearest keyframe
declare -i DECODER=$DEC_FFMPEG # Deprecated
# New in 1.13. Replaces the old 'decoder' symbolic option.
# The value is *not* the name of the executable, but a supported capturer,
#+right now 'ffmpeg' or 'mplayer'. Equivalent configuration setting: 'capturer'
288,7 → 292,7
 
# These variables will hold the output of tput, used
# to colourise feedback
declare prefix_err= prefix_inf= prefix_warn= prefix_dbg= suffix_fback=
declare prefix_err= prefix_inf= prefix_warn= suffix_fback=
 
# Workarounds:
# Argument order in FFmpeg is important -ss before or after -i will make
349,15 → 353,6
# the input file and append an extension to it
declare -a OUTPUT_FILES=( )
 
# Which of the two vidcappers should be used (see -F, -M)
#+mplayer seems to fail for mpeg or WMV9 files, at least on my system
#+also, ffmpeg allows better seeking: ffmpeg allows exact second.fraction
#+seeking while mplayer apparently only seeks to nearest keyframe
# Starting with 1.13 this value can no longer be overridden directly,
#+setting 'decoder' actually changes PREFERRED_CAPTURER. DECODER is still used
#+internally.
declare -i DECODER=$DEC_FFMPEG
 
# Mplayer and FFmpeg binaries. Will be detected.
# Don't set manually, if you need to override set the path temporarily, e.g.:
# $ env PATH=/whatever:$PATH vcs ...
573,8 → 568,8
 
# TODO: These variables are evaluated to constants, would be better to
# use some symbolic system (e.g. decoder=f instead of decoder=$DEC_FFMPEG)
"DECODER:=:meta:D" # To be deprecated
#"CAPTURE_MODE:TIMECODE_FROM:alias:T"
"DECODER:=:=:D"
#"capture_mode:TIMECODE_FROM:alias:T"
"TIMECODE_FROM:=:=:T"
"VERBOSITY:=:=:V"
"SIMPLE_FEEDBACK:=:=:b"
862,7 → 857,7
if [[ $flags && ( $flags != '=' ) && ( $flags != 'alias' ) ]]; then
local ERE='^deprecated='
if [[ $flags =~ $ERE ]]; then
local new=$(echo "$flags" | sed 's/^deprecated=//' | tr '[A-Z]' '[a-z]')
local new=$(echo "$flags" | sed 's/^deprecated=//')
buffered warn "Setting '$varname' will be removed in the future,$NL please use '$new' instead."
else
case "$flags" in
952,16 → 947,6
load_profile $prof
done
;;
decoder)
buffered inf "decoder => capturer"
if [[ $2 -eq $DEC_FFMPEG ]]; then
parse_override 'CAPTURER=ffmpeg'
elif [[ $2 -eq $DEC_MPLAYER ]]; then
parse_override 'CAPTURER=mplayer'
else
assert false
fi
;;
esac
}
 
1229,12 → 1214,6
type -pf "$@" >/dev/null 2>&1
}
 
# Checks if a variable has been defined (even to empty values).
# isset($1 = variable name)
isset() {
[[ -n ${!1+x} ]]
}
 
# Wrapper around $RANDOM, not called directly, wrapped again in rand().
# See rand() for an explanation.
bashrand() {
1443,12 → 1422,10
# pretty_stamp($1 = seconds)
pretty_stamp() {
assert "is_float '$1'"
assert 'isset CAPTURER_HAS_MS'
# Fully implemented in AWK to discard bc.
 
# As a bonus now it's much faster and compact
awk "BEGIN {
t=$1 ; NOTMS=!$CAPTURER_HAS_MS;
t=$1 ; NOTMS=($DEC_MPLAYER==$DECODER);
MS=(t - int(t));
h=int(t / 3600);
t=(t % 3600);
1758,7 → 1735,7
return 0
fi
fi
echo "${prefix_dbg}[TRACE]: $func ${*}${suffix_fback}" >&2
echo "[TRACE]: $func $*" >&2
}
 
# Print an error message and exit
1792,7 → 1769,6
prefix_err='[E] '
prefix_inf='[i] '
prefix_warn='[w] '
prefix_dbg=''
suffix_fback=
}
 
1811,7 → 1787,6
prefix_err=$(tput bold; tput setaf 1)
prefix_warn=$(tput bold; tput setaf 3)
prefix_inf=$(tput bold; tput setaf 2)
prefix_dbg=$(tput bold; tput setaf 4)
suffix_fback=$(tput sgr0)
HAS_COLORS="yes"
fi >/dev/null
1826,7 → 1801,6
prefix_err=$(echo $'\033[1m\033[31m')
prefix_warn=$(echo $'\033[1m\033[33m')
prefix_inf=$(echo $'\033[1m\033[32m')
prefix_dbg=$(echo $'\033[1m\033[34m')
suffix_fback=$(echo $'\033[0m')
HAS_COLORS="yes"
fi
2208,29 → 2182,6
 
# }}}} # Classic identification
 
# Sets the tool to use as a capturer
# Possible tool names: ffmpeg, mplayer
# set_capturer($1 = tool, [$2 = user picked]=1)
set_capturer() {
trace $@
local up=$2
if [[ $1 = mplayer ]]; then
DECODER=$DEC_MPLAYER
PREFERRED_CAPTURER=mplayer
CAPTURER_HAS_MS=0
elif [[ $1 = ffmpeg ]]; then
DECODER=$DEC_FFMPEG
PREFERRED_CAPTURER=ffmpeg
CAPTURER_HAS_MS=1
else
assert false
fi
if [[ ( -z $up ) || ( $up -eq 1 ) ]]; then
USR_DECODER=$DECODER
USR_PREFERRED_CAPTURER=$PREFERRED_CAPTURER
fi
}
 
# Creates a new temporary directory
# create_temp_dir()
create_temp_dir() {
2536,6 → 2487,7
capture_impl() {
trace $@
local f=$1 stamp=$2 ofile=$3
# globals: $DECODER
 
# Avoid recapturing if timestamp is already captured.
# The extended set includes the standard set so when using the extended mode
2543,7 → 2495,7
#+have ms precission
local key=
# Normalise key values' decimals
if [[ $CAPTURER_HAS_MS -eq 0 ]]; then
if [[ $DECODER -eq $DEC_MPLAYER ]]; then
key=$(awkex "int($stamp)")
else
key=$(awkex $stamp)
3226,7 → 3178,6
CAPTURER_HAS_MS=0
DECODER=$DEC_MPLAYER
elif [[ $CAPTURER == 'ffmpeg' ]]; then
CAPTURER_HAS_MS=1
DECODER=$DEC_FFMPEG
fi
}
3483,11 → 3434,11
fi
 
if [[ ( $DECODER -eq $DEC_MPLAYER ) && ( -z $MPLAYER_BIN ) ]]; then
inf "Mplayer not available."
set_capturer ffmpeg 0
inf "No mplayer available. Using ffmpeg only."
DECODER=$DEC_FFMPEG
elif [[ ( $DECODER -eq $DEC_FFMPEG ) && ( -z $FFMPEG_BIN ) ]]; then
inf "FFmpeg not available."
set_capturer mplayer 0
inf "No ffmpeg available. Using mplayer only."
DECODER=$DEC_MPLAYER
fi
 
local filter=
4654,8 → 4605,10
;;
-h|--help) show_help ; exit $EX_OK ;;
--fullhelp) show_help 'full' ; exit $EX_OK ;;
-F|--ffmpeg) set_capturer ffmpeg ;;
-M|--mplayer) set_capturer mplayer ;;
-F|--ffmpeg) DECODER=$DEC_FFMPEG ; USR_DECODER=$DECODER ;
PREFERRED_CAPTURER=ffmpeg ; USR_PREFERRED_CAPTURER=ffmpeg ;;
-M|--mplayer) DECODER=$DEC_MPLAYER ; USR_DECODER=$DECODER ;
PREFERRED_CAPTURER=mplayer ; USR_PREFERRED_CAPTURER=mplayer ;;
-H|--height)
check_constraint 'height' "$2" "$1" || die
HEIGHT="$2"
4954,7 → 4907,7
exit $EX_UNAVAILABLE
fi
DVD_MODE=1
set_capturer mplayer 0
DECODER=$DEC_MPLAYER
ASPECT_RATIO=-2 # Special value: Auto detect only if ffmpeg couldn't
;;
-q|--quiet)
4996,13 → 4949,13
FFMPEG_BIN=''
warn "FFmpeg disabled"
assert '[[ $MPLAYER_BIN ]]'
set_capturer mplayer
DECODER=$DEC_MPLAYER
;;
disable_mplayer)
MPLAYER_BIN=''
warn "Mplayer disabled"
assert '[[ $FFMPEG_BIN ]]'
set_capturer ffmpeg
DECODER=$DEC_FFMPEG
;;
debug)
warn "[U] debug"