Code Monkey home page Code Monkey logo

music-metadata-browser's People

Contributors

borewit avatar dependabot-preview[bot] avatar dependabot[bot] avatar industral avatar tgambet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

music-metadata-browser's Issues

Source map warnings.

Using music-metadata-browser with create-react-app (react-scripts version: 5.0.1) gives 21 console warnings in command line about source-maps for the package.

Uncaught ReferenceError: `Buffer` is not defined

I am receiving this error:
Capture

I am importing the package like this:
import { parseBlob } from "music-metadata-browser"

I am calling the function like this:
const metadata = await parseBlob(audio)

I have already checked that I am passing a object of type File using instanceof.

I am using the latest version of music-metadata and Chrome.

Download from URL using HTTP-protocol.

Add an HTTP/XHR reader like for reading metadata based on an URL reference to an audio track. The track will be read based on range request to avoid to many is downloaded.

Support HTTP range request

Download metadata using HTTP range requests.

This would reduced bandwith, because only the required data from the audio track shall be requested.

This functionality maybe added in a different module.

transpiling to es5 with babel

I've got error (SCRIPT1028: SCRIPT1028: Expected identifier, string or number) in production build for edge browser.
It crashes in file-type/core.js _check function with spread operator
I'am using ts-loader -> babel-loader with preset-env and @babel/plugin-proposal-object-rest-spread plugin to transpile down to es5 but it seems it doesn't.
Any suggestions.

Can't use this package with vite 3

Hey, I currently use music-metadata with a buffer polyfill and vite 2 in my project. I would like to switch to this package (which is intended for the use in the browser) and vite 3. Sadly, it does not work, and I get the following error. I tried to polyfill the events module, but that led to more similar errors and I got into polyfilling hell.

Uncaught Error: Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code.
    at Object.get (browser-external:events:9:13)
    at node_modules/readable-web-to-node-stream/node_modules/readable-stream/lib/_stream_readable.js (_stream_readable.js:32:10)
    at __require (music-metadata-browser.js?v=8f4e2ce6:3:50)
    at node_modules/readable-web-to-node-stream/node_modules/readable-stream/readable-browser.js (readable-browser.js:1:28)
    at __require (music-metadata-browser.js?v=8f4e2ce6:3:50)
    at node_modules/readable-web-to-node-stream/lib/index.js (index.js:4:27)
    at __require (music-metadata-browser.js?v=8f4e2ce6:3:50)
    at node_modules/music-metadata-browser/lib/index.js (index.js:6:39)
    at __require (music-metadata-browser.js?v=8f4e2ce6:3:50)
    at dep:music-metadata-browser:1:16

I created a minimal reproduction of the issue here: https://github.com/lennyanders/music-metadata-browser-8-with-vite-3.
There you just need to execute npm i, after that npm start and then you can see the error in the browser console.

Thanks for looking into it and if I can be of any help, please let me know.

Setup Angular 6 with music-metadata-browser

Replacement of issue Borewit/music-metadata#163 from @bfromager:

V3.1.6
Trying to use music-metadata.parseFile() under Ionic 4/Angular 6

Got the following errors:
ERROR in ./node_modules/strtok3/lib/FsPromise.js
Module not found: Error: Can't resolve 'fs' in '...\node_modules\strtok3\lib'
ERROR in ./node_modules/music-metadata/lib/index.js
Module not found: Error: Can't resolve 'path' in '...\node_modules\music-metadata\lib'
ERROR in ./node_modules/music-metadata/lib/aiff/AiffParser.js
Module not found: Error: Can't resolve 'stream' in '...\node_modules\music-metadata\lib\aiff'
ERROR in ./node_modules/music-metadata/lib/riff/RiffParser.js
Module not found: Error: Can't resolve 'stream' in '...\node_modules\music-metadata\lib\riff'

Not sure if i'm doing something wrong

RangeError: offset is not uint

Hi there,

I'm loving music-metadata-browser. Nice work!

Every so often, though, when processing a file, it throws an error like the below for certain songs:

RangeError: offset is not uint
    at checkOffset (index.js:1165)
    at Uint8Array.readUInt32LE (index.js:1218)
    at ID3v24TagMapper.postMap (ID3v24TagMapper.js:173)
    at ID3v24TagMapper.mapGenericTag (GenericTagMapper.js:78)
    at CombinedTagMapper.mapTag (CombinedTagMapper.js:42)
    at MetadataCollector.toCommon (MetadataCollector.js:239)
    at MetadataCollector.addTag (MetadataCollector.js:102)
    at ID3v2Parser.addTag (ID3v2Parser.js:195)
    at ID3v2Parser.parseId3Data (ID3v2Parser.js:189)

