46,13 → 46,19 |
# {{{ # CHANGELOG |
# History (The full changelog can be found at <http://p.outlyer.net/vcs/files/CHANGELOG>). |
# |
# 1.0.11: (?) the Grundig release :) |
# * RETROCOMPATIBILITY: Older bash syntax for appending and initialising arrays |
# (contributed by Phil Grundig) |
# * COMPATIBILITY: Support alternative du syntax for compatibility with busybox |
# (based on Phil Grundig's contribution) |
# * COSMETIC: Don't print milliseconds when using mplayer as capturer (they're not |
# really meaningful then) (suggested by Phil Grundig) |
# 1.0.11: |
# * BUGFIX: (brown bag bug) Corrected typo in variable name that made vcs |
# fail when setting the default timecode derivation to number of |
# captures instead of interval (i.e. when including timecode_from=8 in |
# the config file) (thanks to Chris Hills for the bug report) |
# * RETROCOMPATIBILITY: Older bash syntax for appending and initialising |
# arrays (contributed by Phil Grundig) |
# * COMPATIBILITY: Support alternative du syntax for compatibility with |
# busybox (based on Phil Grundig's contribution) |
# * COSMETIC: Don't print milliseconds when using mplayer as capturer |
# (they're not really meaningful then) (suggested by Phil Grundig) |
# * DEBUGGING: Added optional function call trace (by setting variable DEBUG |
# to 1) |
# }}} # CHANGELOG |
|
set -e |
115,6 → 121,8 |
|
# {{{ # Override-able variables |
|
# Set to 1 to print function calls |
declare -i DEBUG=0 |
declare -i DEFAULT_INTERVAL=300 |
declare -i DEFAULT_NUMCAPS=16 |
declare -i DEFAULT_COLS=2 |
344,7 → 352,7 |
# Override-able hack, this won't work with command line overrides, though |
end_offset=$DEFAULT_END_OFFSET |
interval=$DEFAULT_INTERVAL |
numcaps=$DEAFULT_NUMCAPS |
numcaps=$DEFAULT_NUMCAPS |
} |
|
# Do an override |
742,6 → 750,18 |
fi |
} |
|
# |
# trace($1 = function name = $FUNCNAME, function arguments...) |
if [ "$DEBUG" -eq "1" ]; then |
trace() { |
echo "[TRACE]: $@" >&2 |
} |
else |
trace() { |
return |
} |
fi |
|
# }}} # Convenience functions |
|
# {{{ # Core functionality |
749,6 → 769,7 |
# Creates a new temporary directory |
# create_temp_dir() |
create_temp_dir() { |
trace $FUNCNAME $@ |
# Try to use /dev/shm if available, this provided a very small |
# benefit on my system but me of help for huge files. Or maybe won't. |
if [ -d /dev/shm ] && [ -w /dev/shm ]; then |
766,6 → 787,7 |
# Create a new temporal file and print its filename |
# new_temp_file($1 = suffix) |
new_temp_file() { |
trace $FUNCNAME $@ |
local r=$(mktemp -p "$VCSTEMPDIR" "vcs-XXXXXX") |
if [ ! -f "$r" ]; then |
error "Failed to create temporary file" |
784,7 → 806,7 |
# or colour combination you like. |
# randomize_look() |
randomize_look() { |
|
trace $FUNCNAME $@ |
local mode=f lineno |
|
if [ "f" == $mode ]; then # Random mode |
846,6 → 868,8 |
# from the current video |
# compute_timecodes($1 = timecode_from, $2 = interval, $3 = numcaps) |
compute_timecodes() { |
trace $FUNCNAME $@ |
|
local st=0 end=${VID[$LEN]} tcfrom=$1 tcint=$2 tcnumcaps=$3 eo=0 |
# globals: fromtime, totime, timecode_from, TIMECODES, end_offset |
if fptest $st -lt $fromtime ; then |
911,6 → 935,7 |
# known values (e.g. VCD resolution turns into 4/3) |
# guess_aspect($1 = width, $2 = height) |
guess_aspect() { |
trace $FUNCNAME $@ |
# mplayer's ID_ASPECT seems to be always 0 ¿? |
local w=$1 h=$2 ar |
|
957,6 → 982,7 |
# Capture a frame |
# capture($1 = filename, $2 = second) |
capture() { |
trace $FUNCNAME $@ |
local f=$1 stamp=$2 |
local VIDCAPFILE=00000001.png |
# globals: $shoehorned $decoder |
995,6 → 1021,7 |
# Applies all individual vidcap filters |
# filter_vidcap($1 = filename, $2 = timestamp, $3 = width, $4 = height) |
filter_vidcap() { |
trace $FUNCNAME $@ |
# For performance purposes each filter simply prints a set of options |
# to 'convert'. That's less flexible but enough right now for the current |
# filters. |
1015,6 → 1042,7 |
#} |
|
filt_resize() { |
trace $FUNCNAME $@ |
local f="$1" t=$2 w=$3 h=$4 |
|
# Note the '!', required to change the aspect ratio |
1024,6 → 1052,7 |
# Draw a timestamp in the file |
# filt_apply_stamp($1 = filename, $2 = timestamp, $3 = width, $4 = height) |
filt_apply_stamp() { |
trace $FUNCNAME $@ |
local filename=$1 timestamp=$2 width=$3 height=$4 |
|
echo -n " \( -box '#000000aa' -fill '$fg_tstamps' -pointsize '$pts_tstamps' " |
1035,6 → 1064,7 |
# Taken from <http://www.imagemagick.org/Usage/thumbnails/#polaroid> |
# filt_photoframe($1 = filename, $2 = timestamp, $3 = width, $4 = height) |
filt_photoframe() { |
trace $FUNCNAME $@ |
# local file="$1" ts=$2 w=$3 h=$4 |
# Tweaking the size gives a nice effect too |
# w=$(( $w - ( $RANDOM % ( $w / 3 ) ) )) |
1048,6 → 1078,7 |
# Taken from <http://www.imagemagick.org/Usage/thumbnails/#polaroid> |
# filt_randrot($1 = filename, $2 = timestamp, $3 = width, $4 = height) |
filt_randrot() { |
trace $FUNCNAME $@ |
# Rotation angle [-18..18] |
local angle=$(( ($RANDOM % 37) - 18 )) |
echo "-background none -rotate $angle " |
1056,6 → 1087,7 |
# This one requires much more work, the results are pretty rough, but ok as |
# a starting point / proof of concept |
filt_film() { |
trace $FUNCNAME $@ |
local file="$1" ts=$2 w=$3 h=$4 |
# Base reel dimensions |
local rw=$(rmultiply $w,0.08) # 8% width |
1097,6 → 1129,7 |
# create_contact_sheet($1 = columns, $2 = context, $3 = width, $4 = height, |
# $5...$# = vidcaps) : output |
create_contact_sheet() { |
trace $FUNCNAME $@ |
$CSHEET_DELEGATE "$@" |
} |
|
1104,6 → 1137,7 |
# csheet_montage($1 = columns, $2 = context, $3 = width, $4 = height, |
# $5... = vidcaps) : output |
csheet_montage() { |
trace $FUNCNAME $@ |
local cols=$1 ctx=$2 width=$3 height=$4 output=$(new_temp_file .png) |
shift 4 |
case $ctx in |
1130,6 → 1164,7 |
# csheet_overlap($1 = columns, $2 = context, $3 = width, $4 = height, |
# $5... = $vidcaps) : output |
csheet_overlap() { |
trace $FUNCNAME $@ |
local cols=$1 ctx=$2 width=$3 height=$4 |
# globals: $VID |
shift 4 |
1236,6 → 1271,7 |
# Sorts timestamps and removes duplicates |
# clean_timestamps($1 = space separated timestamps) |
clean_timestamps() { |
trace $FUNCNAME $@ |
# Note AFAIK sort only sorts lines, that's why y replace spaces by newlines |
local s=$1 |
sed 's/ /\n/g'<<<"$s" | sort -n | uniq |
1244,6 → 1280,7 |
# Fills the $MPLAYER_CACHE and $VID variables with the video data |
# identify_video($1 = file) |
identify_video() { |
trace $FUNCNAME $@ |
local f=$1 |
# Meta data extraction |
# Note to self: Don't change the -vc as it would affect $vdec |
1279,6 → 1316,7 |
# Creates the contact sheet. |
# process($1 = file) |
process() { |
trace $FUNCNAME $@ |
local f=$1 |
|
local numcols= |
1409,7 → 1447,7 |
local hlnc=$(rtomult "$(( ${#TIMECODES[@]} * $extended_factor ))" $((2*$numcols))) |
|
unset TIMECODES # required step to get the right count |
declare -a TIMECODES # Note the manual stamps aren't included anymore |
declare -a TIMECODES # Note the manual stamps are not included anymore |
compute_timecodes $TC_NUMCAPS "" $hlnc |
unset hlnc |
|