Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Failed to read audio data from file waveform (-50) #295

Open
norbertmocsnik opened this issue Mar 11, 2016 · 2 comments
Open

Error: Failed to read audio data from file waveform (-50) #295

norbertmocsnik opened this issue Mar 11, 2016 · 2 comments

Comments

@norbertmocsnik
Copy link

For certain mp3 files getWaveformDataWithNumberOfPoints in EZAudioFile.m crashes because it reaches the end of file sooner than expected.

Here is an example for how it turns out:
0: 4541
1: 4541
...: 4541
994: 4541
995: 4541
996: 492
997: 0
Error: Failed to read audio data from file waveform (-50)

By default EZAudioFileWaveformDefaultResolution is 1024 so we're expecting to read 1024 times using ExtAudioFileRead but as you can see at read #996 we can already only read 492 frames instead of 4541 as calculated based on the meta data extracted from reading from the file.

I have at least 2 audio files where this is happening, both are mp3, one of them is proper music 44,100 320kbps stereo, the other is an audio book 22,050 mono and some lower bitrate.

Seems like a check for the actual number of bytes read in getWaveformDataWithNumberOfPoints is missing such as:

   for (SInt64 i = 0; i < numberOfPoints; i++)
    {
        UInt32 bufferSize = (UInt32) framesPerBuffer;
        [EZAudioUtilities checkResult:ExtAudioFileRead(self.info->extAudioFileRef,
                                                       &bufferSize,
                                                       audioBufferList)
                            operation:"Failed to read audio data from file waveform"];

        if (bufferSize == 0) {
            // unexpected end of file -- might happen for compressed formats for some reason
            break;
        }

Although I'm not sure at this point if that's the correct solution or remaining buffers/RMS values for the rest of the file that was missing need to be zeroed out.

Not sure what's causing this, perhaps it's how ExtAudioFileRead reads compressed formats, perhaps it's some internal bug, will investigate further but wanted to file an issue in the meantime.

@gevariya-ajit
Copy link

Having same problem, @norbertmocsnik do you have any solution?

@norbertmocsnik
Copy link
Author

@gevariya-ajit Adding the if above in EZAudioFile.m seems to solve it technically although I'm not sure about the implications. It depends on how you use the data afterwards because now there's less data than expected. It works for my use case for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants