commit 297f3e27a471283fd36b498aca9fd61cf1500d7b parent 4b899c7c61084b11790152d0b33ffff9d293a6b1 Author: lostd <lostd@2f30.org> Date: Tue, 6 May 2014 21:14:00 +0300 Media file duration using mplayer script Diffstat:
A | medialen | | | 17 | +++++++++++++++++ |
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/medialen b/medialen @@ -0,0 +1,17 @@ +#!/bin/sh + +# use mplayer to get media file duration +# depends: mplayer + +if test -z "$1"; then + echo usage: $(basename $0) mfile ... && exit 1 +fi + +for F in "$@"; do + SECS=$(mplayer -vo null -ao null -frames 0 -identify "$F" \ + 2> /dev/null | grep "^ID_LENGTH" | sed 's/^ID_LENGTH=//') + H=$(echo "$SECS / 3600" | bc) + M=$(echo "$SECS % 3600 / 60" | bc) + S=$(echo "$SECS % 60 / 1" | bc) + echo "$F $H:$M:$S" +done