check duration of audio files on the command-line

后端 未结 14 871
攒了一身酷
攒了一身酷 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:39

    A solution based on mplayer from commandlinefu by syssyphus that works with both audio and video files:

    sudo apt-get install mplayer
    find -type f -name "*.mp3" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
    

    Get the total length of all video / audio in the current dir (and below) in H:m:s

    Change the *.mp3 to whatever you want to match (e.g., *.avi, *.wav), you can remove it altogether if you want to check all files.

    Example of output: 00:00:37

提交回复
热议问题