3

i'm looking for an efficient alternative to grabbing audio file attributes in case spotlight is turned off.

Spotlight's MDItem attributes: kMDItemDurationSeconds, kMDItemAudioEncodingApplication, kMDItemAudioBitRate, kMDItemAudioSampleRate,kMDItemAudioChannelCount, kMDItemCodecs, are possible.

however QTKit's movieAttributes (if the file can be a QTMovie type), are not as complete, only QTMovieDurationAttribute fills my spec.

should i use Audio Format Services : OSStatus AudioFormatGetProperty, or is there something else, perhaps more light-weight that will suffice in the absence of MDItem information ?

i don't need to modify or play any files, i only need to know the property values.

thanks.

4

2 回答 2

0

如果您不害怕使用终端,mdls 可能是适合您的工具:

mdls /path/toYour/file
于 2012-06-04T15:08:38.803 回答
0

从音轨的媒体而不是电影中获取属性。这是一个如何以秒为单位获取持续时间的示例。

for (QTTrack* track in [movie tracks])
{
    QTMedia* trackMedia = [track media];

    if ([trackMedia hasCharacteristic:QTMediaCharacteristicAudio])
    {
        QTTime mediaDuration = [(NSValue*)[trackMedia attributeForKey:QTMediaDurationAttribute] QTTimeValue];
        long long mediaDurationScaleValue = mediaDuration.timeScale;
        long long mediaDurationTimeValue = mediaDuration.timeValue;
        result = (double)mediaDurationTimeValue / (double)mediaDurationScaleValue;
        break;
    }
}

[trackMedia mediaAttributes]将为您提供音频的其他可用属性。

于 2012-06-05T23:43:29.487 回答