[英]How to get the uncompressed file size of an MP3 file using CoreAudio API
Using CoreAudio, I am able to get the sampleRate (frames per second) and the file size, but in order to get the "total" time of the song, I need to know the Real file size of that compressed mp3. 使用CoreAudio,我能够获得sampleRate(每秒帧数)和文件大小,但是为了获得歌曲的“总”时间,我需要知道该压缩mp3的实际文件大小。
AudioStreamBasicDescription asbd;
UInt32 asbdSize = sizeof(asbd);
// get the stream format.
err = AudioFileStreamGetProperty(inAudioFileStream, kAudioFileStreamProperty_DataFormat, &asbdSize, &asbd);
if (err)
{
[self failWithErrorCode:AS_FILE_STREAM_GET_PROPERTY_FAILED];
return;
}
sampleRate = asbd.mSampleRate;
Is there any way I can know the real size of the song using Objective-C? 有什么方法可以使用Objective-C知道歌曲的真实大小吗?
Thanks in advance. 提前致谢。
See the answer to this question 看到这个问题的答案
There's a property you can ask in AudioFileGetProperty
called kAudioFilePropertyEstimatedDuration
that should do the trick. 您可以在
AudioFileGetProperty
请求一个名为kAudioFilePropertyEstimatedDuration
的属性来kAudioFilePropertyEstimatedDuration
这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.