Comparing version 0.0.3 to 0.0.4
17
index.js
@@ -65,20 +65,13 @@ const binding = require('./js-binding'); | ||
const onClose = () => { | ||
try { | ||
const result = binding.probe(readBuffer); | ||
if (result != null) resolved = result; | ||
} catch { } | ||
finish(resolved || null); | ||
}; | ||
const onData = (buffer) => { | ||
readBuffer = Buffer.concat([readBuffer, buffer]); | ||
try { | ||
const result = binding.probe(readBuffer); | ||
if (result != null) resolved = result; | ||
if (result && ![ | ||
CodecType.MP3, | ||
CodecType.MP1, | ||
CodecType.MP2, | ||
].some(c => resolved.codec === c)) return finish(result); | ||
} catch { } | ||
if (readBuffer.length >= probeSize) { | ||
@@ -85,0 +78,0 @@ stream.off('data', onData); |
{ | ||
"name": "mediaplex", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -65,13 +65,13 @@ "types": "index.d.ts", | ||
"optionalDependencies": { | ||
"mediaplex-win32-x64-msvc": "0.0.3", | ||
"mediaplex-darwin-x64": "0.0.3", | ||
"mediaplex-linux-x64-gnu": "0.0.3", | ||
"mediaplex-darwin-arm64": "0.0.3", | ||
"mediaplex-android-arm64": "0.0.3", | ||
"mediaplex-win32-arm64-msvc": "0.0.3", | ||
"mediaplex-linux-arm-gnueabihf": "0.0.3", | ||
"mediaplex-freebsd-x64": "0.0.3", | ||
"mediaplex-win32-ia32-msvc": "0.0.3", | ||
"mediaplex-darwin-universal": "0.0.3" | ||
"mediaplex-win32-x64-msvc": "0.0.4", | ||
"mediaplex-darwin-x64": "0.0.4", | ||
"mediaplex-linux-x64-gnu": "0.0.4", | ||
"mediaplex-darwin-arm64": "0.0.4", | ||
"mediaplex-android-arm64": "0.0.4", | ||
"mediaplex-win32-arm64-msvc": "0.0.4", | ||
"mediaplex-linux-arm-gnueabihf": "0.0.4", | ||
"mediaplex-freebsd-x64": "0.0.4", | ||
"mediaplex-win32-ia32-msvc": "0.0.4", | ||
"mediaplex-darwin-universal": "0.0.4" | ||
} | ||
} |
@@ -34,3 +34,3 @@ # Mediaplex | ||
const stream = createReadStream('./media.mp3'); | ||
const { result } = mediaplex.probeStream(stream); | ||
const { result } = await mediaplex.probeStream(stream); | ||
@@ -62,3 +62,12 @@ console.log(result); | ||
This will output an object containing information about the media file, including the number of channels, sample rate, codec, duration, and metadata. | ||
The default probe size is `10MB`, but you can adjust this as needed by passing the second argument to `probeStream`: | ||
```js | ||
// probe only 1024 bytes | ||
const { result } = await mediaplex.probeStream(stream, 1024); | ||
// probe 5 MB | ||
const { result } = await mediaplex.probeStream(stream, 5 * 1024 * 1024); | ||
``` | ||
## Opus Encoder | ||
@@ -79,3 +88,3 @@ | ||
You can use `OpusEncoder` to encode pcm data to opus and decode opus data to pcm format. | ||
You can use `OpusEncoder` to encode pcm data to opus and decode opus data to pcm format. Stream interface is provided by [@discord-player/opus](https://npm.im/@discord-player/opus) package. | ||
@@ -128,2 +137,2 @@ #### Opus Benchmarks | ||
These benchmarks compare the performance of Mediaplex's Opus encoder/decoder to other popular Opus libraries. | ||
These benchmarks compare the performance of Mediaplex's Opus encoder/decoder to other popular Opus libraries. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4318058
135
1494