user488792
user488792

Reputation: 2013

Estimating the time-position in an audio using data?

I am wondering on how to estimate where I am currently in an audio with regards to time, by using the data.

For example, I read data by byte[8192] blocks. How can I know how much byte[8192] is equivalent to in time?

Upvotes: 1

Views: 79

Answers (2)

brainwash
brainwash

Reputation: 689

I think this is not what he was asking. First you have to tell us what kind of data you are using. WAV? MP3? Usually without knowing where that block came from - so you know if you have some kind of frame information and where to find it - you are not able to determine that block's position. If you have the full stream and this data then you can do a search

Upvotes: 0

Brad
Brad

Reputation: 163428

If this is some sort of raw-ish encoding, like PCM, this is simple. The length in time is a function of the sample rate, bit depth, and number of channels. 30 seconds of 16-bit audio at 44.1kHz in mono is 2.5MB. However, you also need to factor in headers and container format crapola. WAV files for example can have a lot of other stuff in them.

Compressed formats are much more tricky. You can never be sure where you are without playing through the file to get to where you are. Of course you can always guesstimate based on the percentage of the file length, if that is good enough for your case.

Upvotes: 1

Related Questions