When I say "certain songs" I mean mp3 files, and that the error is consistent, in that it will always happen for some files and it will never happen on others.

What are some things to look at with regards to the file to determine why a problematic file is causing the error?

I've read through issue #15 but couldn't quite figure out how to troubleshoot the issue.

I dropped some of the files in question on the Audio Tag Analyzer, and compared those to "known good" files, but I'm not seeing thing that sticks out.

Any advice would be greatly appreciated.

P.S. I'm using "music-metadata-browser": "^1.1.1" in a create-react-app

Add `parsers` option in `parseFile` to minimize bundle size

Feature Request

Webpack-bundle-analyzer output

As seen in the screenshot, all parsers are included in the music-metadata bundle. I'm curious if it's possible to reduce the bundle size when using a selection of parsers (such as ID3v2 and ID3v1). This is useful when you know what type of files you're dealing with beforehand.

Steps to reproduce

// src/index.js
const { parseFile } = require('music-metadata');
// webpack.config.js
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');

module.exports = {
  plugins: [new BundleAnalyzerPlugin()],
  optimization: {
    splitChunks: {
      cacheGroups: {
        vendors: {
          name: 'vendors',
          test: /[\\/]node_modules[\\/]/,
          chunks: 'all'
        }
      }
    }
  }
}
webpack --mode production

Suggestion

I'm not entirely sure how feasible this suggestion is, but it would be nice if something like this would be possible:

const { parseFile } = require('music-metadata');

parseFile(file, { parsers: ['id3v1', 'id3v2'] })

This way you keep the flexibility of automatically grabbing the correct parser for the file, but limit the amount of parsers it should check for (and hopefully decrease the overall bundle size by doing so).

Parser loading

Hey @Borewit πŸ‘‹
I finally got around to testing this package, sorry for the delay! πŸ˜„

I'm a little confused about the parser loading. So normally the parsers are lazy loaded, but how would that work in a browser? It doesn't seem to work for me (ie. I'm getting Cannot find module './mpeg/index' in the browser console). So what's the solution here? Copy all the parser files into the my javascript directory? Or manually import all the parsers I need into my bundle and then write a custom loadParser function?

Also, would it be possible to have a static browser build that works straight away without a javascript bundler? I'm not using a javascript bundler in version two of Diffuse. Totally cool if not.

Thanks! ✌️

Multiple blobs at once not parsing in WebWorker in Firefox

I've decided to move the parsing logic to the web worker, so that the main thread and ui wouldn't be impacted by analyzing lots of files.

Consider following web worker code:

/// <reference lib="webworker" />

import * as Metadata from 'music-metadata-browser'

const parse = async (id: number, file: File) => {
  try {
    console.log(`[${id}] parsing...`)
    const metadata = await Metadata.parseBlob(file)
    console.log(`[${id}] metadata:`, metadata)
    postMessage({ 
      id,
      status: 'success',
      metadata, 
      coverUrl 
    })
  } catch (error) {
    console.error(error)
    postMessage({ 
      id,
      status: 'failure',
      error
    })
  }
}

// ...

Now, when I try to parse it the easiest way possible, only a few random files are parsed:

addEventListener('message', async (event) => {
  const id = event.data.id as number
  const file = event.data.file as File
  parse(id, file)
})

image

In that case, only files with id 3 and 4 have been parsed. Note that pausing, the web worker thread in the devtools does nothing until I send a new file to process to the worker. It then breaks on the addEventListener. The parseBlob never resolves nor rejects.

Also, before moving all the logic into the web worker I could start parsing all files at the same time without any problems like so:

await Promise.allSettled(files.map(async (file) => {
  return Metadata.parseBlob(file)
}))

The workaround that I need to introduce now is to wait until one file is parsed and then start parsing the next one. That's not really what I want to do as it would be much less performant.

const queue = []
let queuePromise = Promise.resolve()
addEventListener('message', async (event) => {
  const id = event.data.id as number
  const file = event.data.file as File

  queue.push(() => parse(id, file))
  queuePromise = queuePromise.then(() => queue.shift()())
})

Affected browser: Firefox 120, it works well on Chromium

Vite 4 with the ngmi-polyfill plugin as per #836 (comment)

Offset is not uint

Issue description

I am working on a music track uploader. The user is supposed to upload a music file, and the uploader is supposed to display the file metadata, once the upload is successful.

I have two mp3 files that both have the same kind of metadata, tracks A and B.

Track A's metadata are read and displayed fine.

Track B's displays no metadata.

I investigated on this, and the cause of the issue is that at some point, after the track has been translated into an array buffer, a checkOffset is called with an offset argument that is undefined, and as a result it throws (file location is node_modules/node-libs-browser/node_modules/buffer/index.js line 1097).

The best I could do, was check the initial array buffer for any undefined data inside of it, but the .some() I run on it returned false.

The stack trace is this:

checkOffset (index.js:1165)
readUInt32LE (index.js:1218)
postMap (ID3v24TagMapper.js:194)
mapGenericTag (GenericTagMapper.js:40)
mapTag (CombinedTagMapper.js:54)
toCommon (MetadataCollector.js:256)
addTag (MetadataCollector.js:115)
addTag (ID3v2Parser.js:409)
_callee4$ (ID3v2Parser.js:357)
tryCatch (runtime.js:63)
invoke (runtime.js:282)
prototype.(anonymous function) (runtime.js:116)
fulfilled (ID3v2Parser.js:13)
Promise.then (async)
step (ID3v2Parser.js:30)
(anonymous) (ID3v2Parser.js:33)
push../node_modules/music-metadata/lib/id3v2/ID3v2Parser.js.__awaiter (ID3v2Parser.js:10)
parseId3Data (ID3v2Parser.js:170)
_callee$ (ID3v2Parser.js:95)
tryCatch (runtime.js:63)
invoke (runtime.js:282)
prototype.(anonymous function) (runtime.js:116)
fulfilled (ID3v2Parser.js:13)
Promise.then (async)
step (ID3v2Parser.js:30)
(anonymous) (ID3v2Parser.js:33)
push../node_modules/music-metadata/lib/id3v2/ID3v2Parser.js.__awaiter (ID3v2Parser.js:10)
parse (ID3v2Parser.js:59)
_callee2$ (AbstractID3Parser.js:162)
tryCatch (runtime.js:63)
invoke (runtime.js:282)
prototype.(anonymous function) (runtime.js:116)
fulfilled (AbstractID3Parser.js:19)
Promise.then (async)
step (AbstractID3Parser.js:36)
(anonymous) (AbstractID3Parser.js:39)
push../node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js.__awaiter (AbstractID3Parser.js:16)
tryReadId3v2Headers (AbstractID3Parser.js:141)
_callee$ (AbstractID3Parser.js:105)
tryCatch (runtime.js:63)
invoke (runtime.js:282)
prototype.(anonymous function) (runtime.js:116)
(anonymous) (AbstractID3Parser.js:39)
push../node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js.__awaiter (AbstractID3Parser.js:16)
parseID3v2 (AbstractID3Parser.js:96)
parse (AbstractID3Parser.js:83)
_callee3$ (ParserFactory.js:287)
tryCatch (runtime.js:63)
invoke (runtime.js:282)
prototype.(anonymous function) (runtime.js:116)
fulfilled (ParserFactory.js:13)
Promise.then (async)
step (ParserFactory.js:30)
(anonymous) (ParserFactory.js:33)
push../node_modules/music-metadata/lib/ParserFactory.js.__awaiter (ParserFactory.js:10)
_parse (ParserFactory.js:272)
_callee$ (ParserFactory.js:138)
tryCatch (runtime.js:63)
invoke (runtime.js:282)
prototype.(anonymous function) (runtime.js:116)
(anonymous) (ParserFactory.js:33)
push../node_modules/music-metadata/lib/ParserFactory.js.__awaiter (ParserFactory.js:10)
parse (ParserFactory.js:92)
parseFromTokenizer (core.js:56)
parseBuffer (core.js:37)
(anonymous) (index.js:61)
Promise.then (async)
parseBlob (index.js:60)

Can you direct me to the right direction for solving this?

I can provide you with the track files as well if you ask.

Thank you, and thank you for this library.

Nuxt 3 compatibility

mmb is throwing an error when trying to parseBlob. Could be fixed by polyfilling, but process.nextTick is also required by mmb but already set with a custom function from Nuxt, so polyfilling it is not an option.

ReferenceError: Buffer is not defined
    at ReadStreamTokenizer.peekToken (AbstractTokenizer.js:37:28)
    at FlacParser.tryReadId3v2Headers (AbstractID3Parser.js:52:48)
    at FlacParser.parseID3v2 (AbstractID3Parser.js:39:20)
    at FlacParser.parse (AbstractID3Parser.js:24:24)
    at parse (ParserFactory.js:38:50)
_stream_readable.js:490 Uncaught (in promise) TypeError: process.nextTick is not a function
    at emitReadable (_stream_readable.js:490:13)
    at addChunk (_stream_readable.js:284:29)
    at readableAddChunk (_stream_readable.js:262:11)
    at Readable.push (_stream_readable.js:228:10)
    at ReadableWebToNodeStream._read (index.js:44:18)

Uncaught Syntax Error: Unexpected token function when using with cordova app

Bug description
There is an uncaught syntax error thrown in the console when using this library in a cordova app.
The syntax error is thrown by simply importing the library:

try {
    var MusicMetadata = require("music-metadata");
} catch(e) {
    // syntax error thrown when using music-metadata library with cordova
    // console output if not caught: 
    // Uncaught SyntaxError: Unexpected token function
}

Expected behavior
No syntax error should be thrown.

Audio file demonstrating the problem
This has nothing to do with a specific audio file.

Related images
Untitled
image

Edit: was using music-metadata-browser in the above images but It is still the same issue with music-metadata. However the error is thrown on line 15 of index.js instead :
image

Edit: Through further investigation it seems that this bug only occurs in development if using android virtual device. running the app on a real device seems to work fine. I can live with this, but it would be nice if this bug is fixed though.

Empty metadata for AAC files

Hello!

I was working on an audioMotion update and realized it's not fetching metadata from any aac/m4a files anymore. parseBlob() still works fine, but not fetchFromUrl() or parseReadableStream(). No issues with other formats, like mp3, flac and ogg.

I'm not sure which version introduced the issue, since I use mostly flac. I had some old test code working with music-metadata-browser v1.4.0, and it stops working if I update to v1.5.0. The problem persists up to v1.9.1.

Below is the output with [email protected]:

metadata_ok

After updating to 1.5.0, the metadata is returned empty for m4a files:

empty_metadata

Here with debug info.. the parser seems to be working fine, but the collector returns an empty format/codec..

metadata_debug

My test code:

const mm = require('music-metadata-browser');

let files = [ 'test.m4a', 'test.mp3', 'test.ogg', 'test.flac', 'http://a1rj.streams.com.br:7801/stream' ];

files.forEach( uri => {

	mm.fetchFromUrl( uri, { duration: false, skipCovers: true } ).then( metadata => {
		console.log( `${uri} via fetchFromUrl():`, metadata );
	}).catch( err => console.log( err ) );

	fetch( uri ).then( response => {
		return response.body;
	}).then( stream => {
		mm.parseReadableStream( stream, '', { duration: false, skipCovers: true } ).then( metadata => {
			console.log( `${uri} via parseReadableStream():`, metadata );
			stream.cancel();
		}).catch( err => console.log( err ) );
	});

});

For the same audio, the file information obtained by using different APIs is different

mp3-meta-test.zip

test code

const musicMetadata = require('music-metadata-browser');
const fs = require('fs')
const path = require('path')

async function start() {
    let mp3 = path.join(__dirname, 'A8E0CE2D6C590E51F225201FB021885F.mp3')
    let meta = await musicMetadata.parseNodeStream(fs.createReadStream(mp3))
    console.log(meta)
    meta = await musicMetadata.parseBuffer(fs.readFileSync(mp3))
    console.log(meta)
}

start()

output

PS C:\Users\y> node C:\Users\y\Desktop\mp3-meta-test\index.js
{
  format: {
    tagTypes: [ 'ID3v2.3' ],
    trackInfo: [],
    lossless: false,
    container: 'MPEG',
    codec: 'MPEG 1 Layer 3',
    sampleRate: 44100,
    numberOfChannels: 1,
    bitrate: 32000,
    codecProfile: 'CBR'
  },
  native: { 'ID3v2.3': [ [Object] ] },
  quality: { warnings: [ [Object], [Object] ] },
  common: {
    track: { no: null, of: null },
    disk: { no: null, of: null },
    movementIndex: {}
  }
}
{
  format: {
    tagTypes: [ 'ID3v2.3', 'ID3v1' ],
    trackInfo: [],
    lossless: false,
    container: 'MPEG',
    codec: 'MPEG 1 Layer 3',
    sampleRate: 44100,
    numberOfChannels: 1,
    bitrate: 32000,
    codecProfile: 'CBR',
    numberOfSamples: 688896,
    duration: 15.62122448979592
  },
  native: { 'ID3v2.3': [ [Object] ], ID3v1: [ [Object] ] },
  quality: { warnings: [ [Object], [Object] ] },
  common: {
    track: { no: null, of: null },
    disk: { no: null, of: null },
    movementIndex: {},
    genre: [ 'Blues' ]
  }
}

Use ffmpeg to view the audio duration should be 4.44 seconds.

PS C:\Users\y\Desktop\mp3-meta-test> ffprobe.exe .\A8E0CE2D6C590E51F225201FB021885F.mp3                                 ffprobe version N-93863-g58d167bcd5 Copyright (c) 2007-2019 the FFmpeg developers
  built with gcc 8.3.1 (GCC) 20190414
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 27.100 / 56. 27.100
  libavcodec     58. 52.101 / 58. 52.101
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 53.100 /  7. 53.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[mp3 @ 000002085649c380] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '.\A8E0CE2D6C590E51F225201FB021885F.mp3':
  Metadata:
    genre           : Blues
    id3v2_priv.XMP  : <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27        ">\x0a <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">\x0a  <rdf
  Duration: 00:00:04.44, start: 0.000000, bitrate: 122 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, mono, fltp, 112 kb/s

fetchFromURL can't get metadata from m4a file

I'm getting the following error when trying to read metadata from m4a files with fetchFromURL():

TypeError: 'cancel' can't be called on a locked stream.

It works fine with mp3 and flac files though.

parseBlob() does work with the same m4a files.

Just updated to version 1.2.0, but the problem persists.

Thanks!

Vorbis tag "METADATA_BLOCK_PICTURE" in FLAC throws an error

Usually pictures in FLAC are using the PICTURE block-type (type 6).

In case a VORBIS COMMENT (type 4) block is used, with a base-64 encoded METADATA_BLOCK_PICTURE tag, the way pictures are embedded in Ogg/Vorbis, it will cause a crash.

Although I suspect using the METADATA_BLOCK_PICTURE in FLAC files is non-standard, I will consider the issue as a bug.

Caused by: Borewit/music-metadata#266 (please put comments here)
Blocks: audio-tag-analyze#21

fetchFromUrl doesn't include credentials

The function
export async function fetchFromUrl(audioTrackUrl: string, options?: IOptions): Promise<IAudioMetadata> {

Does a fetch without including the credentials or cors mode. When enabled, I can use it to fetch data from an url that needs a web session (login) to download the data.

I think it should be as simple as

await fetch(audioTrackUrl, {
    credentials: 'include',
    mode: 'cors'
})

2.5.0 Version updates Break Some Features on Safari

Issue:

After updating this package to the latest 2.5.0 version within our team's app, the functionality we had around audio files being uploaded was completely broken on Safari alone. All other browsers were unaffected by the update

Looking at the changelog, looks like the issue might be within the return of the parseBlob function:

if (blob instanceof File) {
  fileInfo.path = (blob as File).name;
}

return parseReadableStream(blob.stream(), {.....);

That switching of the blob from being a Uint8Array to a ReadableStream comes with an issue with the Default Reader of the ReadableStream -> https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader

Within the readable-web-to-node-stream package, the class constructor calls the ReadableStream.getReader() method, which returns the ReadableStreamDefaultReader that Safari has issues with ->

https://github.com/Borewit/readable-web-to-node-stream/blob/e81a7c91b1fa73cb11dc50bac41a9f033e0d030e/lib/index.ts#L27

Using music-metadata 7.x instead on 8.x

Hi,

Currently using music-metadata-browser (what an incredibly good project), I am facing a warning in Vite:

node_modules/file-type/core.js (1419:16) Use of eval in "node_modules/file-type/core.js" is strongly discouraged as it poses security risks and may cause issues with minification.

After seeking the reason of this warning, I saw that music-metadata-browser currently depends on "music-metadata": "^7.13.3", which depends on "file-type": "^16.5.4", which uses an eval in its code base.

Since "music-metadata": "8.1.4" depends on "file-type": "^18.2.1" (not uning eval anymore), I would suggest to update the dependencies to "music-metadata": "8.1.4";

I could help creating pull request if want me to.

Thanks.

Getting error on uploaded build of angular on server

Hi,

I have integrated music-metadata-browser in my Angular 8 project and its working fine on local server of my system but when I uploaded the project on server then getting error on the component in which music-metadata-browser is used. Error that I am getting is:

core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Class extends value undefined is not a constructor or null
TypeError: Class extends value undefined is not a constructor or null
at Object../node_modules/music-metadata/lib/id3v2/ID3Stream.js (ID3Stream.js:8)
at webpack_require (bootstrap:84)
at Object../node_modules/music-metadata/lib/aiff/AiffParser.js (AiffParser.js:12)
at webpack_require (bootstrap:84)
at Object../node_modules/music-metadata/lib/ParserFactory.js (ParserFactory.js:9)
at webpack_require (bootstrap:84)
at Object../node_modules/music-metadata/lib/core.js (core.js:5)
at webpack_require (bootstrap:84)
at Object../node_modules/music-metadata-browser/lib/index.js (index.js:5)

Incompatibility with Webpack 5

When trying to use the music-metadata-browser with webpack 5 serveral errors will appear.

  1. Several *.js.map files can't be found anymore.
Error warnings `Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\apev2\APEv2TagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\apev2\APEv2TagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\apev2\APEv2Token.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\apev2\APEv2Token.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\asf\AsfTagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\asf\AsfTagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\CaseInsensitiveTagMap.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\CaseInsensitiveTagMap.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\CombinedTagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\CombinedTagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\FourCC.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\FourCC.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\GenericTagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\GenericTagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\GenericTagTypes.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\GenericTagTypes.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\MetadataCollector.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\MetadataCollector.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\Util.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\common\Util.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\id3v1\ID3v1TagMap.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\id3v1\ID3v1TagMap.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\id3v2\ID3v22TagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\id3v2\ID3v22TagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\id3v2\ID3v24TagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\id3v2\ID3v24TagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\matroska\MatroskaTagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\matroska\MatroskaTagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\matroska\types.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\matroska\types.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\mp4\MP4TagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\mp4\MP4TagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\ogg\vorbis\VorbisTagMapper.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\ogg\vorbis\VorbisTagMapper.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\riff\RiffInfoTagMap.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\riff\RiffInfoTagMap.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\type.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\music-metadata\lib\type.js.map'

Failed to parse source map from 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\readable-web-to-node-stream\lib\index.js.map' file: Error: ENOENT: no such file or directory, open 'D:\Programmierung\JS_React\delete\music-analyzer\node_modules\readable-web-to-node-stream\lib\index.js.map'`

This can be fixed temporarly by setting the enviroment variable
GENERATE_SOURCEMAP=false

  1. Parsing won't be working anymore since buffer isn't supported anymore (?)
    https://stackoverflow.com/questions/67009449/after-upgrading-webpack-to-version-5-getting-run-time-error-buffer-is-not-defin

Uncaught (in promise) ReferenceError: Buffer is not defined at new MpegParser (MpegParser.js:218:1) at Function.loadParser (ParserFactory.js:148:1) at parse (ParserFactory.js:36:1) at Function.parse (ParserFactory.js:79:1) at Function.parseOnContentType (ParserFactory.js:55:1) at async parseReadableStream (index.js:31:1)

This error makes it nearly impossible to use this libary with the newest CRA of React or any other projects which rely on webpack5.

To reproduce the error you just have to setup the basic react-app and try to implement music-metadata-browser.

Unable to parse audio tags using 'fetchFromUrl'

I'm working on a music app using Vue framework, currently my app is on localhost server .I'm unable to parse the audio files which is .in .mp3 format located inside 'src/assets/songs' folder, the webpack seems to load the files without any issues but the 'fetchFromUrl' function throws 'Type Error: Failed to fetch' error in catch block. I've also checked the Network tab in chrome ,the status seems to be pending for a while but fails eventually how can I rectify this?

1
2
3
4

Bug with in-browser implementation

I'm seeing the following message in my browser with builds and local dev (Node16, Typescript 4, Vite, VueJS)

_stream_readable.js:529 Uncaught (in promise) TypeError: process.nextTick is not a function
    at emitReadable (_stream_readable.js:529)
    at addChunk (_stream_readable.js:303)
    at readableAddChunk (_stream_readable.js:280)
    at ReadableWebToNodeStream.Readable.push (_stream_readable.js:241)
    at ReadableWebToNodeStream._read (index.js:44)

Here's the full trace:

Screen Shot 2021-08-26 at 7 37 56 PM

Before I say ANYTHING else, I just want to say THANK YOU for all the difficult and thoughtful work you put into building and maintaining this library. I also want to add that I've spent a few hours googling and experimenting with potential fixes before coming here to ask for help. πŸ˜€

In my project, I do the following shimming:

src/shim.ts

// source: https://github.com/Azure/azure-sdk-for-js/issues/14496
import * as process from 'process'
import * as events from 'events'
import { Buffer } from 'buffer'
import { Readable } from 'readable-stream'

Object.assign(self, {
  process,
  Buffer,
  Readable,
  EventEmitter: events,
  global: self,
})

This is my "main" file (entrypoint) ==> src/main.ts

import 'shim.ts'
import 'vue-global-api'
import devalue from '@nuxt/devalue'
import { ViteSSG } from 'vite-ssg'

.... and then EVERYTHING else after that

and I have a file called src/components/helpers.ts (where I use music-metadata-browser)

/* eslint-disable no-console */
import * as musicMetadata from 'music-metadata-browser'


interface FileToBeUploaded extends File {
  audioMeta?: musicMetadata.IAudioMetadata | null
}

const parseMeta = async(audioFilesToParse: FileToBeUploaded[]) => {
  try {
    const metaArray = Promise.all(
      audioFilesToParse.map(async(file) => {
        const metaForFile = await musicMetadata.parseBlob(file)

        if (metaForFile.common.title && (metaForFile.common.artist || metaForFile.common.artists))
          console.log('GOT META: ', metaForFile)
        else console.warn('NO Artist or Song Meta! for ', file.name)

        return Object.assign(file, {
          audioMeta: metaForFile || null,
        })
      }),
    )

    return metaArray
  }
  catch (error) {
    console.error(error)
  }
}

const sanitizeFilenames = (newFiles: FileToBeUploaded[]) => {
  return newFiles.map((item) => {
    // Replace any spaces in filename with underscore
    const sanitizedName = item.name.split(' ').join('_')

    return Object.defineProperty(item, 'name', {
      writable: true,
      value: sanitizedName,
    })
  })
}

export const prepareFiles = async(filesToPrepare: FileToBeUploaded[]) => {
  const sanitizedFileArray = sanitizeFilenames(filesToPrepare)
  const parsedMetaFileArray = await parseMeta(sanitizedFileArray)

  return parsedMetaFileArray
}

Any help would be MUCH appreciated! Thank you so much!

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

The property '#/update_configs/0/automerged_updates/1/match/update_type' value "semver::minor" did not match one of the following values: all, security:patch, semver:patch, semver:minor, in_range

Please update the config file to conform with Dependabot's specification using our docs and online validator.

No title or artist metadata from URL streams

I am trying to use this package in an angular application to read metadata about streaming radio stations using an URL, however it seems the library is not able to catch the title and artist data.
I tried running both in my own Angular project and the demo here that you provided.
By dragging the stream URL on the drop box, some metadata about bitrate etc. is extracted however there is no title or artist name as you can see here:
image

At the same time an application like foobar2000 is able to get the artist and song title from the stream as you can see:
image

Here are some example streams i used:
https://stream.open.fm/3
https://listen6.myradio24.com/walcon

From what I understand it should be possible to gather this information using this package

Broken data in metadata result

Hi, today we found that metadata parse doesn't work anymore in our case,
image

package versions were tested: 2.2.6, 2.5.4.
browser chrome latest version

const metadata = mm.parseReadableStream(file.stream());

metadata.then(result => {
    console.log(result);
});

Add MusicSource to online demos

Hello @Borewit,
This is not an issue, but repository discussions are not enabled so I take the liberty to contact you this way.
I have release an open source project that heavily relies on music-metadata-browser: MusicSource.
You might want to take a look. Thank you for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.