从sox输出中获取.wav的长度 [英] Get length of .wav from sox output

查看:883
本文介绍了从sox输出中获取.wav的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



使用:

  sox output.wav -n stat 

给出:

 样本读取:449718 
长度(秒):28.107375
缩放比例:2147483647.0
最大幅度:0.999969
最小幅度:-0.999969
中线幅度:0.000000
平均常态:0.145530
平均幅度:0.000291
有效值幅度:0.249847
最大差值:1.316925
最小增量:0.000000
平均增量:0.033336
RMS增量:0.064767
粗糙频率:660
调整量:1.000
pre>

如何使用grep或其他方法仅输出第二列中的长度值,即28.107375?

谢谢

解决方案

stat ts输出到 stderr ,使用 2>& 1 重定向到 stdout 。使用 sed 来提取相关位:

  sox out.wav  - n stat 2>& 1 | sed -n's#^长度(秒):[^ 0-9] * \([0-9。] * \)$#\ 1#p'


I need to get the length of a .wav file.

Using:

sox output.wav -n stat

Gives:

Samples read:            449718
Length (seconds):     28.107375
Scaled by:         2147483647.0
Maximum amplitude:     0.999969
Minimum amplitude:    -0.999969
Midline amplitude:     0.000000
Mean    norm:          0.145530
Mean    amplitude:     0.000291
RMS     amplitude:     0.249847
Maximum delta:         1.316925
Minimum delta:         0.000000
Mean    delta:         0.033336
RMS     delta:         0.064767
Rough   frequency:          660
Volume adjustment:        1.000

How do I use grep or some other method to only output the value of the length in the second column, i.e. 28.107375?

Thanks

解决方案

The stat effect sends its output to stderr, use 2>&1 to redirect to stdout. Use sed to extract the relevant bits:

sox out.wav -n stat 2>&1 | sed -n 's#^Length (seconds):[^0-9]*\([0-9.]*\)$#\1#p'

这篇关于从sox输出中获取.wav的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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