mirror of
https://github.com/darksaid98/mediaplex.git
synced 2026-12-03 14:38:55 +00:00
0.0.2
This commit is contained in:
1 parent
9077961fe5
commit
f4e69a62e4
1 file changed
+30
-17
@@ -1,35 +1,41 @@
|
|||||||
# Mediaplex
|
# Mediaplex
|
||||||
|
|
||||||
Tiny media transcoding utility for node.
|
Mediaplex is a tiny media transcoding utility for Node.js that allows you to probe media files for metadata and use an Opus encoder/decoder.
|
||||||
|
|
||||||
> 🏗️ This package is a work in progress.
|
> 🏗️ Please note that this package is a work in progress.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
To install Mediaplex, run the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ npm install --save mediaplex
|
$ npm install --save mediaplex
|
||||||
```
|
```
|
||||||
|
|
||||||
# Current Features
|
# Current Features
|
||||||
|
|
||||||
- probe media files for metadata
|
Mediaplex currently supports the following features:
|
||||||
|
|
||||||
|
- Probe media files for metadata
|
||||||
- Opus encoder/decoder
|
- Opus encoder/decoder
|
||||||
|
|
||||||
More features coming soon.
|
More features are coming soon.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
## Probe metadata
|
## Probe metadata
|
||||||
|
|
||||||
|
You can use Mediaplex to probe media files for metadata. Here's an example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const mediaplex = require('mediaplex');
|
const mediaplex = require('mediaplex');
|
||||||
|
|
||||||
const stream = createReadStream('./media.mp3');
|
const stream = createReadStream('./media.mp3');
|
||||||
const result = mediaplex.probe(stream);
|
const { result } = mediaplex.probeStream(stream);
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
/*
|
/* Sample Output */
|
||||||
{
|
{
|
||||||
channels: 2,
|
channels: 2,
|
||||||
sampleRate: 44100,
|
sampleRate: 44100,
|
||||||
@@ -49,15 +55,18 @@ console.log(result);
|
|||||||
{ name: 'TPUB', value: '...' }
|
{ name: 'TPUB', value: '...' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This will output an object containing information about the media file, including the number of channels, sample rate, codec, duration, and metadata.
|
||||||
|
|
||||||
## Opus Encoder
|
## Opus Encoder
|
||||||
|
|
||||||
|
Mediaplex also includes an Opus encoder/decoder. Here's an example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { OpusEncoder, getOpusVersion } = require('mediaplex');
|
const { OpusEncoder, getOpusVersion } = require('mediaplex');
|
||||||
|
|
||||||
console.log(getOpusVersion()); // libopus ...
|
console.log(getOpusVersion()); // libopus xxx
|
||||||
|
|
||||||
const encoder = new OpusEncoder(48000, 2);
|
const encoder = new OpusEncoder(48000, 2);
|
||||||
|
|
||||||
@@ -65,9 +74,11 @@ const encoded = encoder.encode(buffer);
|
|||||||
const decoded = encoder.decode(encoded);
|
const decoded = encoder.decode(encoded);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can use `OpusEncoder` to encode pcm data to opus and decode opus data to pcm format.
|
||||||
|
|
||||||
#### Opus Benchmarks
|
#### Opus Benchmarks
|
||||||
|
|
||||||
Tested on windows 11 i7-8700 3.2GHz
|
Mediaplex includes benchmarks for the Opus encoder/decoder. Here are the results of the benchmarks on a Windows 11 machine with an i7-8700 3.2GHz processor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
$ yarn benchmark
|
$ yarn benchmark
|
||||||
@@ -76,16 +87,16 @@ Running "OpusEncoder Benchmark" suite...
|
|||||||
Progress: 100%
|
Progress: 100%
|
||||||
|
|
||||||
mediaplex:
|
mediaplex:
|
||||||
3 305 ops/s, ±0.15% | 21.18% slower
|
3 502 ops/s, ±0.84% | 16.04% slower
|
||||||
|
|
||||||
@discordjs/opus:
|
@discordjs/opus:
|
||||||
3 174 ops/s, ±0.09% | 24.3% slower
|
3 185 ops/s, ±0.17% | 23.64% slower
|
||||||
|
|
||||||
opusscript:
|
opusscript:
|
||||||
4 193 ops/s, ±0.16% | fastest
|
4 171 ops/s, ±0.34% | fastest
|
||||||
|
|
||||||
opusscript (no wasm):
|
opusscript (no wasm):
|
||||||
260 ops/s, ±0.55% | slowest, 93.8% slower
|
261 ops/s, ±0.85% | slowest, 93.74% slower
|
||||||
|
|
||||||
Finished 4 cases!
|
Finished 4 cases!
|
||||||
Fastest: opusscript
|
Fastest: opusscript
|
||||||
@@ -95,18 +106,20 @@ Running "OpusDecoder Benchmark" suite...
|
|||||||
Progress: 100%
|
Progress: 100%
|
||||||
|
|
||||||
mediaplex:
|
mediaplex:
|
||||||
11 441 ops/s, ±0.99% | 3.21% slower
|
9 838 ops/s, ±0.38% | 16.96% slower
|
||||||
|
|
||||||
@discordjs/opus:
|
@discordjs/opus:
|
||||||
11 821 ops/s, ±0.55% | fastest
|
11 848 ops/s, ±0.40% | fastest
|
||||||
|
|
||||||
opusscript:
|
opusscript:
|
||||||
6 095 ops/s, ±0.27% | 48.44% slower
|
6 100 ops/s, ±0.23% | 48.51% slower
|
||||||
|
|
||||||
opusscript (no wasm):
|
opusscript (no wasm):
|
||||||
2 584 ops/s, ±0.52% | slowest, 78.14% slower
|
2 589 ops/s, ±0.20% | slowest, 78.15% slower
|
||||||
|
|
||||||
Finished 4 cases!
|
Finished 4 cases!
|
||||||
Fastest: @discordjs/opus
|
Fastest: @discordjs/opus
|
||||||
Slowest: opusscript (no wasm)
|
Slowest: opusscript (no wasm)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
These benchmarks compare the performance of Mediaplex's Opus encoder/decoder to other popular Opus libraries.
|
||||||
Reference in new issue
Block a user