check duration of audio files on the command-line

后端 未结 14 1084
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 00:13

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:42

    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 }'
    

提交回复
热议问题