dimanche 10 juillet 2016

Obtain the total number of samples with FFMpeg


Currently my application reads audio files based on a while-realloc loop:

// Pseudocode
float data* = nullptr;
int size = 0;
AVFrame* frame;
while(readFrame(formatContext, frame))
{
    data = realloc(data, size + frame.nSamples);
    size += frame.nSamples;
    /* Read frame samples into data */
}

Is there a way to obtain the total number of samples in a stream at the beginning? I want to be able to create the array with new[] instead of malloc.


Aucun commentaire:

Enregistrer un commentaire