Topic - Skip to halfway through?



Reply to this topic

Topic Starter max_williams - Posted on Friday, October 3 2008 10:28:26 AM
I'm trying to grab thumbnails from some flvs but they vary a lot in terms of length - from 2 seconds to 10 minutes. I'm skipping in by a fixed amount (eg 3 seconds) but it would be nicer to skip to 50%, or 20% of the way through before grabbing my thumbnail.

Does anyone know how to skip to a certain percentage of the way through, rather than a fixed time?
max_williams - Posted on Friday, October 3 2008 10:56:48 AM
Never mind, i found a solution: use the midentify script to get the length, then half it for my skip time:

# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.

if [ -z "$1" ]; then
echo "Usage: midentify.sh <file> [<file> ...]"
exit 1
fi

mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |
sed -ne '/^ID_/ {
s/[]()|&;<>`'"'"'\!$" []/\&/g;p
}' | grep ID_LENGTH | cut -d "=" -f2