remotion-lambda 4.0.538__tar.gz → 4.0.540__tar.gz

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 (25) hide show
  1. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/PKG-INFO +1 -1
  2. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/__init__.py +2 -0
  3. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/asyncremotionclient.py +56 -1
  4. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/models.py +66 -0
  5. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/remotionclient.py +123 -1
  6. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/version.py +1 -1
  7. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda.egg-info/PKG-INFO +1 -1
  8. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/LICENSE +0 -0
  9. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/README.md +0 -0
  10. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/exception.py +0 -0
  11. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda/webhook.py +0 -0
  12. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda.egg-info/SOURCES.txt +0 -0
  13. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda.egg-info/dependency_links.txt +0 -0
  14. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda.egg-info/requires.txt +0 -0
  15. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/remotion_lambda.egg-info/top_level.txt +0 -0
  16. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/setup.cfg +0 -0
  17. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/setup.py +0 -0
  18. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/__init__.py +0 -0
  19. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/conftest.py +0 -0
  20. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/constants.py +0 -0
  21. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/test_get_render_progress_client.py +0 -0
  22. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/test_large_payload_compression.py +0 -0
  23. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/test_remotion_client.py +0 -0
  24. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/test_render_client_render_media.py +0 -0
  25. {remotion_lambda-4.0.538 → remotion_lambda-4.0.540}/tests/test_render_client_render_still.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotion_lambda
3
- Version: 4.0.538
3
+ Version: 4.0.540
4
4
  Summary: Remotion Lambda client
5
5
  Home-page: https://github.com/remotion-dev/remotion/tree/main/packages/lambda-python
6
6
  Author: Jonny Burger
@@ -1,5 +1,7 @@
1
1
  # pylint: disable=missing-module-docstring
2
2
  from .models import (
3
+ GetCompositionsParams,
4
+ VideoConfig,
3
5
  RenderFramesParams,
4
6
  ImageSequenceOutputPrefix,
5
7
  RenderMediaParams,
@@ -1,7 +1,7 @@
1
1
  # pylint: disable=too-many-arguments, too-many-positional-arguments
2
2
  """Awaitable client for rendering with Remotion Lambda."""
3
3
  import asyncio
4
- from typing import Optional, Union
4
+ from typing import Any, Dict, List, Optional, Union
5
5
 
6
6
  from boto3.session import Session
7
7
  from botocore.config import Config
@@ -14,6 +14,7 @@ from .models import (
14
14
  RenderStillParams,
15
15
  RenderStillResponse,
16
16
  RenderType,
17
+ VideoConfig,
17
18
  )
18
19
  from .remotionclient import RemotionClient
19
20
 
@@ -71,6 +72,60 @@ class AsyncRemotionClient:
71
72
  s3_output_provider,
72
73
  )
73
74
 
75
+ async def construct_get_compositions_request(
76
+ self,
77
+ input_props: Optional[Dict[str, Any]] = None,
78
+ env_variables: Optional[Dict[str, str]] = None,
79
+ chromium_options: Optional[Dict[str, Any]] = None,
80
+ log_level: str = "info",
81
+ force_bucket_name: Optional[str] = None,
82
+ timeout_in_milliseconds: int = 30000,
83
+ offthread_video_cache_size_in_bytes: Optional[int] = None,
84
+ media_cache_size_in_bytes: Optional[int] = None,
85
+ preferred_effect_backend: Optional[str] = None,
86
+ ) -> str:
87
+ """Construct a compositions request, including any required S3 uploads."""
88
+ return await asyncio.get_running_loop().run_in_executor(
89
+ None,
90
+ self._client.construct_get_compositions_request,
91
+ input_props,
92
+ env_variables,
93
+ chromium_options,
94
+ log_level,
95
+ force_bucket_name,
96
+ timeout_in_milliseconds,
97
+ offthread_video_cache_size_in_bytes,
98
+ media_cache_size_in_bytes,
99
+ preferred_effect_backend,
100
+ )
101
+
102
+ async def get_compositions_on_lambda(
103
+ self,
104
+ input_props: Optional[Dict[str, Any]] = None,
105
+ env_variables: Optional[Dict[str, str]] = None,
106
+ chromium_options: Optional[Dict[str, Any]] = None,
107
+ log_level: str = "info",
108
+ force_bucket_name: Optional[str] = None,
109
+ timeout_in_milliseconds: int = 30000,
110
+ offthread_video_cache_size_in_bytes: Optional[int] = None,
111
+ media_cache_size_in_bytes: Optional[int] = None,
112
+ preferred_effect_backend: Optional[str] = None,
113
+ ) -> Optional[List[VideoConfig]]:
114
+ """Get the compositions in the deployed project without blocking the event loop."""
115
+ return await asyncio.get_running_loop().run_in_executor(
116
+ None,
117
+ self._client.get_compositions_on_lambda,
118
+ input_props,
119
+ env_variables,
120
+ chromium_options,
121
+ log_level,
122
+ force_bucket_name,
123
+ timeout_in_milliseconds,
124
+ offthread_video_cache_size_in_bytes,
125
+ media_cache_size_in_bytes,
126
+ preferred_effect_backend,
127
+ )
128
+
74
129
  async def render_media_on_lambda(
75
130
  self, render_params: RenderMediaParams
76
131
  ) -> Optional[RenderMediaResponse]:
@@ -234,6 +234,68 @@ class RenderProgressParams:
234
234
  return parameters
235
235
 
236
236
 
237
+ @dataclass
238
+ class GetCompositionsParams:
239
+ """
240
+ Parameters for getting the compositions defined in a Remotion project.
241
+ """
242
+
243
+ serve_url: str
244
+ input_props: Dict
245
+ env_variables: Optional[Dict] = None
246
+ chromium_options: Optional[Dict] = None
247
+ log_level: str = 'info'
248
+ force_bucket_name: Optional[str] = None
249
+ force_path_style: bool = False
250
+ timeout_in_milliseconds: int = 30000
251
+ offthread_video_cache_size_in_bytes: Optional[int] = None
252
+ media_cache_size_in_bytes: Optional[int] = None
253
+ preferred_effect_backend: Optional[str] = None
254
+ serialized_input_props: Optional[Dict] = None
255
+
256
+ def serialize_params(self) -> Dict:
257
+ """
258
+ Convert instance attributes to a dictionary for serialization.
259
+ """
260
+ parameters: Dict[str, Any] = {
261
+ 'type': 'compositions',
262
+ 'version': VERSION,
263
+ 'chromiumOptions': self.chromium_options or {},
264
+ 'logLevel': self.log_level,
265
+ 'inputProps': self.serialized_input_props or {},
266
+ 'envVariables': self.env_variables or {},
267
+ 'timeoutInMilliseconds': self.timeout_in_milliseconds,
268
+ 'serveUrl': self.serve_url,
269
+ 'bucketName': self.force_bucket_name,
270
+ 'offthreadVideoCacheSizeInBytes': self.offthread_video_cache_size_in_bytes,
271
+ 'mediaCacheSizeInBytes': self.media_cache_size_in_bytes,
272
+ 'preferredEffectBackend': self.preferred_effect_backend or 'auto',
273
+ 'forcePathStyle': self.force_path_style,
274
+ }
275
+ return parameters
276
+
277
+
278
+ @dataclass
279
+ class VideoConfig:
280
+ """
281
+ A single composition as returned by a compositions Lambda function.
282
+ """
283
+
284
+ width: int = 0
285
+ height: int = 0
286
+ fps: float = 0.0
287
+ durationInFrames: int = 0
288
+ id: str = ""
289
+ defaultProps: Dict = field(default_factory=dict)
290
+ props: Dict = field(default_factory=dict)
291
+ defaultCodec: Optional[str] = None
292
+ defaultOutName: Optional[str] = None
293
+ defaultVideoImageFormat: Optional[str] = None
294
+ defaultPixelFormat: Optional[str] = None
295
+ defaultProResProfile: Optional[str] = None
296
+ defaultSampleRate: Optional[int] = None
297
+
298
+
237
299
  @dataclass
238
300
  class CostsInfo:
239
301
  """
@@ -351,6 +413,7 @@ class RenderMediaParams:
351
413
  sample_rate: int = 48000
352
414
  disable_shared_memory_capture: bool = False
353
415
  separate_audio_to: Optional[Union[str, OutNameInputObject]] = None
416
+ preferred_effect_backend: Literal["auto", "webgpu", "webgl2", "2d"] = "auto"
354
417
 
355
418
  def serialize_params(self) -> Dict:
356
419
  """
@@ -407,6 +470,7 @@ class RenderMediaParams:
407
470
  'forceDurationInFrames': self.force_duration_in_frames,
408
471
  'offthreadVideoCacheSizeInBytes': self.offthreadvideo_cache_size_in_bytes,
409
472
  'mediaCacheSizeInBytes': self.media_cache_size_in_bytes,
473
+ 'preferredEffectBackend': self.preferred_effect_backend,
410
474
  'offthreadVideoThreads': self.offthreadvideo_threads,
411
475
  'forceWidth': self.force_width,
412
476
  'licenseKey': self.license_key if self.license_key is not None else self.api_key,
@@ -554,6 +618,7 @@ class RenderStillParams:
554
618
  offthreadvideo_threads: Optional[int] = None
555
619
  streamed: bool = False
556
620
  is_production: Optional[bool] = None
621
+ preferred_effect_backend: Literal["auto", "webgpu", "webgl2", "2d"] = "auto"
557
622
 
558
623
  def serialize_params(self) -> Dict:
559
624
  """
@@ -607,6 +672,7 @@ class RenderStillParams:
607
672
  'attempt': self.attempt,
608
673
  'offthreadVideoCacheSizeInBytes': self.offthreadvideo_cache_size_in_bytes,
609
674
  'mediaCacheSizeInBytes': self.media_cache_size_in_bytes,
675
+ 'preferredEffectBackend': self.preferred_effect_backend,
610
676
  'offthreadVideoThreads': self.offthreadvideo_threads,
611
677
  'streamed': self.streamed,
612
678
  'isProduction': self.is_production,
@@ -18,6 +18,7 @@ from botocore.response import StreamingBody # For Lambda payload
18
18
  from .models import (
19
19
  CostsInfo,
20
20
  CustomCredentials,
21
+ GetCompositionsParams,
21
22
  RenderFramesParams,
22
23
  RenderMediaParams,
23
24
  RenderMediaProgress,
@@ -26,6 +27,7 @@ from .models import (
26
27
  RenderStillResponse,
27
28
  RenderStillParams,
28
29
  RenderType,
30
+ VideoConfig,
29
31
  )
30
32
 
31
33
  from .exception import (
@@ -447,13 +449,26 @@ class RemotionClient:
447
449
  objects: List[str] = []
448
450
  depth = 0
449
451
  start_index = 0
452
+ in_string = False
453
+ escaped = False
450
454
 
451
455
  for i, char in enumerate(input_string):
456
+ if in_string:
457
+ if escaped:
458
+ escaped = False
459
+ elif char == '\\':
460
+ escaped = True
461
+ elif char == '"':
462
+ in_string = False
463
+ continue
464
+ if char == '"' and depth > 0:
465
+ in_string = True
466
+ continue
452
467
  if char == '{':
453
468
  if depth == 0:
454
469
  start_index = i
455
470
  depth += 1
456
- elif char == '}':
471
+ elif char == '}' and depth > 0:
457
472
  depth -= 1
458
473
  if depth == 0:
459
474
  objects.append(input_string[start_index : i + 1])
@@ -742,3 +757,110 @@ class RemotionClient:
742
757
  render_progress.__dict__.update(progress_response_data)
743
758
  return render_progress
744
759
  return None
760
+
761
+ def construct_get_compositions_request(
762
+ self,
763
+ input_props: Optional[Dict[str, Any]] = None,
764
+ env_variables: Optional[Dict[str, str]] = None,
765
+ chromium_options: Optional[Dict[str, Any]] = None,
766
+ log_level: str = "info",
767
+ force_bucket_name: Optional[str] = None,
768
+ timeout_in_milliseconds: int = 30000,
769
+ offthread_video_cache_size_in_bytes: Optional[int] = None,
770
+ media_cache_size_in_bytes: Optional[int] = None,
771
+ preferred_effect_backend: Optional[str] = None,
772
+ ) -> str:
773
+ """
774
+ Construct a get compositions request in JSON format.
775
+
776
+ Args:
777
+ input_props (Optional[Dict[str, Any]]): Input properties passed to the project.
778
+ env_variables (Optional[Dict[str, str]]): Environment variables for the render function.
779
+ chromium_options (Optional[Dict[str, Any]]): Chromium options.
780
+ log_level (str): Log level ("error", "warning", "info", "verbose").
781
+ force_bucket_name (Optional[str]): Force the bucket to upload input props to.
782
+ timeout_in_milliseconds (int): Timeout for getting compositions.
783
+ offthread_video_cache_size_in_bytes (Optional[int]): Size limit for the offthread video cache.
784
+ media_cache_size_in_bytes (Optional[int]): Size limit for the media cache.
785
+ preferred_effect_backend (Optional[str]): Preferred effect backend.
786
+
787
+ Returns:
788
+ str: JSON representation of the get compositions request.
789
+ """
790
+ serialized_input_props = self._serialize_input_props(
791
+ input_props=input_props or {}, render_type="video-or-audio"
792
+ )
793
+
794
+ params = GetCompositionsParams(
795
+ serve_url=self.serve_url,
796
+ input_props=input_props or {},
797
+ env_variables=env_variables or {},
798
+ chromium_options=chromium_options or {},
799
+ log_level=log_level,
800
+ force_bucket_name=force_bucket_name,
801
+ force_path_style=self.force_path_style,
802
+ timeout_in_milliseconds=timeout_in_milliseconds,
803
+ offthread_video_cache_size_in_bytes=offthread_video_cache_size_in_bytes,
804
+ media_cache_size_in_bytes=media_cache_size_in_bytes,
805
+ preferred_effect_backend=preferred_effect_backend,
806
+ serialized_input_props=serialized_input_props,
807
+ )
808
+
809
+ try:
810
+ return json.dumps(params.serialize_params(), default=self._custom_serializer)
811
+ except (TypeError, OverflowError) as e:
812
+ raise RemotionInvalidArgumentException(
813
+ f"Failed to serialize compositions parameters to JSON: {e}"
814
+ ) from e
815
+
816
+ def get_compositions_on_lambda(
817
+ self,
818
+ input_props: Optional[Dict[str, Any]] = None,
819
+ env_variables: Optional[Dict[str, str]] = None,
820
+ chromium_options: Optional[Dict[str, Any]] = None,
821
+ log_level: str = "info",
822
+ force_bucket_name: Optional[str] = None,
823
+ timeout_in_milliseconds: int = 30000,
824
+ offthread_video_cache_size_in_bytes: Optional[int] = None,
825
+ media_cache_size_in_bytes: Optional[int] = None,
826
+ preferred_effect_backend: Optional[str] = None,
827
+ ) -> Optional[List[VideoConfig]]:
828
+ """
829
+ Get the compositions inside a Lambda function.
830
+
831
+ Args:
832
+ input_props (Optional[Dict[str, Any]]): Input properties passed to the project.
833
+ env_variables (Optional[Dict[str, str]]): Environment variables for the render function.
834
+ chromium_options (Optional[Dict[str, Any]]): Chromium options.
835
+ log_level (str): Log level ("error", "warning", "info", "verbose").
836
+ force_bucket_name (Optional[str]): Force the bucket to upload input props to.
837
+ timeout_in_milliseconds (int): Timeout for getting compositions.
838
+ offthread_video_cache_size_in_bytes (Optional[int]): Size limit for the offthread video cache.
839
+ media_cache_size_in_bytes (Optional[int]): Size limit for the media cache.
840
+ preferred_effect_backend (Optional[str]): Preferred effect backend.
841
+
842
+ Returns:
843
+ Optional[List[VideoConfig]]: The compositions, or None if no compositions response.
844
+ """
845
+ params_json_str = self.construct_get_compositions_request(
846
+ input_props=input_props,
847
+ env_variables=env_variables,
848
+ chromium_options=chromium_options,
849
+ log_level=log_level,
850
+ force_bucket_name=force_bucket_name,
851
+ timeout_in_milliseconds=timeout_in_milliseconds,
852
+ offthread_video_cache_size_in_bytes=offthread_video_cache_size_in_bytes,
853
+ media_cache_size_in_bytes=media_cache_size_in_bytes,
854
+ preferred_effect_backend=preferred_effect_backend,
855
+ )
856
+ response_data = self._invoke_lambda(
857
+ function_name=self.function_name, payload=params_json_str
858
+ )
859
+ if response_data and "compositions" in response_data:
860
+ compositions: List[VideoConfig] = []
861
+ for composition in response_data["compositions"]:
862
+ video_config = VideoConfig()
863
+ video_config.__dict__.update(composition)
864
+ compositions.append(video_config)
865
+ return compositions
866
+ return None
@@ -1,2 +1,2 @@
1
1
  # pylint: disable=missing-module-docstring, missing-final-newline
2
- VERSION = "4.0.538"
2
+ VERSION = "4.0.540"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotion-lambda
3
- Version: 4.0.538
3
+ Version: 4.0.540
4
4
  Summary: Remotion Lambda client
5
5
  Home-page: https://github.com/remotion-dev/remotion/tree/main/packages/lambda-python
6
6
  Author: Jonny Burger