26,8 → 26,7 |
# Author: Toni Corvera <outlyer@gmail.com> |
# |
# References: |
# Mainly pages I've taken snippets from or wrote code based on them; or pages |
# containing reference/technical data |
# Pages I've taken snippets from or wrote code based on them. |
# I refer to them in comments as e.g. [[R1]]. [[R1#3]] Means section 3 in R1. |
# I also use internal references in the form [x1] (anchor -where to point-) |
# and [[x1]] (x-reference -point to what-). |
47,17 → 46,32 |
# <http://wiki.multimedia.cx/index.php?title=VC-1> |
# |
|
declare -r VERSION="1.0.12" |
declare -r VERSION="1.0.11" |
# {{{ # CHANGELOG |
# History (The full changelog can be found at <http://p.outlyer.net/vcs/files/CHANGELOG>). |
# |
# 1.0.12: (2008-0?-??) |
# * BUGFIX/COSMETIC: Corrected 0ms timestamps |
# * COSMETIC: Re-added the (disabled for long) black border after highlights |
# * BUGFIX/COSMETIC: Corrected the count of captures in manual-only mode (-m) |
# * FEATURE: Added a minimun length to use the end offset |
# * BUGFIX: Fixed the regression on highlights from the last version (extra |
# padding was being added my IM automatically) |
# 1.0.11: (2008-04-08) |
# * 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) |
# * WORKAROUND: Fix for all-equal captures (seems to be a known problem |
# with mplayer [M1]) (contributed by Phil Grundig) |
# * 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) |
# * COSMETIC: Align the extended set captures (-e) and the standard set |
# (bug pointed by Chris Hills). Seems to fail at some (smaller?) |
# sizes. |
# "Funky" modes aren't correctly aligned yet. |
# * DEBUGGING: Added optional function call trace (by setting variable DEBUG |
# to 1) |
# * Added FOURCC for VC-1 |
# * COSMETIC: Fixed captures recount with multiple files (prompted by a |
# bugreport from Dougn Redhammer) |
# }}} # CHANGELOG |
|
set -e |
176,8 → 190,6 |
declare shoehorned= |
# See -E / $end_offset |
declare -i DEFAULT_END_OFFSET=60 |
# If the video is less than this length, end offset won't be used at all |
declare MIN_LENGTH_FOR_END_OFFSET=19m30s |
# This can only be changed in the configuration file |
# Change it to change the safe renanimg: |
# When writing the output file, the input name + output extension is |
335,7 → 347,6 |
'stdout' |
'stderr' |
'DEFAULT_END_OFFSET' |
'MIN_LENGTH_FOR_END_OFFSET' |
'DEBUG' |
) |
|
544,13 → 555,13 |
# Get Image Width |
# imw($1 = file) |
imw() { |
identify -format '%w' "$1" |
identify "$1" | cut -d' ' -f3 | cut -d'x' -f1 |
} |
|
# Get Image Height |
# imh($1 = file) |
imh() { |
identify -format '%h' "$1" |
identify "$1" | cut -d' ' -f3 | cut -d'x' -f2 |
} |
|
# Prints a number of seconds in a more human readable form |
560,7 → 571,6 |
if ! is_float "$1" ; then return $EX_USAGE ; fi |
|
local t=$1 |
|
#local h=$(( $t / 3600 )) |
# bc's modulus seems to *require* not using the math lib (-l) |
local h=$( bc -q <<<"$t / 3600") |
567,15 → 577,8 |
t=$(bc -q <<<"$t % 3600") |
local m=$( bc -q <<<"$t / 60") |
t=$(bc -q <<<"$t % 60") |
local s ms |
if grep -q '\.' <<<"$t" ; then |
# Have ms |
s=$(cut -d'.' -f1 <<<$t) |
ms=$(cut -d'.' -f2 <<<$t) |
else |
s=$t |
ms=0 |
fi |
local s=$(cut -d'.' -f1 <<<$t) |
local ms=$(cut -d'.' -f2 <<<$t) |
|
local R="" |
|
892,13 → 895,9 |
|
local runlen=$( bc <<<"$end - $st" ) |
|
if fptest "$runlen" -lt $(get_interval "$MIN_LENGTH_FOR_END_OFFSET") ; then |
# Min length to use end offset not met, it won't be used |
inf "End offset won't be used, video too short." |
eo=0 |
elif fptest "($end-$eo-$st)" -le 0 ; then |
if fptest "($end-$eo-$st)" -le 0 ; then |
if fptest "$eo" -gt 0 && fptest "$eo" -eq "$DEFAULT_END_OFFSET" ; then |
warn "Default end offset was too high for the video, ignoring it." |
warn "Default end offset was too high, ignoring it." |
eo=0 |
else |
error "End offset too high, use e.g. '-E0'." |
1168,6 → 1167,7 |
# This produces soft-shadows, which look much better than the montage ones |
convert \( -shadow 50x2+10+10 "$output" \) "$output" -composite "$output" |
fi |
#convert \( -shadow 50x2+10+10 "$output" \) "$output" -composite "$output" |
|
# FIXME: Error handling |
echo $output |
1366,13 → 1366,8 |
|
unset TIMECODES |
# Compute the stamps (if in auto mode)... |
if [ $manual_mode -eq 1 ]; then |
# Note TIMECODES must be set as an array to get the correct count in |
# manual mode; in automatic mode it will be set correctly inside |
# compute_timecodes() |
TIMECODES=( ${initial_stamps[@]} ) |
else |
TIMECODES=${initial_stamps[@]} |
TIMECODES=${initial_stamps[*]} |
if [ $manual_mode -ne 1 ]; then |
compute_timecodes $timecode_from $interval $numcaps || { |
return $? |
} |
1610,14 → 1605,9 |
fi |
# If there were highlights then mix them in |
if [ "$HLTIMECODES" ]; then |
# For some reason adding the background also adds padding with: |
# convert \( -background LightGoldenRod "$hlfile" -flatten \) \ |
# \( "$output" \) -append "$output" |
# replacing it with a "-composite" operation apparently works |
local geometry=$(identify -format '%wx%h' "$hlfile") |
convert \( -size "$geometry" xc:LightGoldenRod "$hlfile" -composite \) \ |
\( -size "$(cut -d'x' -f1<<<$geometry)"x1 xc:black \) \ |
"$output" -append "$output" |
#\( -geometry x2 xc:black -background black \) # This breaks it! |
convert \( -background LightGoldenRod "$hlfile" -flatten \) \ |
\( "$output" \) -append "$output" |
fi |
# Extended captures |
if [ "$extended_factor" != 0 ]; then |
1638,7 → 1628,7 |
else |
signature="Created with $PROGRAM_SIGNATURE" |
fi |
local headwidth=$(imw "$output") |
local headwidth=$(identify "$output" | cut -d' ' -f3 | cut -d'x' -f1) |
# TODO: Use a better height calculation |
local headheight=$(($pts_meta * 4 )) |
local heading=$(new_temp_file .png) |