# flac-substream

> NodeJS module for streaming subsections of FLAC files

Latest version **0.1.7** (published 2021-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install flac-substream
pnpm add flac-substream
yarn add flac-substream
bun add flac-substream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2021-09-03 |
| First published | 2017-02-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | lammas |
| Maintainers | lammas |
| Keywords | flac, stream |

## Links

- npm: https://www.npmjs.com/package/flac-substream
- Repository: https://github.com/lammas/flac-substream
- Homepage: https://github.com/lammas/flac-substream#readme
- Issues: https://github.com/lammas/flac-substream/issues
- npm.io page: https://npm.io/package/flac-substream

## Dependencies (2)

- [bin-format](https://npm.io/package/bin-format.md) ^1.4.1
- [flac-seektable](https://npm.io/package/flac-seektable.md) ^0.2.1

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.1.7 (latest) — 2021-09-03
- 0.1.6 — 2021-05-08
- 0.1.5 — 2020-07-21
- 0.1.4 — 2020-04-05
- 0.1.3 — 2019-11-01
- 0.1.2 — 2019-05-08
- 0.1.1 — 2017-02-21
- 0.1.0 — 2017-02-21

## README

# flac-substream

NodeJS module for streaming subsections of FLAC files.
This module is intended to accompany the [flac-seektable](https://github.com/lammas/flac-seektable) module.


## Install

```sh
npm install flac-substream
```

## Usage

The module returns a single function:

```javascript
substream(
	writable,        // A stream.Writable object for the output
	seekdata,        // Metadata object from flac-seektable module
	start,           // Start position (index into seekpoints)
	end,             // End position (index into seekpoints)
	get_read_stream  // Function with signature: (start, end), must return stream.Readable
)
```

The `get_read_stream` function must return a stream.Readable object that provides data from the FLAC file from offset `start` to offset `end`.


```javascript
// Demonstrates the usage to perform random access on a file.
// This is by no means a practical example (most usecases would involve storage of the FLAC metadata beforehand).

const fs = require('fs');
const seektable = require('flac-seektable');
const substream = require('flac-substream');

const FLAC_IN = 'input.flac';
const FLAC_OUT = 'output.flac';
const START_SECONDS = 10;
const END_SECONDS = 20;

var reader = fs.createReadStream(FLAC_IN);
reader.pipe(new seektable(function(data) {
	var output = fs.createWriteStream(FLAC_OUT, { flags: 'w' });
	substream(output, data, START_SECONDS, END_SECONDS, function(start, end) {
		var stream = fs.createReadStream(
			FLAC_IN,
			{
				start: start,
				end: end
			}
		);
		return stream;
	});
})).pipe(
	devnull() // Or this could go to somewhere useful.
);
```

---
_Source: https://npm.io/package/flac-substream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
