在命令行上检查音频文件的持续时间 [英] check duration of audio files on the command-line

查看:291
本文介绍了在命令行上检查音频文件的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查一组音频文件的持续时间. 在UNIX命令行上有一种简单的方法可以做到这一点吗?

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 *

我有一个很棒的SoX应用程序,它具有一个名为stats的选项,该选项可以生成包括持续时间在内的一组音频信息.我正在寻找一种只获得持续时间的方法. 我对输出格式很灵活,可以是任何样本长度,hh:mm:ss或秒. 后者将是我的偏爱.

I have the amazing SoX app which has an option called stats that generates a set of audio info including duration. I am looking for a way to get only duration. I am flexible on output format, could be any of sample length, hh:mm:ss, or seconds. The latter would be my preference.

推荐答案

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

mm:ss格式为您提供指定文件的长度(mm可以大于59).对于文件中的总秒数,您将使用:

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

要获取所有mp3文件的总长度(以秒为单位),AWK可以提供帮助:

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

这篇关于在命令行上检查音频文件的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