Skip to content

How to get length of audio file before reading each sample? #294

Closed

Description

@Boscop

Is it possible to get the length of the audio file before reading each sample?

Activity

  1. HalfVoxel commented on Oct 3, 2020

    @HalfVoxel
    Contributor

    source.size_hint().0 should work.

  2. est31 commented on Oct 3, 2020

    @est31
    Member

    size_hint is not required to be accurate.

  3. roderickvd commented on Aug 24, 2025

    @roderickvd
    Member

    Today you can call total_duration() or still inspect size_hint().1 with #786. The first gives an Option<Duration>, the second Option<usize> in amount of samples. Besides @est31 being correct that size_hint() is not guaranteed to be accurate, with decoding you can anyway never guarantee it due to I/O errors, malformed packets, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions