Skip to content

Calculating audio track duration in seconds #223

@ClementNerma

Description

@ClementNerma

Hi there!

I'm currently trying to compute the duration of a given Track. From what I understand, the following works:

track.codec_params.time_base?.calc_time(track.codec_params.n_frames?) // Gives a `Time` value

Is that right?

In case these values aren't available (e.g. formats with variable sample width such as MPEG or Vorbis), I understand the entire audio track needs to be read in order to determine the duration from the sum of all samples, right?

How do I achieve this? I have the loop that can get me a set of AudioBufferRef, but I don't know how to get an actual duration from it.

How can I compute it? Thanks in advance for your help :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions