@caprid/moq-mediabunny 0.1.1 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +28 -29
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,16 +1,14 @@
1
- # Optional file input: Mediabunny → LOC/MSF
1
+ # Optional file input: Mediabunny to LOC and MSF
2
2
 
3
- Optional adapter for encoded packets demuxed by [Mediabunny](https://mediabunny.dev/). The unpublished
4
- workspace package is `@caprid/moq-mediabunny`; consumers install it alongside
5
- `@caprid/moq-media` and Mediabunny (tested with 1.58.1). Neither the core, Relay SDK, nor format package
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
- The initial adapter supports length-prefixed AVC/H.264 with four-byte NAL lengths and Opus.
9
- Mediabunny owns file parsing; this adapter maps its encoded packets. Standard WebCodecs decoder
10
- config mapping lives in `@caprid/moq-media`, which also provides the
11
- [direct browser publishing path](../../examples/webcodecs/README.md).
12
- It uses only public APIs and never rebuilds SPS/PPS, converts Annex B, decodes, or re-encodes media.
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/config');
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](../../examples/mediabunny/publish-video.ts) and its
38
- [usage instructions](../../examples/mediabunny/README.md) for demand, pacing, groups, and cleanup.
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 adapter retains their
43
- original exports for compatibility; new code should import them from the media package.
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](../moq-media/README.md) for the AVC/Opus config-mapper contract.
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 }`. Payload
48
- bytes are borrowed unchanged; keep them stable until the write completes. Metadata-only packets
49
- are rejected. Timestamps use Mediabunny's integer microsecond presentation timestamp, and input
50
- decode order must be preserved (do not sort B-frames by presentation time).
51
- - Options include `timescale`, `videoConfig`, `audioConfig`, and `timestampOffsetUs`. Configs are
52
- attached only to key packets. The default timescale is 1,000,000; declare the same timescale on
53
- the track. Negative file timestamps need an explicit offset shared across audio/video; the
54
- resulting timestamp must fit the format package's nonnegative safe-integer contract.
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
- directly. No conversion to a Mediabunny packet is needed.
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
- at the same version; see the [changelog](../../CHANGELOG.md).
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.1.1",
3
+ "version": "0.3.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.1.1"
24
+ "@caprid/moq-media": "0.3.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "mediabunny": "^1.58.1"