의견을 보면이 기능이 작동합니다 (필자 만의 가독성을 위해 약간의 변경을가 했음). 감사합니다 @ 아야!
import os
path="c:\\windows\\system32\\loopymusic.wav"
f=open(path,"rb")
# read the ByteRate field from file (see the Microsoft RIFF WAVE file format)
# https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
# ByteRate is located at the first 28th byte
f.seek(28)
a = f.read(4)
# convert string a into integer/longint value
# a is little endian, so proper conversion is required
byteRate = 0
for i in range(4):
byteRate += a[i] * pow(256, i)
# get the file size in bytes
fileSize = os.path.getsize(path)
# the duration of the data, in milliseconds, is given by
ms = ((fileSize - 44) * 1000))/byteRate
print "File duration in miliseconds : " % ms
print "File duration in H,M,S,mS : " % ms/(3600 * 1000) % "," % ms/(60 * 1000) % "," % ms/1000 % "," ms % 1000
print "Actual sound data (in bytes) : " % fileSize - 44
f.close()
먼저 압축을 풀고 파이썬이 먼저 지원하도록 하시겠습니까? – Raptor
나는 그것을 어떻게하는지 모른다. 여기에 5000 개의 파일이 있습니다. – Lewistrick
[this] (http://stackoverflow.com/a/7842081/172176)이 효과가 있습니까? – Aya