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

Missing "numberOfSamples" on parsing audio file #2273

Closed
2 tasks done
julianpoemp opened this issue Oct 30, 2024 · 1 comment · Fixed by #2282
Closed
2 tasks done

Missing "numberOfSamples" on parsing audio file #2273

julianpoemp opened this issue Oct 30, 2024 · 1 comment · Fixed by #2282
Labels
bug Bug, will addressed with high priority

Comments

@julianpoemp
Copy link

julianpoemp commented Oct 30, 2024

Is there an existing issue for this?

  • I have searched the existing issues

music-metadata version

10.5.1

Current Behavior

Audio sample (needs to be downloaded):
https://upload.poemp.net/index.php/s/Qc2qgKmcgUt55Iu/download

parseWebStream() with "audio/mpeg" returns audio information without "format.numberOfSamples" attribute.

    try {
      // Assuming you have a ReadableStream of an audio file
      const response = await fetch('http://localhost:5321/media/zahlen.mp3');
      const webStream = response.body!;

      // Parse the metadata from the web stream
      console.log("METADATA:");
      const metadata = await parseWebStream(webStream, 'audio/mpeg');

      // Log the parsed metadata
      console.log(metadata);
    } catch (error) {
      console.error('Error parsing metadata:', error);
    }

This issue is related to parsing a part of the supported audio formats like mp3, m4a a.s.o. .

I had a look on the Parser codes and found out, that "numberOfSamples" is not set there.

Expected Behavior

parseWebStream (and other parsing methods) should always return "format.numberOfSamples" attribute.

The numberOfSamples attribute is very important for calculating correct time positions in samples with the original aample rate. Knowing the maximum duration in samples is very important e.g. for annotation of audio files.

Please set "numberOfSamples" on every audio format.

Attached audio sample?

  • I have provided sufficient information to reproduce the issue
@julianpoemp julianpoemp added the bug Bug, will addressed with high priority label Oct 30, 2024
@julianpoemp julianpoemp changed the title Missing "numberOfSamples" on parsing mp3 file Missing "numberOfSamples" on parsing audio file Oct 31, 2024
@Borewit
Copy link
Owner

Borewit commented Nov 10, 2024

@julianpoemp I cannot guarantee that the numberOfSamples is available for every type of audio file, as music-metadata is not designed to parse the audio portion. But for the example provided, it could be done: #2282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, will addressed with high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants