@remotion/studio 4.0.402 → 4.0.403

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.
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEncodableVideoCodecs = void 0;
4
+ const web_renderer_1 = require("@remotion/web-renderer");
5
+ const react_1 = require("react");
6
+ const useEncodableVideoCodecs = (container) => {
7
+ var _a;
8
+ const cacheRef = (0, react_1.useRef)({});
9
+ const [codecsByContainer, setCodecsByContainer] = (0, react_1.useState)(() => {
10
+ // Initialize with fallback for the current container
11
+ return {
12
+ [container]: (0, web_renderer_1.getSupportedVideoCodecsForContainer)(container),
13
+ };
14
+ });
15
+ (0, react_1.useEffect)(() => {
16
+ const cached = cacheRef.current[container];
17
+ // Already fetched or currently fetching for this container
18
+ if (cached) {
19
+ return;
20
+ }
21
+ const supported = (0, web_renderer_1.getSupportedVideoCodecsForContainer)(container);
22
+ // Mark as fetching to prevent duplicate requests
23
+ cacheRef.current[container] = {
24
+ codecs: supported,
25
+ status: 'fetching',
26
+ };
27
+ (0, web_renderer_1.getEncodableVideoCodecs)(container)
28
+ .then((encodable) => {
29
+ cacheRef.current[container] = {
30
+ codecs: encodable,
31
+ status: 'done',
32
+ };
33
+ setCodecsByContainer((prev) => ({
34
+ ...prev,
35
+ [container]: encodable,
36
+ }));
37
+ })
38
+ .catch(() => {
39
+ // On error, keep using the supported codecs fallback
40
+ cacheRef.current[container] = {
41
+ codecs: supported,
42
+ status: 'done',
43
+ };
44
+ });
45
+ }, [container]);
46
+ // Return codecs for current container, or fall back to supported codecs
47
+ return ((_a = codecsByContainer[container]) !== null && _a !== void 0 ? _a : (0, web_renderer_1.getSupportedVideoCodecsForContainer)(container));
48
+ };
49
+ exports.useEncodableVideoCodecs = useEncodableVideoCodecs;