check duration of audio files on the command-line

后端 未结 14 935
没有蜡笔的小新
没有蜡笔的小新 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:36

    with ffprobe

    ffprobe your_file.mp3 2>&1 | grep "Duration"
    

    The output looks like this:

    Duration: 00:44:33.50, start: 0.011995, bitrate: 128 kb/

    0 讨论(0)
  • 2021-02-05 00:37
    sox --info -D file             --> duration in seconds
    sox --info -d file             --> duration in HH:mm:ss.ss
    sox --info file                --> metadata 
    
    0 讨论(0)
  • 2021-02-05 00:38
    ffmpeg -i <audiofile> 2>&1 | grep Duration
    
    0 讨论(0)
  • 2021-02-05 00:38

    Another soxi based answer including the file names and duration in hours, minutes and seconds format.

    $for f in *amr; do printf "$f "; soxi -d $f; done
    
    DGT20161216.amr 00:22:04.62
    DGT20170108.amr 00:28:22.80
    DGT20170117.amr 00:20:05.18
    
    0 讨论(0)
  • 2021-02-05 00:39

    If you are interested in finding total duration of wav files in a directory using soxi you can use this:

    soxi -D input_dir/*.wav | python -c "import sys;print(sum(float(l) for l in sys.stdin))

    change input_dir according to your input directory. If you want to find max/min duration between all wav files feel free to change sum to max or min.

    0 讨论(0)
  • 2021-02-05 00:40

    on OSX

    Print the length of each audio file in the current dir:

    afinfo * | awk '/estimated duration/ { print $3 }'
    

    Include the filepath:

    afinfo * | awk '/File:/ { song=$2 } /estimated duration/ { print song, $3 }'
    
    0 讨论(0)
提交回复
热议问题