@stream-io/video-filters-web 0.1.2 → 0.1.3
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/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +12 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +12 -5
- package/dist/index.es.js.map +1 -1
- package/dist/src/createRenderer.d.ts +1 -1
- package/dist/src/tflite.d.ts +0 -1
- package/package.json +3 -3
- package/src/createRenderer.ts +8 -3
- package/src/webgl2/webgl2Pipeline.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
### [0.1.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-filters-web-0.1.2...@stream-io/video-filters-web-0.1.3) (2024-07-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* refactor background filters ([#1415](https://github.com/GetStream/stream-video-js/issues/1415)) ([deb6da2](https://github.com/GetStream/stream-video-js/commit/deb6da238f541c733451e84b198434671da8dceb))
|
|
11
|
+
|
|
5
12
|
### [0.1.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-filters-web-0.1.1...@stream-io/video-filters-web-0.1.2) (2024-06-12)
|
|
6
13
|
|
|
7
14
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -675,6 +675,8 @@ function buildWebGL2Pipeline(videoSource, backgroundImage, blurLevel, background
|
|
|
675
675
|
const gl = canvas.getContext('webgl2');
|
|
676
676
|
if (!gl)
|
|
677
677
|
throw new Error('WebGL2 is not supported');
|
|
678
|
+
if (gl.isContextLost())
|
|
679
|
+
throw new Error('WebGL2 context was lost');
|
|
678
680
|
const { width: frameWidth, height: frameHeight } = videoSource;
|
|
679
681
|
const { width: segmentationWidth, height: segmentationHeight } = segmentationConfig;
|
|
680
682
|
const vertexShaderSource = glsl `#version 300 es
|
|
@@ -777,16 +779,21 @@ const getSegmentationParams = (level) => {
|
|
|
777
779
|
return { width: 160, height: 96 };
|
|
778
780
|
};
|
|
779
781
|
|
|
780
|
-
function createRenderer(tflite, videoSource, targetCanvas, options) {
|
|
782
|
+
function createRenderer(tflite, videoSource, targetCanvas, options, onError) {
|
|
781
783
|
const { backgroundFilter, backgroundImage, backgroundBlurLevel, segmentationLevel = exports.SegmentationLevel.HIGH, fps = 30, } = options;
|
|
782
784
|
if (backgroundFilter === 'image' && !backgroundImage) {
|
|
783
785
|
throw new Error(`backgroundImage element is required when backgroundFilter is image`);
|
|
784
786
|
}
|
|
785
787
|
const pipeline = buildWebGL2Pipeline(videoSource, backgroundImage, backgroundBlurLevel, backgroundFilter, targetCanvas, tflite, getSegmentationParams(segmentationLevel));
|
|
786
788
|
const id = setInterval(() => {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
789
|
+
try {
|
|
790
|
+
pipeline.render();
|
|
791
|
+
if (backgroundFilter === 'image') {
|
|
792
|
+
pipeline.updatePostProcessingConfig();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
catch (error) {
|
|
796
|
+
onError?.(error);
|
|
790
797
|
}
|
|
791
798
|
}, 1000 / (fps <= 0 ? 30 : fps));
|
|
792
799
|
return {
|
|
@@ -1531,7 +1538,7 @@ const createTFLiteSIMDModule = (__Module) => {
|
|
|
1531
1538
|
return __Module.ready;
|
|
1532
1539
|
};
|
|
1533
1540
|
|
|
1534
|
-
const version = "0.1.
|
|
1541
|
+
const version = "0.1.3" ;
|
|
1535
1542
|
const packageName = "@stream-io/video-filters-web" ;
|
|
1536
1543
|
|
|
1537
1544
|
// @ts-expect-error - module is not declared
|