@caprid/moq-mediabunny 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -29
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
# Optional file input: Mediabunny
|
|
1
|
+
# Optional file input: Mediabunny to LOC and MSF
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`@caprid/moq-media`
|
|
6
|
-
requires Mediabunny.
|
|
3
|
+
`@caprid/moq-mediabunny` turns encoded packets that [Mediabunny](https://mediabunny.dev/) demuxes from a file into LOC
|
|
4
|
+
frames. Install it alongside `@caprid/moq-media` and Mediabunny 1.58.1 or later. Neither `@caprid/moq-core`,
|
|
5
|
+
`@caprid/relay`, nor `@caprid/moq-media` needs Mediabunny.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Other codecs can still use the generic format package directly.
|
|
7
|
+
Mediabunny parses the file, and this adapter maps its encoded packets. The decoder config mappers in
|
|
8
|
+
`@caprid/moq-media` support length-prefixed AVC (H.264) with four-byte NAL lengths, and Opus. The adapter uses only
|
|
9
|
+
public Mediabunny APIs. It never rebuilds SPS or PPS, converts Annex B, decodes, or re-encodes media. For other codecs,
|
|
10
|
+
use `@caprid/moq-media` directly. For live capture, `@caprid/moq-media` also provides the
|
|
11
|
+
[direct WebCodecs publishing path](https://github.com/caprids/relay-sdks/blob/main/ts/examples/webcodecs/README.md).
|
|
14
12
|
|
|
15
13
|
```ts
|
|
16
14
|
import { packetToLocFrame } from '@caprid/moq-mediabunny';
|
|
@@ -21,7 +19,7 @@ const input = new Input({ source: new BlobSource(file), formats: [MP4] });
|
|
|
21
19
|
try {
|
|
22
20
|
const track = await input.getPrimaryVideoTrack();
|
|
23
21
|
const config = await track?.getDecoderConfig();
|
|
24
|
-
if (!track || !config) throw new Error('Missing video track
|
|
22
|
+
if (!track || !config) throw new Error('Missing video track or decoder config');
|
|
25
23
|
const video = videoTrackFromDecoderConfig(config);
|
|
26
24
|
const catalog = buildMsfCatalog({ namespace, video });
|
|
27
25
|
// Serve catalog with createCatalogService from @caprid/relay/media.
|
|
@@ -34,27 +32,28 @@ try {
|
|
|
34
32
|
}
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
See the [complete publishing function](
|
|
38
|
-
[usage instructions](
|
|
35
|
+
See the [complete publishing function](https://github.com/caprids/relay-sdks/blob/main/ts/examples/mediabunny/publish-video.ts) and its
|
|
36
|
+
[usage instructions](https://github.com/caprids/relay-sdks/blob/main/ts/examples/mediabunny/README.md) for demand, pacing, groups, and cleanup.
|
|
39
37
|
|
|
40
38
|
## Contract
|
|
41
39
|
|
|
42
|
-
The config mappers and `LocFrame` type belong to `@caprid/moq-media`. This
|
|
43
|
-
|
|
40
|
+
The config mappers and the `LocFrame` type belong to `@caprid/moq-media`. This package still re-exports
|
|
41
|
+
`videoTrackFromDecoderConfig`, `audioTrackFromDecoderConfig`, and `LocFrame` for compatibility. Import them from
|
|
42
|
+
`@caprid/moq-media` in new code.
|
|
44
43
|
|
|
45
|
-
See the [media package](
|
|
44
|
+
See the [media package](https://github.com/caprids/relay-sdks/blob/main/ts/packages/moq-media/README.md) for the AVC/Opus config-mapper contract.
|
|
46
45
|
|
|
47
|
-
- `packetToLocFrame(packet, options?)` returns `{ payload, timestampUs, key, properties }`.
|
|
48
|
-
bytes
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
the
|
|
54
|
-
|
|
46
|
+
- `packetToLocFrame(packet, options?)` returns `{ payload, timestampUs, key, properties }`. The payload borrows the
|
|
47
|
+
packet's bytes unchanged, so keep them stable until the write completes. A metadata-only packet throws. The timestamp
|
|
48
|
+
is Mediabunny's integer microsecond presentation timestamp. Keep packets in decode order, and do not sort B-frames by
|
|
49
|
+
presentation time.
|
|
50
|
+
- The options are `timescale`, `videoConfig`, `audioConfig`, and `timestampOffsetUs`. Configs go on key packets only.
|
|
51
|
+
The default timescale is 1,000,000. Declare the same timescale on the track. A file with negative timestamps needs an
|
|
52
|
+
explicit `timestampOffsetUs`, shared across the audio and video tracks. The resulting timestamp must be a nonnegative
|
|
53
|
+
safe integer.
|
|
55
54
|
|
|
56
|
-
For live browser encoding, use `chunkToLocFrame` and the config mappers from `@caprid/moq-media`
|
|
57
|
-
|
|
55
|
+
For live browser encoding, use `chunkToLocFrame` and the config mappers from `@caprid/moq-media` directly, with no
|
|
56
|
+
Mediabunny packet in between.
|
|
58
57
|
|
|
59
58
|
Public upstream APIs: [encoded packets](https://mediabunny.dev/api/EncodedPacket),
|
|
60
59
|
[reading files](https://mediabunny.dev/guide/reading-media-files),
|
|
@@ -63,5 +62,5 @@ Public upstream APIs: [encoded packets](https://mediabunny.dev/api/EncodedPacket
|
|
|
63
62
|
|
|
64
63
|
## Stability
|
|
65
64
|
|
|
66
|
-
Before 1.0, a minor version can break the API. This package releases together with `@caprid/relay`
|
|
67
|
-
|
|
65
|
+
Before 1.0, a minor version can break the API. This package releases together with `@caprid/relay` at the same version.
|
|
66
|
+
See the [changelog](https://github.com/caprids/relay-sdks/blob/main/ts/CHANGELOG.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caprid/moq-mediabunny",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Optional Mediabunny packet adapter for LOC and MSF",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@caprid/moq-media": "0.
|
|
24
|
+
"@caprid/moq-media": "0.2.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"mediabunny": "^1.58.1"
|