npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flac-metadata2

v1.0.0

Published

FLAC metadata processor implemented as Transform stream

Downloads

1

Readme

flac-metadata2

A FLAC metadata processor for Node.js, implemented as Transform stream.

Installation

npm install flac-metadata2

Usage Examples

Some simple examples to get you started:

Noop

Does nothing, just pipes a source FLAC through the Processor into a target FLAC.

var fs = require("fs");
var flac = require("flac-metadata2");

var reader = fs.createReadStream("source.flac");
var writer = fs.createWriteStream("target.flac");
var processor = new flac.Processor();

reader.pipe(processor).pipe(writer);

Trace Metadata

Traces out the metadata from a FLAC file.

var fs = require("fs");
var flac = require("flac-metadata2");

var reader = fs.createReadStream("source.flac");
var processor = new flac.Processor({ parseMetaDataBlocks: true });
processor.on("postprocess", function(mdb) {
  console.log(mdb.toString());
});

reader.pipe(processor);

The output should be something like this:

[MetaDataBlockStreamInfo] type: 0, isLast: false
  minBlockSize: 4096
  maxBlockSize: 4096
  minFrameSize: 14
  maxFrameSize: 12389
  samples: 9750804
  sampleRate: 44100
  channels: 2
  bitsPerSample: 16
  duration: 3:41.107
  checksum: 1746dff27beb6d1875a88cfeed8a576b

[MetaDataBlockVorbisComment] type: 4, isLast: false
  vendor: reference libFLAC 1.2.1 20070917
  comments:
    ALBUM: Close to the Glass
    ARTIST: The Notwist
    GENRE: Rock
    DATE: 2014
    TITLE: Signals

[MetaDataBlockPicture] type: 6, isLast: true
  pictureType: 3
  mimeType: image/png
  description:
  width: 120
  height: 120
  bitsPerPixel: 32
  colors: 0
  pictureData: 391383

Strip All Metadata

Pipes a source FLAC through the Processor into a target FLAC, removing all metadata.

var fs = require("fs");
var flac = require("flac-metadata2");

var reader = fs.createReadStream("source.flac");
var writer = fs.createWriteStream("target.flac");
var processor = new flac.Processor();

processor.on("preprocess", function(mdb) {
  // STREAMINFO is always the first (and only mandatory) metadata block.
  if (mdb.type === flac.Processor.MDB_TYPE_STREAMINFO) {
    // When a metadata block's isLast flag is set to true in preprocess,
    // subsequent blocks are automatically discarded.
    mdb.isLast = true;
  }
});

reader.pipe(processor).pipe(writer);

Inject Metadata

Injects a VORBIS_COMMENT block (and removes the existing one, if any).

var fs = require("fs");
var flac = require("flac-metadata2");

var reader = fs.createReadStream("source.flac");
var writer = fs.createWriteStream("target.flac");
var processor = new flac.Processor();

var vendor = "reference libFLAC 1.2.1 20070917";
var comments = [
  "ARTIST=Boyracer",
  "TITLE=I've Got It And It's Not Worth Having",
  "ALBUM=B Is For Boyracer",
  "TRACKNUMBER=A1",
  "DATE=1993",
  "DISCOGS=22379"
];

processor.on("preprocess", function(mdb) {
  // Remove existing VORBIS_COMMENT block, if any.
  if (mdb.type === flac.Processor.MDB_TYPE_VORBIS_COMMENT) {
    mdb.remove();
  }
  // Inject new VORBIS_COMMENT block.
  if (mdb.removed || mdb.isLast) {
    var mdbVorbis = flac.data.MetaDataBlockVorbisComment.create(mdb.isLast, vendor, comments);
    this.push(mdbVorbis.publish());
  }
});

reader.pipe(processor).pipe(writer);

License

MIT