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

Wav: Failed to read RIFF INFO item value #373

Open
Ferry-200 opened this issue Apr 10, 2024 · 5 comments
Open

Wav: Failed to read RIFF INFO item value #373

Ferry-200 opened this issue Apr 10, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Ferry-200
Copy link

Ferry-200 commented Apr 10, 2024

Reproducer

I tried this code:

let tagged_file: Option<TaggedFile> = match lofty::read_from_path(
        "C:\\Users\\ferry\\Music\\test\\大哉乾元(洛天依人声版)_MMM.wav",
    ) {
        Ok(value) => Some(value),
        Err(err) => {
            // Wav: Failed to read RIFF INFO item value
            println!("{}", err);
            None
        }
    };

The lofty version is "0.18.2"
image

Summary

There is an error "Wav: Failed to read RIFF INFO item value"

The Windows Properties page can read the tags in it. I can also play it on Windows Media Player.

Can anyone provide some information about this? Thanks.

Expected behavior

Read tag correctly.

Assets

大哉乾元(洛天依人声版)_MMM.wav

@Ferry-200 Ferry-200 added the bug Something isn't working label Apr 10, 2024
@Serial-ATA
Copy link
Owner

Hello!

Your file has items that are not UTF-8 encoded. What is your local character encoding? If Windows is able to read it, that means the file is using your system encoding.

@Ferry-200
Copy link
Author

Ferry-200 commented Apr 10, 2024

UTF-16.
And the file's tags are UTF-16 LE encoded.

@Serial-ATA
Copy link
Owner

Hm. It's unfortunate that RIFF doesn't specify a text encoding. We would be able to somewhat reliably detect UTF-16 LE, but there's no BOM either. The only way for us to know ahead of time how to decode the text would be using GetACP() from Windows. Don't know how I feel about having platform-specific code in Lofty, though.

@Ferry-200
Copy link
Author

Ferry-200 commented Apr 10, 2024

Maybe we can simply set the way to decode text when reading riff info. Obviously it is not a good way to fix it though.

And this is the way how the Taglib support it. StringHandler

StringHandler

Detailed Description

An abstraction for the string to data encoding in Info tags.

RIFF INFO tag has no clear definitions about character encodings. In practice, local encoding of each system is largely used and UTF-8 is popular too.

Here is an option to read and write tags in your preferred encoding by subclassing this class, reimplementing parse() and render() and setting your reimplementation as the default with Info::Tag::setStringHandler().

@Serial-ATA
Copy link
Owner

That would also work. Gonna have to think about this one. For now I'd just recommend changing the encoding of your files to UTF-8, that's what most libraries (outside of TagLib) will exclusively support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants