Jump to content
  • Advertisement
Sign in to follow this  
_rab_

Ogg stream length

This topic is 4494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a ogg/vorbis stream, i need to know how long it is (pcm duration). Does anyone know if this possible? I'm not opening a file, it's streaming from the internet, so I can't use the ov_* functions (unless I'm wrong), and I can't find anything in the headers that store this information. I guessed this would be something that is done frequently, but can't find any reference to this sort of stuff on the web. Cheers Rab

Share this post


Link to post
Share on other sites
Advertisement
You can determine the length of a track going by the data length, frequency and the format. I wrote these functions a while ago to find the length of a track.


ALuint oalGetSampleSize(ALenum format){
//defaults to 1, even if the format is invalid
ALuint sampleSize = 1;
switch (format){
case AL_FORMAT_STEREO16:
sampleSize *= 2;
case AL_FORMAT_MONO16:
case AL_FORMAT_STEREO8:
sampleSize *= 2;
break;
}
return sampleSize;
}

ALfloat oalGetTrackLength(ALuint dataLength,ALuint freq,ALenum format){
ALfloat trackLength = 0.0f;
if (freq != 0.0f){//avoid divide by zero
trackLength = dataLength / (ALfloat)(freq * oalGetSampleSize(format));
}
return trackLength;
}

Share this post


Link to post
Share on other sites
Thanks for your reply Gorax - that's the best option i could think of, but I don't have the uncompressed data length - it's streaming from the internet and I'm not guaranteed that all the data is down yet :/

I was wanting to know if this information was available in the headers. I thought it might be simply because windows media player knows what length an mp3 is when it is being streamed - so i guess mp3 has it - just don't know if it exists in ogg, or where to get it from if it does.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!