Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4ef1d6f
Author: Amish Shah <amish@shah.gg>
Date:   Mon Feb 27 15:56:49 2023 +0000

    chore(Release): v1.3.5

commit 84eb054
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Feb 27 15:55:06 2023 +0000

    build(deps): bump json5 from 2.2.1 to 2.2.3 (amishshah#112)

    Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3.
    - [Release notes](https://github.com/json5/json5/releases)
    - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
    - [Commits](json5/json5@v2.2.1...v2.2.3)

    ---
    updated-dependencies:
    - dependency-name: json5
      dependency-type: indirect
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 02628fe
Author: dzlandis <49926644+dzlandis@users.noreply.github.com>
Date:   Mon Feb 27 07:52:00 2023 -0800

    fix(Decoder): add check of chunk length (amishshah#110)

commit 37b3d65
Author: Chase Crayne <chawork1234@gmail.com>
Date:   Mon Feb 27 09:51:26 2023 -0600

    Correct @djs/opus dependency version restrictions (amishshah#113)

    In [node-semver](https://github.com/npm/node-semver#caret-ranges-123-025-004), the caret "Allows changes that do not modify the left-most non-zero element in the [major, minor, patch] tuple". That is, `0.x` versions are considered breaking, and thus not valid. I'm fairly sure this was just an oversight, as all `0.x` versions of djs/opus to date have been non-breaking.

    This change just modifies the dependency version to allow all `0.x` versions, breaking at `1.0.0`

commit fc562b1
Author: Amish Shah <amishshah.2k@gmail.com>
Date:   Sat Jul 9 12:01:26 2022 +0100

    chore: run docs action on main branch

commit fcd7ea6
Author: Amish Shah <amishshah.2k@gmail.com>
Date:   Sat Jul 9 11:58:14 2022 +0100

    chore(Release): v1.3.4 (amishshah#106)

    * Update packages

    * Fix audit issues, replace docma, update tests

    * Update node in CI

    * Update README

    * Version bump to 1.3.4
  • Loading branch information
skick1234 committed Jul 28, 2023
1 parent 3a20eda commit 4ff4919
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[![Logo](https://hydrabolt.me/assets/prism-media-logo.svg)](https://amishshah.github.io/prism-media/)

<div align="center">

[![Build Status](https://travis-ci.org/amishshah/prism-media.svg?branch=master)](https://travis-ci.org/hydrabolt/prism-media)
[![dependencies](https://david-dm.org/amishshah/prism-media/status.svg)](https://david-dm.org/hydrabolt/prism-media)
[![npm](https://img.shields.io/npm/dt/prism-media.svg)](https://www.npmjs.com/package/prism-media)
[![Patreon](https://img.shields.io/badge/donate-patreon-F96854.svg)](https://www.patreon.com/discordjs)

</div>

## What is it?

An easy-to-use stream-based toolkit that you can use for media processing. All the features provided have predictable
abstractions and join together coherently.

```js
// This example will demux and decode an Opus-containing OGG file, and then write it to a file.
const prism = require('prism-media');
const fs = require('fs');

fs.createReadStream('./audio.ogg')
.pipe(new prism.opus.OggDemuxer())
.pipe(new prism.opus.Decoder({ rate: 48000, channels: 2, frameSize: 960 }))
.pipe(fs.createWriteStream('./audio.pcm'));
```

The example above can work with either a native or pure JavaScript Opus decoder - you don't need to worry about changing
your code for whichever you install.

- FFmpeg support (either through npm modules or a normal installation)
- Opus support (native or pure JavaScript)
- Demuxing for WebM/OGG files (no modules required!)
- Volume Altering (no modules required!)

## Dependencies

The following dependencies are all optional, and you should only install one from each category (the first listed in
each category is preferred)

- Opus
- [`@discordjs/opus`](https://github.com/discordjs/opus)
- [`node-opus`](https://github.com/Rantanen/node-opus)
- [`opusscript`](https://github.com/abalabahaha/opusscript)
- FFmpeg
- [`ffmpeg-static`](http://npmjs.com/ffmpeg-static)
- `ffmpeg` from a [normal installation](https://www.ffmpeg.org/download.html)

## Useful Links

- [Documentation](https://amishshah.github.io/prism-media)
- [Examples](https://github.com/amishshah/prism-media/tree/master/examples)
- [Patreon](https://www.patreon.com/discordjs)

## License

> Copyright 2019 - 2022 Amish Shah
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> See the License for the specific language governing permissions and
> limitations under the License.
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "prism-media",
"version": "1.3.3",
"version": "1.3.5",
"description": "Easy-to-use stream-based media transcoding",
"main": "src/index.js",
"types": "typings/index.d.ts",
"scripts": {
"lint": "eslint src",
"test": "npm run lint && jest && npm run docs",
"docs": "docma"
"docs": "jsdoc src/** -d docs -R README.md"
},
"repository": {
"type": "git",
Expand All @@ -29,16 +29,18 @@
},
"homepage": "https://github.com/hydrabolt/prism-media#readme",
"devDependencies": {
"docma": "^3.2.2",
"eslint": "^7.32.0",
"jest": "^27.0.6"
"eslint": "^8.19.0",
"jest": "^28.1.2",
"jsdoc": "^4.0.2"
},
"jest": {
"testURL": "http://localhost/"
"testEnvironmentOptions": {
"url": "http://localhost/"
}
},
"peerDependencies": {
"@discordjs/opus": "*",
"ffmpeg-static": "^4.2.7 || ^3.0.0 || ^2.4.0",
"@discordjs/opus": ">=0.8.0 <1.0.0",
"ffmpeg-static": "^5.0.2 || ^4.2.7 || ^3.0.0 || ^2.4.0",
"node-opus": "^0.3.3",
"opusscript": "^0.0.8"
},
Expand Down
4 changes: 2 additions & 2 deletions src/opus/Opus.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Encoder extends OpusStream {
class Decoder extends OpusStream {
_transform(chunk, encoding, done) {
const signature = chunk.slice(0, 8);
if (signature.equals(OPUS_HEAD)) {
if (chunk.length >= 8 && signature.equals(OPUS_HEAD)) {
this.emit('format', {
channels: this._options.channels,
sampleRate: this._options.rate,
Expand All @@ -196,7 +196,7 @@ class Decoder extends OpusStream {
});
return done();
}
if (signature.equals(OPUS_TAGS)) {
if (chunk.length >= 8 && signature.equals(OPUS_TAGS)) {
this.emit('tags', chunk);
return done();
}
Expand Down

0 comments on commit 4ff4919

Please sign in to comment.