Re: Slow seeking in MP3 files using ExtAudioFile
Re: Slow seeking in MP3 files using ExtAudioFile
- Subject: Re: Slow seeking in MP3 files using ExtAudioFile
- From: Hamish Allan <email@hidden>
- Date: Fri, 23 Jan 2009 14:50:46 +0000
On Thu, Jan 22, 2009 at 8:20 PM, Christopher Atlan <email@hidden> wrote:
> I'm trying the same thing, but I use AudioFileStreamGetProperty
> kAudioFileStreamProperty_FrameToPacket and AudioFileStreamSeek for the
> offset which works fine.
That property looks useful; thank you for pointing it out to me. I'm
not sure how I missed it first time through the docs!
So for MP3 data, does the AudioFileStreamSeek always return an
estimate of the byte offset? Or is the AudioFileStream building up a
packet table for everything played so far, which it can use if you
skip backwards, or return kAudioFileStreamError_InvalidPacketOffset or
kAudioFileStreamError_DataUnavailable if you try to skip to a packet
beyond the end of the bytes parsed?
Also, there remains the issue of trying to convert seconds into
frames. Any estimate of the duration of the audio file based on e.g.
HTTP expected content length may not be accurate, because who knows
how much of the remaining data is audio? This is my current best
estimate:
AudioStreamBasicDescription asbd; // set to kAudioFileStreamProperty_DataFormat
CGFloat secondsPerPacket = (CGFloat)asbd.mFramesPerPacket /
(CGFloat)asbd.mSampleRate;
SInt64 dataOffset; // set to kAudioFileStreamProperty_DataOffset
SInt64 expectedLength; // set to HTTP expected content length
SInt64 bytesParsedSoFar; // set to number of bytes passed to
AudioFileStreamParseBytes
SInt64 packetCountSoFar; // set to kAudioFileStreamProperty_AudioDataPacketCount
SInt64 estimatedPacketCount = (expectedLength - dataOffset) /
(bytesParsedSoFar - dataOffset) * packetCountSoFar;
CGFloat estimatedTotalSeconds = estimatedPacketCount * secondsPerPacket;
Can I do better than this?
Thanks,
Hamish
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden