scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

medialen (434B)


      1 #!/bin/sh
      2 
      3 # use mplayer to get media file duration
      4 # depends: mplayer
      5 
      6 if test -z "$1"; then
      7     echo usage: $(basename $0) mfile ... && exit 1
      8 fi
      9 
     10 for F in "$@"; do
     11     SECS=$(mplayer -vo null -ao null -frames 0 -identify "$F" \
     12         2> /dev/null | grep "^ID_LENGTH" | sed 's/^ID_LENGTH=//')
     13     H=$(echo "$SECS / 3600" | bc)
     14     M=$(echo "$SECS % 3600 / 60" | bc)
     15     S=$(echo "$SECS % 60 / 1" | bc)
     16     echo "$F $H:$M:$S"
     17 done