Search code examples
c++audioogg

Getting .ogg audio clip duration


I'm using stb_vorbis.c to load/decode .ogg audio files in C++. How do I get the clip's duration in seconds?


Solution

  • You can use the stb_vorbis_stream_length_in_seconds function which takes the result of the stb_vorbis_open_file call as the argument. Here is an example of how it is used.