check duration of audio files on the command-line

后端 未结 14 890
攒了一身酷
攒了一身酷 2021-02-05 00:00

I need to check the duration of a group of audio files. Is there a simple way to do this on the unix command-line?

> duration *

I have the a

14条回答
  •  终归单人心
    2021-02-05 00:49

    mp3info -p "%m:%02s\n" filename
    

    gives you the length of the specified file in mm:ss format (mm can be greater than 59). For just the total number of seconds in the file, you'd use:

    mp3info -p "%S\n" filename
    

    To get the total length of all the mp3 files in seconds, AWK can help:

    mp3info -p "%S\n" *.mp3 | awk 'BEGIN { s = 0 }; { s = s + $1 }; END { print s }'
    

提交回复
热议问题