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 reading some flac files #54

Closed
pkfox opened this issue Oct 25, 2020 · 7 comments
Closed

Error reading some flac files #54

pkfox opened this issue Oct 25, 2020 · 7 comments

Comments

@pkfox
Copy link

pkfox commented Oct 25, 2020

Hi Aaron , thanks for the great library - I'm seeing this exception when opening certain ( not all ) flac files.
It is thrown here which is in BinaryDataHelper.cs

public static UInt64 GetUInt64(byte[] data, int byteOffset, int bitCount, byte bitOffset)

Specified argument was out of the range of valid values.
Parameter name: Provided arguments would require reading outside of the data array upper bounds

@AaronLenoir
Copy link
Owner

AaronLenoir commented Nov 25, 2020

Hello @pkfox sorry I didn't see your post sooner.

Could you share one or more of the files that are failling? The GetUInt64 function is a generic function, so from that it's hard to say what part of the file the library is having issues with. If you can't provide the file, are you able to get the full stack trace of the exception?

Thanks for the help!

@pkfox
Copy link
Author

pkfox commented Nov 26, 2020

Nocturne No 1 in B flat minor Op 9 No 1.zip

Hi Aaron thanks for getting back to me - having done some research I think the problem stems from the fact that, I have a lot of flac files that don't have the magic marker fLaC in the header , they were ripped a long time ago by a Linux program called Grip. As you can see the in the file I've supplied the magic marker is ID3 so it failed the VerifyFlacIdentity() in FlacFile.cs. To progress further into the program I commented out the call to VerifyFlacIdentity() and then got the error I reported. Hope that helps.

@AaronLenoir
Copy link
Owner

AaronLenoir commented Nov 26, 2020

Thanks!

The problem doesn't seem to be that it doesn't have a fLaC marker. It's actually there a little further, but it looks like a big blob of ID3 metadata is put in front of it.

Since metaflac has no issues with your file, I think they are ignoring all bytes before the magic marker, where FlacLibSharp just bails out if the file doesn't start with that marker. I think I can do the same as what metaflac is doing.

@AaronLenoir
Copy link
Owner

@pkfox I think I covered that case now, if you have some time could you try it out with this branch on some of your files and let me know how it goes?

@pkfox
Copy link
Author

pkfox commented Nov 27, 2020

Hi Aaron all is good now - thanks very much

@AaronLenoir
Copy link
Owner

Good news! I'll make a release.

Thanks a lot for taking the time to report the issue, this made the library more useful!

@AaronLenoir
Copy link
Owner

The fix is in the newly published release version 3.2.1

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