You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Release v0.3.1: Enhanced configuration validation and error handling
- Add comprehensive config parser validation with detailed error messages
- Improve encoder factory with better browser compatibility checks
- Enhance worker communication with structured message handling
- Add frame drop detection and recovery in encoder worker
- Improve stream encoding with robust error handling
- Add config-parser test suite for validation coverage
- Update dependencies and improve type definitions
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [0.3.1] - 2025-09-22
9
+
10
+
### 🎧 Added
11
+
- Expanded audio codec coverage to include FLAC, MP3, Vorbis, linear PCM, and μ-law/A-law, with capability probing via `AudioEncoder.isConfigSupported()` and worker fallbacks when a codec is unavailable.
12
+
13
+
### 🛠️ Improved
14
+
- The configuration parser now infers codec-specific defaults (bitrate, sample rate, channels) without forcing inappropriate values onto PCM or telephony codecs.
15
+
-`canEncode` and the MP4/WebM muxers share stricter compatibility checks so unsupported codec/container combinations are rejected before encoding begins.
16
+
- VideoFile sources read metadata up front, align the encoder resolution, and scale frames when necessary to avoid width/height mismatches.
17
+
- Worker creation prefers external worker scripts; the inline mock worker is now opt-in for development and tests only.
18
+
19
+
### 🐛 Fixed
20
+
- Preserved `video: false` and `audio: false` flags when merging options, restoring audio-only workflows.
21
+
- Delayed muxer construction until after codec fallbacks complete, ensuring muxers match the actual encoder configuration.
22
+
- MediaStream tracks are no longer stopped automatically during cleanup, leaving ownership with the caller.
23
+
24
+
### 🧪 Tests
25
+
- Extended coverage across async iterable safety, audio codec probing, worker initialization paths, and configuration merging edge cases.
A TypeScript library to encode video (H.264/AVC, VP9, VP8) and audio (AAC, Opus) using the WebCodecs API and mux them into MP4 or WebM containers with a simple.
8
+
A TypeScript library to encode video (H.264/AVC, HEVC, VP9, VP8, AV1) and audio (AAC, MP3, Opus, Vorbis, FLAC) using the WebCodecs API and mux them into MP4 or WebM containers with a simple, function-first API.
9
9
10
10
## Features
11
11
@@ -17,7 +17,7 @@ A TypeScript library to encode video (H.264/AVC, VP9, VP8) and audio (AAC, Opus)
17
17
-**🎨 Progressive Enhancement**: Start simple, add complexity as needed
18
18
-**📦 Optimized Bundle Size**: Tree-shakable with ES Modules and `sideEffects: false` for efficient bundling.
19
19
-**🛡️ Type Safety**: Full TypeScript support with comprehensive types
20
-
-**🎵 Audio Support**: AACand Opus encoding with automatic configuration
20
+
-**🎵 Audio Support**: Automatic AAC↔MP3 fallback for MP4 and Opus/Vorbis/FLAC support for WebM
21
21
-**🎤 Audio-Only Encoding**: Support for `video: false` option (v0.2.2)
22
22
-**📹 VideoFile Audio**: Extract and encode audio from video files (v0.2.2)
23
23
-**⚡ Performance Optimized**: Transferable objects for faster data transfer (v0.2.2)
@@ -32,15 +32,59 @@ yarn add webcodecs-encoder
32
32
33
33
### Worker Setup
34
34
35
-
A dedicated Web Worker (**webcodecs-worker.js**) must be reachable at the site root (default: `/webcodecs-worker.js`). The library falls back to an inline worker only in test environments; in production, the external file **is mandatory for security reasons**.
35
+
The encoder runs inside a dedicated Web Worker (`/webcodecs-worker.js`). Ship that file with your app and ensure it is publicly reachable at the site root.
36
36
37
-
You need to copy the worker file from `node_modules` to your public directory.
37
+
By default the library:
38
+
39
+
-**Prefers the external worker** in browsers and production builds.
40
+
-**Falls back to an inline mock** only when running under known test runners (Vitest, Jest, `NODE_ENV=test`) or when you explicitly opt in.
41
+
-**Never uses the inline mock in production** unless you override the safety check.
42
+
43
+
Inline worker controls:
44
+
45
+
| Flag | Effect |
46
+
| --- | --- |
47
+
|`WEBCODECS_USE_INLINE_WORKER=true` or `window.__WEBCODECS_USE_INLINE_WORKER__ = true`| Force the inline mock (useful for Storybook, unit tests, etc.). |
48
+
|`WEBCODECS_DISABLE_INLINE_WORKER=true` or `window.__WEBCODECS_DISABLE_INLINE_WORKER__ = true`| Always require the external worker. |
49
+
|`WEBCODECS_ALLOW_INLINE_IN_PROD=true` or `window.__WEBCODECS_ALLOW_INLINE_IN_PROD__ = true`| Explicitly permit the inline mock on production builds (not recommended). |
50
+
51
+
> ⚠️ The inline worker is a **test stub** that returns placeholder bytes. Use it only for wiring/UI development. Real MP4/WebM output requires the external worker bundle.
52
+
53
+
Copy the worker file from `node_modules` into your public assets directory during build/deploy:
38
54
39
55
```bash
40
56
# Example for a Next.js/Vite project with a 'public' directory
// After: Stop MediaStream tracks or break out of the loop
627
+
const stopRecording = () => {
628
+
stream.getTracks().forEach(track=>track.stop());
629
+
};
630
+
631
+
setTimeout(stopRecording, 5000);
579
632
```
580
633
634
+
> The current implementation does not accept an `AbortSignal`. To cancel `encode` / `encodeStream`, stop the MediaStream tracks or end the async generator manually.
635
+
581
636
See [`examples/realtime-mediastream.ts`](examples/realtime-mediastream.ts) for complete examples.
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "webcodecs-encoder",
3
-
"version": "0.3.0",
3
+
"version": "0.3.1",
4
4
"description": "A TypeScript library for browser environments to encode video (H.264/AVC, VP9, VP8) and audio (AAC, Opus) using the WebCodecs API and mux them into MP4 or WebM containers with real-time streaming support. New function-first API design.",
0 commit comments