Open gilnuy opened 8 years ago
I have the same problem with you.
The duration is calculated based upon the average bitrate of the file. Without reading the whole file (which defeats the purpose of seek-less streaming) it's not always possible to get a perfect approximation especially for VBR files.
In general, the error will tend towards 0 the longer you play the file (this means that the duration changes as the file is playing).
You could try increasing STK_MAX_COMPRESSED_PACKETS_FOR_BITRATE_CALCULATION. For MP3 files it may also be possible to read the length from the ID3 tags.
Cheers.
Thx, I've tried it, but it does not work.
I've modified like this, and it does work well.
-(double) calculatedBitRate
{
double retval;
if (packetDuration > 0.0)
{
if (processedPacketsCount > STK_BIT_RATE_ESTIMATION_MIN_PACKETS_PREFERRED || (audioStreamBasicDescription.mBytesPerFrame == 0 && processedPacketsCount > STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MIN))
{
double averagePacketByteSize = (processedPacketsSizeTotal * 1.0) / processedPacketsCount;
retval = averagePacketByteSize / packetDuration * 8;
return retval;
}
}
retval = (audioStreamBasicDescription.mBytesPerFrame * audioStreamBasicDescription.mSampleRate) * 8;
return retval;
}
Ahh, missed the int->double precision problem. Good catch. Fixed in HEAD.
for example: the duration is 1:30:10 streammingkit return is 1:30:40.
how could i get the right duration? please help me,thank you!