@meframe/core 0.0.49 → 0.1.1
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/dist/cache/CacheManager.d.ts +1 -1
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +2 -2
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/l1/AudioL1Cache.d.ts +1 -1
- package/dist/cache/l1/AudioL1Cache.d.ts.map +1 -1
- package/dist/cache/l1/AudioL1Cache.js +2 -2
- package/dist/cache/l1/AudioL1Cache.js.map +1 -1
- package/dist/controllers/PlaybackController.d.ts.map +1 -1
- package/dist/controllers/PlaybackController.js +1 -5
- package/dist/controllers/PlaybackController.js.map +1 -1
- package/dist/model/CompositionModel.d.ts.map +1 -1
- package/dist/model/CompositionModel.js +4 -5
- package/dist/model/CompositionModel.js.map +1 -1
- package/dist/model/RcFrame.d.ts +10 -6
- package/dist/model/RcFrame.d.ts.map +1 -1
- package/dist/model/RcFrame.js +7 -10
- package/dist/model/RcFrame.js.map +1 -1
- package/dist/model/types.d.ts +6 -0
- package/dist/model/types.d.ts.map +1 -1
- package/dist/model/types.js.map +1 -1
- package/dist/orchestrator/CompositionPlanner.d.ts +0 -1
- package/dist/orchestrator/CompositionPlanner.d.ts.map +1 -1
- package/dist/orchestrator/CompositionPlanner.js +4 -12
- package/dist/orchestrator/CompositionPlanner.js.map +1 -1
- package/dist/orchestrator/ExportScheduler.d.ts.map +1 -1
- package/dist/orchestrator/ExportScheduler.js +1 -0
- package/dist/orchestrator/ExportScheduler.js.map +1 -1
- package/dist/orchestrator/GlobalAudioSession.d.ts +1 -1
- package/dist/orchestrator/GlobalAudioSession.d.ts.map +1 -1
- package/dist/orchestrator/GlobalAudioSession.js +25 -2
- package/dist/orchestrator/GlobalAudioSession.js.map +1 -1
- package/dist/orchestrator/Orchestrator.d.ts.map +1 -1
- package/dist/orchestrator/Orchestrator.js +2 -7
- package/dist/orchestrator/Orchestrator.js.map +1 -1
- package/dist/stages/compose/LayerRenderer.d.ts +6 -1
- package/dist/stages/compose/LayerRenderer.d.ts.map +1 -1
- package/dist/stages/compose/LayerRenderer.js +98 -97
- package/dist/stages/compose/LayerRenderer.js.map +1 -1
- package/dist/stages/compose/VideoComposer.d.ts.map +1 -1
- package/dist/stages/compose/VideoComposer.js +13 -8
- package/dist/stages/compose/VideoComposer.js.map +1 -1
- package/dist/stages/compose/instructions.d.ts +6 -6
- package/dist/stages/compose/instructions.d.ts.map +1 -1
- package/dist/stages/compose/types.d.ts +7 -0
- package/dist/stages/compose/types.d.ts.map +1 -1
- package/dist/workers/stages/compose/{video-compose.worker.CsbBuccL.js → video-compose.worker.C8728Oi3.js} +117 -114
- package/dist/workers/stages/compose/video-compose.worker.C8728Oi3.js.map +1 -0
- package/dist/workers/worker-manifest.json +1 -1
- package/package.json +1 -1
- package/dist/workers/stages/compose/video-compose.worker.CsbBuccL.js.map +0 -1
|
@@ -795,7 +795,7 @@ class LayerRenderer {
|
|
|
795
795
|
/**
|
|
796
796
|
* Render a single layer with all its properties
|
|
797
797
|
*/
|
|
798
|
-
|
|
798
|
+
renderLayer(layer) {
|
|
799
799
|
if (!layer.visible || layer.opacity <= 0) return;
|
|
800
800
|
const needsStateManagement = layer.opacity !== 1 || layer.blendMode || layer.transform || layer.mask;
|
|
801
801
|
if (needsStateManagement) {
|
|
@@ -814,13 +814,13 @@ class LayerRenderer {
|
|
|
814
814
|
}
|
|
815
815
|
switch (layer.type) {
|
|
816
816
|
case "video":
|
|
817
|
-
|
|
817
|
+
this.renderVideoLayer(layer);
|
|
818
818
|
break;
|
|
819
819
|
case "image":
|
|
820
|
-
|
|
820
|
+
this.renderImageLayer(layer);
|
|
821
821
|
break;
|
|
822
822
|
case "text":
|
|
823
|
-
|
|
823
|
+
this.renderTextLayer(layer);
|
|
824
824
|
break;
|
|
825
825
|
}
|
|
826
826
|
if (layer.mask) {
|
|
@@ -843,41 +843,46 @@ class LayerRenderer {
|
|
|
843
843
|
const parsed = parseFloat(strValue);
|
|
844
844
|
return isNaN(parsed) ? void 0 : parsed;
|
|
845
845
|
}
|
|
846
|
+
/**
|
|
847
|
+
* Calculate dimensions from renderConfig
|
|
848
|
+
* Returns dimensions maintaining aspect ratio when only one dimension is specified
|
|
849
|
+
*/
|
|
850
|
+
calculateDimensionsFromConfig(sourceWidth, sourceHeight, renderConfig) {
|
|
851
|
+
if (!renderConfig) {
|
|
852
|
+
return { width: sourceWidth, height: sourceHeight };
|
|
853
|
+
}
|
|
854
|
+
const width = this.parseDimension(renderConfig.width, this.width);
|
|
855
|
+
const height = this.parseDimension(renderConfig.height, this.height);
|
|
856
|
+
if (width && height) {
|
|
857
|
+
return { width, height };
|
|
858
|
+
} else if (width) {
|
|
859
|
+
return {
|
|
860
|
+
width,
|
|
861
|
+
height: Math.round(sourceHeight / sourceWidth * width)
|
|
862
|
+
};
|
|
863
|
+
} else if (height) {
|
|
864
|
+
return {
|
|
865
|
+
width: Math.round(sourceWidth / sourceHeight * height),
|
|
866
|
+
height
|
|
867
|
+
};
|
|
868
|
+
} else {
|
|
869
|
+
return { width: sourceWidth, height: sourceHeight };
|
|
870
|
+
}
|
|
871
|
+
}
|
|
846
872
|
getLayerDimensions(layer) {
|
|
847
873
|
if (layer.type === "image") {
|
|
848
874
|
const imageLayer = layer;
|
|
849
875
|
if (imageLayer.source) {
|
|
850
876
|
const imgWidth = imageLayer.source.width;
|
|
851
877
|
const imgHeight = imageLayer.source.height;
|
|
852
|
-
|
|
853
|
-
if (isAttachment) {
|
|
854
|
-
const targetWidthRaw = imageLayer.targetWidth;
|
|
855
|
-
const targetHeightRaw = imageLayer.targetHeight;
|
|
856
|
-
const targetWidth = this.parseDimension(targetWidthRaw, this.width);
|
|
857
|
-
const targetHeight = this.parseDimension(targetHeightRaw, this.height);
|
|
858
|
-
if (targetWidth && targetHeight) {
|
|
859
|
-
return { width: targetWidth, height: targetHeight };
|
|
860
|
-
} else if (targetWidth) {
|
|
861
|
-
return {
|
|
862
|
-
width: targetWidth,
|
|
863
|
-
height: imgHeight / imgWidth * targetWidth
|
|
864
|
-
};
|
|
865
|
-
} else if (targetHeight) {
|
|
866
|
-
return {
|
|
867
|
-
width: imgWidth / imgHeight * targetHeight,
|
|
868
|
-
height: targetHeight
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return { width: imgWidth, height: imgHeight };
|
|
878
|
+
return this.calculateDimensionsFromConfig(imgWidth, imgHeight, imageLayer.renderConfig);
|
|
873
879
|
}
|
|
874
880
|
} else if (layer.type === "video") {
|
|
875
881
|
const videoLayer = layer;
|
|
876
882
|
const videoFrame = videoLayer.videoFrame;
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
};
|
|
883
|
+
const videoWidth = videoFrame.displayWidth || videoFrame.codedWidth;
|
|
884
|
+
const videoHeight = videoFrame.displayHeight || videoFrame.codedHeight;
|
|
885
|
+
return this.calculateDimensionsFromConfig(videoWidth, videoHeight, videoLayer.renderConfig);
|
|
881
886
|
}
|
|
882
887
|
return { width: this.width, height: this.height };
|
|
883
888
|
}
|
|
@@ -921,12 +926,28 @@ class LayerRenderer {
|
|
|
921
926
|
}
|
|
922
927
|
this.ctx.translate(-centerX, -centerY);
|
|
923
928
|
}
|
|
924
|
-
|
|
925
|
-
const { videoFrame, crop } = layer;
|
|
929
|
+
renderVideoLayer(layer) {
|
|
930
|
+
const { videoFrame, crop, renderConfig } = layer;
|
|
926
931
|
const videoWidth = videoFrame.displayWidth || videoFrame.codedWidth;
|
|
927
932
|
const videoHeight = videoFrame.displayHeight || videoFrame.codedHeight;
|
|
928
|
-
|
|
929
|
-
|
|
933
|
+
let renderX;
|
|
934
|
+
let renderY;
|
|
935
|
+
let renderWidth;
|
|
936
|
+
let renderHeight;
|
|
937
|
+
if (renderConfig) {
|
|
938
|
+
const dimensions = this.calculateDimensionsFromConfig(videoWidth, videoHeight, renderConfig);
|
|
939
|
+
renderWidth = dimensions.width;
|
|
940
|
+
renderHeight = dimensions.height;
|
|
941
|
+
renderX = Math.round((this.width - renderWidth) / 2);
|
|
942
|
+
renderY = Math.round((this.height - renderHeight) / 2);
|
|
943
|
+
} else {
|
|
944
|
+
const naturalScale = this.height / videoHeight;
|
|
945
|
+
const dimensions = this.calculateRenderDimensions(videoWidth, videoHeight, naturalScale);
|
|
946
|
+
renderX = dimensions.x;
|
|
947
|
+
renderY = dimensions.y;
|
|
948
|
+
renderWidth = dimensions.width;
|
|
949
|
+
renderHeight = dimensions.height;
|
|
950
|
+
}
|
|
930
951
|
if (crop) {
|
|
931
952
|
this.ctx.drawImage(
|
|
932
953
|
videoFrame,
|
|
@@ -934,24 +955,17 @@ class LayerRenderer {
|
|
|
934
955
|
crop.y,
|
|
935
956
|
crop.width,
|
|
936
957
|
crop.height,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
958
|
+
renderX,
|
|
959
|
+
renderY,
|
|
960
|
+
renderWidth,
|
|
961
|
+
renderHeight
|
|
941
962
|
);
|
|
942
963
|
} else {
|
|
943
|
-
this.ctx.drawImage(
|
|
944
|
-
videoFrame,
|
|
945
|
-
dimensions.x,
|
|
946
|
-
dimensions.y,
|
|
947
|
-
dimensions.width,
|
|
948
|
-
dimensions.height
|
|
949
|
-
);
|
|
964
|
+
this.ctx.drawImage(videoFrame, renderX, renderY, renderWidth, renderHeight);
|
|
950
965
|
}
|
|
951
|
-
videoFrame.close();
|
|
952
966
|
}
|
|
953
|
-
|
|
954
|
-
const { source, crop } = layer;
|
|
967
|
+
renderImageLayer(layer) {
|
|
968
|
+
const { source, crop, renderConfig } = layer;
|
|
955
969
|
if (source instanceof ImageData) {
|
|
956
970
|
if (crop) {
|
|
957
971
|
const tempCanvas = new OffscreenCanvas(crop.width, crop.height);
|
|
@@ -961,59 +975,46 @@ class LayerRenderer {
|
|
|
961
975
|
} else {
|
|
962
976
|
this.ctx.putImageData(source, 0, 0);
|
|
963
977
|
}
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (!source) return;
|
|
981
|
+
const imgWidth = source.width;
|
|
982
|
+
const imgHeight = source.height;
|
|
983
|
+
let renderX;
|
|
984
|
+
let renderY;
|
|
985
|
+
let renderWidth;
|
|
986
|
+
let renderHeight;
|
|
987
|
+
if (renderConfig) {
|
|
988
|
+
const dimensions = this.calculateDimensionsFromConfig(imgWidth, imgHeight, renderConfig);
|
|
989
|
+
renderWidth = dimensions.width;
|
|
990
|
+
renderHeight = dimensions.height;
|
|
991
|
+
renderX = 0;
|
|
992
|
+
renderY = 0;
|
|
964
993
|
} else {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
renderWidth = imgWidth / imgHeight * targetHeight;
|
|
987
|
-
} else {
|
|
988
|
-
renderWidth = imgWidth;
|
|
989
|
-
renderHeight = imgHeight;
|
|
990
|
-
}
|
|
991
|
-
} else {
|
|
992
|
-
const naturalScale = this.width / imgWidth;
|
|
993
|
-
const dimensions = this.calculateRenderDimensions(imgWidth, imgHeight, naturalScale);
|
|
994
|
-
renderWidth = dimensions.width;
|
|
995
|
-
renderHeight = dimensions.height;
|
|
996
|
-
}
|
|
997
|
-
const renderX = isAttachment ? 0 : Math.round((this.width - renderWidth) / 2);
|
|
998
|
-
const renderY = isAttachment ? 0 : Math.round((this.height - renderHeight) / 2);
|
|
999
|
-
if (crop) {
|
|
1000
|
-
this.ctx.drawImage(
|
|
1001
|
-
source,
|
|
1002
|
-
crop.x,
|
|
1003
|
-
crop.y,
|
|
1004
|
-
crop.width,
|
|
1005
|
-
crop.height,
|
|
1006
|
-
renderX,
|
|
1007
|
-
renderY,
|
|
1008
|
-
renderWidth,
|
|
1009
|
-
renderHeight
|
|
1010
|
-
);
|
|
1011
|
-
} else {
|
|
1012
|
-
this.ctx.drawImage(source, renderX, renderY, renderWidth, renderHeight);
|
|
1013
|
-
}
|
|
994
|
+
const naturalScale = this.width / imgWidth;
|
|
995
|
+
const dimensions = this.calculateRenderDimensions(imgWidth, imgHeight, naturalScale);
|
|
996
|
+
renderWidth = dimensions.width;
|
|
997
|
+
renderHeight = dimensions.height;
|
|
998
|
+
renderX = Math.round((this.width - renderWidth) / 2);
|
|
999
|
+
renderY = Math.round((this.height - renderHeight) / 2);
|
|
1000
|
+
}
|
|
1001
|
+
if (crop) {
|
|
1002
|
+
this.ctx.drawImage(
|
|
1003
|
+
source,
|
|
1004
|
+
crop.x,
|
|
1005
|
+
crop.y,
|
|
1006
|
+
crop.width,
|
|
1007
|
+
crop.height,
|
|
1008
|
+
renderX,
|
|
1009
|
+
renderY,
|
|
1010
|
+
renderWidth,
|
|
1011
|
+
renderHeight
|
|
1012
|
+
);
|
|
1013
|
+
} else {
|
|
1014
|
+
this.ctx.drawImage(source, renderX, renderY, renderWidth, renderHeight);
|
|
1014
1015
|
}
|
|
1015
1016
|
}
|
|
1016
|
-
|
|
1017
|
+
renderTextLayer(layer) {
|
|
1017
1018
|
const animationType = layer.animation?.type;
|
|
1018
1019
|
const hasWordTimings = layer.wordTimings && layer.wordTimings.length > 0;
|
|
1019
1020
|
const needsWordTimings = ["wordByWord", "characterKTV", "wordByWordFancy"].includes(
|
|
@@ -1479,9 +1480,12 @@ class FilterProcessor {
|
|
|
1479
1480
|
}
|
|
1480
1481
|
const closeLayerFrame = (layer) => {
|
|
1481
1482
|
if (layer.type === "video") {
|
|
1482
|
-
const
|
|
1483
|
-
if (
|
|
1484
|
-
vf.
|
|
1483
|
+
const videoLayer = layer;
|
|
1484
|
+
if (!videoLayer.rcFrame) {
|
|
1485
|
+
const vf = videoLayer.videoFrame;
|
|
1486
|
+
if (vf?.close) {
|
|
1487
|
+
vf.close();
|
|
1488
|
+
}
|
|
1485
1489
|
}
|
|
1486
1490
|
}
|
|
1487
1491
|
};
|
|
@@ -1603,14 +1607,15 @@ class VideoComposer {
|
|
|
1603
1607
|
continue;
|
|
1604
1608
|
}
|
|
1605
1609
|
try {
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1610
|
+
const videoLayer = layer;
|
|
1611
|
+
if (videoLayer.rcFrame) {
|
|
1612
|
+
videoLayer.rcFrame.use((frame2) => {
|
|
1613
|
+
videoLayer.videoFrame = frame2;
|
|
1609
1614
|
if (layer.filters && layer.filters.length > 0) {
|
|
1610
1615
|
this.ctx.save();
|
|
1611
1616
|
this.filterProcessor.applyFilters(this.ctx, layer.filters);
|
|
1612
1617
|
}
|
|
1613
|
-
|
|
1618
|
+
this.layerRenderer.renderLayer(layer);
|
|
1614
1619
|
if (layer.filters && layer.filters.length > 0) {
|
|
1615
1620
|
this.ctx.restore();
|
|
1616
1621
|
}
|
|
@@ -1620,13 +1625,14 @@ class VideoComposer {
|
|
|
1620
1625
|
this.ctx.save();
|
|
1621
1626
|
this.filterProcessor.applyFilters(this.ctx, layer.filters);
|
|
1622
1627
|
}
|
|
1623
|
-
|
|
1628
|
+
this.layerRenderer.renderLayer(layer);
|
|
1624
1629
|
if (layer.filters && layer.filters.length > 0) {
|
|
1625
1630
|
this.ctx.restore();
|
|
1626
1631
|
}
|
|
1627
1632
|
}
|
|
1628
1633
|
} catch (error) {
|
|
1629
1634
|
console.error("[VideoComposer] composeFrame error: ", error);
|
|
1635
|
+
} finally {
|
|
1630
1636
|
closeLayerFrame(layer);
|
|
1631
1637
|
}
|
|
1632
1638
|
}
|
|
@@ -2022,10 +2028,12 @@ function materializeLayer(layer, frame, imageMap, globalTimeUs) {
|
|
|
2022
2028
|
opacity: layer.opacity ?? 1
|
|
2023
2029
|
};
|
|
2024
2030
|
if (layer.type === "video") {
|
|
2031
|
+
const payload = layer.payload;
|
|
2025
2032
|
return {
|
|
2026
2033
|
...baseLayer,
|
|
2027
2034
|
type: "video",
|
|
2028
|
-
videoFrame: frame
|
|
2035
|
+
videoFrame: frame,
|
|
2036
|
+
renderConfig: payload.renderConfig
|
|
2029
2037
|
};
|
|
2030
2038
|
}
|
|
2031
2039
|
if (layer.type === "text") {
|
|
@@ -2049,14 +2057,9 @@ function materializeLayer(layer, frame, imageMap, globalTimeUs) {
|
|
|
2049
2057
|
...baseLayer,
|
|
2050
2058
|
type: "image",
|
|
2051
2059
|
source,
|
|
2052
|
-
attachmentId: payload.attachmentId
|
|
2060
|
+
attachmentId: payload.attachmentId,
|
|
2061
|
+
renderConfig: payload.renderConfig
|
|
2053
2062
|
};
|
|
2054
|
-
if (payload.targetWidth !== void 0) {
|
|
2055
|
-
imageLayer.targetWidth = payload.targetWidth;
|
|
2056
|
-
}
|
|
2057
|
-
if (payload.targetHeight !== void 0) {
|
|
2058
|
-
imageLayer.targetHeight = payload.targetHeight;
|
|
2059
|
-
}
|
|
2060
2063
|
if (payload.animation && globalTimeUs !== void 0) {
|
|
2061
2064
|
const animState = computeAnimationState(payload.animation, globalTimeUs);
|
|
2062
2065
|
if (!animState.visible) {
|
|
@@ -2458,4 +2461,4 @@ export {
|
|
|
2458
2461
|
VideoComposeWorker,
|
|
2459
2462
|
videoCompose_worker as default
|
|
2460
2463
|
};
|
|
2461
|
-
//# sourceMappingURL=video-compose.worker.
|
|
2464
|
+
//# sourceMappingURL=video-compose.worker.C8728Oi3.js.map
|