1932,6 → 1932,7 |
capture() { |
trace $@ |
local f=$1 stamp=$2 ofile=$3 |
local VIDCAPFILE=00000005.png |
# globals: $shoehorned $decoder |
|
# Avoid recapturing if timestamp is already captured. |
1951,18 → 1952,23 |
return $? |
fi |
|
assert '[[ $decoder -eq $DEC_MPLAYER || $decoder -eq $DEC_FFMPEG ]]' |
if [[ $decoder -eq $DEC_MPLAYER ]]; then |
mplayer_capture "$f" "$ofile" "$stamp" |
mplayer_capture "$f" 'IGNOREME' "$stamp" |
elif [[ $decoder -eq $DEC_FFMPEG ]]; then |
# FIXME: ffmpeg can put the temporary file anywhere |
ffmpeg_capture "$f" "$ofile" "$stamp" |
fi || { |
[[ $decoder -ne $DEC_MPLAYER ]] || stamp=${stamp/%.*} |
ffmpeg_capture "$f" "$VIDCAPFILE" "$stamp" |
else |
error "Internal error!" |
return $EX_SOFTWARE |
fi || true |
local fs=$(du "$VIDCAPFILE" | cut -f1) |
if [[ ( ! -f $VIDCAPFILE ) || ( $fs == '0' ) ]]; then |
[[ $decoder -eq $DEC_MPLAYER ]] && stamp=${stamp/%.*} |
error "Failed to capture frame at $(pretty_stamp $stamp) (${stamp}s)" |
return $EX_SOFTWARE |
} |
fi |
CAPTURES="$CAPTURES$key:$ofile$NL" |
mvq "$VIDCAPFILE" "$ofile" |
} |
|
# Applies all individual vidcap filters |
2584,13 → 2590,13 |
} |
|
# Capture a frame with mplayer |
# mplayer_capture($1 = inputfile, $2 = output file, $3 = timestamp[, $4 = extra opts]) |
# mplayer_capture($1 = inputfile, $2 = UNUSED, $3 = timestamp[, $4 = extra opts]) |
mplayer_capture() { |
trace $@ |
# Note mplayer CAN'T set the output filename, newer mplayer can set output |
#+dir though. |
local f="$1" |
local cap=00000005.png o=$2 |
local o=00000005.png |
local ts=$3 |
|
# No point in passing ms to mplayer |
2609,9 → 2615,7 |
|
} >"$stdout" 2>"$stderr" |
rm -f 0000000{1,2,3,4}.png # Remove the first four |
[[ ( -f $cap ) && ( '0' != "$(du "$cap" | cut -f1)" ) ]] && { |
mvq "$cap" "$o" |
} |
[[ -f $o ]] && [[ '0' != "$(du "$o" | cut -f1)" ]] |
} |
|
# }}}} # Mplayer support |
2749,7 → 2753,7 |
"$FFMPEG" -y ${wa_ss_be/ / $ts} -i "$f" ${wa_ss_af/ / $ts} -an \ |
-dframes 1 -vframes 1 -vcodec png \ |
-f rawvideo $4 $shoehorned "$o" >"$stdout" 2>"$stderr" |
[[ ( -f $o ) && ( '0' != "$(du "$o" | cut -f1)" ) ]] |
[[ -f $o ]] && [[ '0' != "$(du "$o" | cut -f1)" ]] |
} |
|
# }}}} # FFmpeg support |
3256,10 → 3260,16 |
fi |
|
local output=$(new_temp_file '-preview.png') |
local VIDCAPFILE=00000005.png |
|
# If the temporal vidcaps for mplayer already exist, abort |
# If the temporal vidcap already exists, abort |
if [[ -f $VIDCAPFILE ]]; then |
error "File $VIDCAPFILE exists and would be overwritten, move it out before running." |
return $EX_CANTCREAT |
fi |
# mplayer will re-write also 00000001.png-00000004.png |
if [[ $decoder -eq $DEC_MPLAYER ]]; then |
for f_ in 1 2 3 4 5; do |
for f_ in 1 2 3 4; do |
if [[ -f "0000000${f_}.png" ]]; then |
error "File 0000000${f_}.png exists and would be overwritten, move it out before running." |
return $EX_CANTCREAT |
3267,7 → 3277,7 |
done |
fi |
|
TEMPSTUFF=( "${TEMPSTUFF[@]}" '00000005.png' ) |
TEMPSTUFF=( "${TEMPSTUFF[@]}" "$VIDCAPFILE" ) |
|
# Highlights |
local hlfile n=1 # hlfile Must be outside the if! |
3275,7 → 3285,7 |
local hlcapfile= pretty= |
local -a capfiles |
for stamp in $(clean_timestamps "${HLTIMECODES[*]}"); do |
if fptest $stamp -gt ${VID[$LEN]} ; then (( ++n )) && continue ; fi |
if fptest $stamp -gt ${VID[$LEN]} ; then (( n++ )) && continue ; fi |
pretty=$(pretty_stamp $stamp) |
inf "Generating highlight #${n}/${#HLTIMECODES[@]} ($pretty)..." |
hlcapfile=$(new_temp_file "-hl-$(pad 6 $n).png") |
3288,7 → 3298,7 |
} |
|
capfiles=( "${capfiles[@]}" "$hlcapfile" ) |
(( ++n )) |
(( n++ )) |
done |
|
assert "[[ '"$n"' -gt 1 ]]" |
3306,6 → 3316,7 |
unset n |
|
# Normal captures |
# TODO: Don't reference $VIDCAPFILE |
local capfile pretty n=1 |
unset capfiles ; local -a capfiles ; local tfile= |
for stamp in $(clean_timestamps "${TIMECODES[*]}"); do |
3448,6 → 3459,7 |
[[ ( $DISABLE_SHADOWS -eq 1 ) && ( -z $HLTIMECODES ) ]] && dotrim=-trim |
convert -background "$bg_contact" "$output" -flatten $dotrim "$output" |
|
|
# Let's add meta inf and signature |
inf "Adding header and footer..." |
local meta2="Dimensions: ${VID[$W]}x${VID[$H]}" |