remotion-lambda 4.0.539__tar.gz → 4.0.541__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.539 → remotion_lambda-4.0.541}/PKG-INFO +1 -1
  2. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/__init__.py +2 -0
  3. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/asyncremotionclient.py +56 -1
  4. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/models.py +66 -0
  5. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/remotionclient.py +141 -4
  6. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/version.py +1 -1
  7. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda.egg-info/PKG-INFO +1 -1
  8. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/test_remotion_client.py +4 -1
  9. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/LICENSE +0 -0
  10. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/README.md +0 -0
  11. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/exception.py +0 -0
  12. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda/webhook.py +0 -0
  13. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda.egg-info/SOURCES.txt +0 -0
  14. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda.egg-info/dependency_links.txt +0 -0
  15. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda.egg-info/requires.txt +0 -0
  16. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/remotion_lambda.egg-info/top_level.txt +0 -0
  17. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/setup.cfg +0 -0
  18. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/setup.py +0 -0
  19. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/__init__.py +0 -0
  20. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/conftest.py +0 -0
  21. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/constants.py +0 -0
  22. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/test_get_render_progress_client.py +0 -0
  23. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/test_large_payload_compression.py +0 -0
  24. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/tests/test_render_client_render_media.py +0 -0
  25. {remotion_lambda-4.0.539 → remotion_lambda-4.0.541}/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.539
3
+ Version: 4.0.541
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 (
@@ -399,13 +401,21 @@ class RemotionClient:
399
401
  return True
400
402
  return False
401
403
 
402
- def _serialize_input_props(self, input_props: Optional[Dict[str, Any]], render_type: RenderType) -> Dict[str, Any] : # Added type hints
404
+ def _serialize_input_props(
405
+ self,
406
+ input_props: Optional[Dict[str, Any]],
407
+ render_type: RenderType,
408
+ user_specified_bucket_name: Optional[str] = None,
409
+ ) -> Dict[str, Any]: # Added type hints
403
410
  """
404
411
  Serialize inputProps to a format compatible with Lambda.
405
412
 
406
413
  Args:
407
414
  input_props (dict): Input properties to be serialized.
408
415
  render_type (RenderType): Type of the render (e.g., 'still' or 'video-or-audio').
416
+ user_specified_bucket_name (Optional[str]): Bucket to upload input props to
417
+ when they exceed the inline limit. When not provided, the default
418
+ Remotion bucket is used.
409
419
 
410
420
  Returns:
411
421
  dict: Serialized inputProps in either payload or bucket-url format.
@@ -416,7 +426,7 @@ class RemotionClient:
416
426
 
417
427
  if self._needs_upload(payload_size, render_type):
418
428
  hash_value = self._generate_hash(payload)
419
- bucket_name = self._get_or_create_bucket()
429
+ bucket_name = user_specified_bucket_name or self._get_or_create_bucket()
420
430
  key = self._input_props_key(hash_value)
421
431
 
422
432
  self._upload_to_s3(bucket_name, key, payload)
@@ -447,13 +457,26 @@ class RemotionClient:
447
457
  objects: List[str] = []
448
458
  depth = 0
449
459
  start_index = 0
460
+ in_string = False
461
+ escaped = False
450
462
 
451
463
  for i, char in enumerate(input_string):
464
+ if in_string:
465
+ if escaped:
466
+ escaped = False
467
+ elif char == '\\':
468
+ escaped = True
469
+ elif char == '"':
470
+ in_string = False
471
+ continue
472
+ if char == '"' and depth > 0:
473
+ in_string = True
474
+ continue
452
475
  if char == '{':
453
476
  if depth == 0:
454
477
  start_index = i
455
478
  depth += 1
456
- elif char == '}':
479
+ elif char == '}' and depth > 0:
457
480
  depth -= 1
458
481
  if depth == 0:
459
482
  objects.append(input_string[start_index : i + 1])
@@ -556,7 +579,12 @@ class RemotionClient:
556
579
  # Assuming RenderMediaParams and RenderStillParams both have an input_props attribute
557
580
  # and a private_serialized_input_props attribute (even if Optional)
558
581
  render_params.private_serialized_input_props = self._serialize_input_props(
559
- input_props=render_params.input_props, render_type=render_type
582
+ input_props=render_params.input_props,
583
+ render_type=render_type,
584
+ user_specified_bucket_name=getattr(
585
+ render_params, "force_bucket_name", None
586
+ )
587
+ or getattr(render_params, "bucket_name", None),
560
588
  )
561
589
  except (RemotionInvalidArgumentException, ClientError) as e:
562
590
  raise RemotionInvalidArgumentException(
@@ -742,3 +770,112 @@ class RemotionClient:
742
770
  render_progress.__dict__.update(progress_response_data)
743
771
  return render_progress
744
772
  return None
773
+
774
+ def construct_get_compositions_request(
775
+ self,
776
+ input_props: Optional[Dict[str, Any]] = None,
777
+ env_variables: Optional[Dict[str, str]] = None,
778
+ chromium_options: Optional[Dict[str, Any]] = None,
779
+ log_level: str = "info",
780
+ force_bucket_name: Optional[str] = None,
781
+ timeout_in_milliseconds: int = 30000,
782
+ offthread_video_cache_size_in_bytes: Optional[int] = None,
783
+ media_cache_size_in_bytes: Optional[int] = None,
784
+ preferred_effect_backend: Optional[str] = None,
785
+ ) -> str:
786
+ """
787
+ Construct a get compositions request in JSON format.
788
+
789
+ Args:
790
+ input_props (Optional[Dict[str, Any]]): Input properties passed to the project.
791
+ env_variables (Optional[Dict[str, str]]): Environment variables for the render function.
792
+ chromium_options (Optional[Dict[str, Any]]): Chromium options.
793
+ log_level (str): Log level ("error", "warning", "info", "verbose").
794
+ force_bucket_name (Optional[str]): Force the bucket to upload input props to.
795
+ timeout_in_milliseconds (int): Timeout for getting compositions.
796
+ offthread_video_cache_size_in_bytes (Optional[int]): Size limit for the offthread video cache.
797
+ media_cache_size_in_bytes (Optional[int]): Size limit for the media cache.
798
+ preferred_effect_backend (Optional[str]): Preferred effect backend.
799
+
800
+ Returns:
801
+ str: JSON representation of the get compositions request.
802
+ """
803
+ serialized_input_props = self._serialize_input_props(
804
+ input_props=input_props or {},
805
+ render_type="video-or-audio",
806
+ user_specified_bucket_name=force_bucket_name,
807
+ )
808
+
809
+ params = GetCompositionsParams(
810
+ serve_url=self.serve_url,
811
+ input_props=input_props or {},
812
+ env_variables=env_variables or {},
813
+ chromium_options=chromium_options or {},
814
+ log_level=log_level,
815
+ force_bucket_name=force_bucket_name,
816
+ force_path_style=self.force_path_style,
817
+ timeout_in_milliseconds=timeout_in_milliseconds,
818
+ offthread_video_cache_size_in_bytes=offthread_video_cache_size_in_bytes,
819
+ media_cache_size_in_bytes=media_cache_size_in_bytes,
820
+ preferred_effect_backend=preferred_effect_backend,
821
+ serialized_input_props=serialized_input_props,
822
+ )
823
+
824
+ try:
825
+ return json.dumps(params.serialize_params(), default=self._custom_serializer)
826
+ except (TypeError, OverflowError) as e:
827
+ raise RemotionInvalidArgumentException(
828
+ f"Failed to serialize compositions parameters to JSON: {e}"
829
+ ) from e
830
+
831
+ def get_compositions_on_lambda(
832
+ self,
833
+ input_props: Optional[Dict[str, Any]] = None,
834
+ env_variables: Optional[Dict[str, str]] = None,
835
+ chromium_options: Optional[Dict[str, Any]] = None,
836
+ log_level: str = "info",
837
+ force_bucket_name: Optional[str] = None,
838
+ timeout_in_milliseconds: int = 30000,
839
+ offthread_video_cache_size_in_bytes: Optional[int] = None,
840
+ media_cache_size_in_bytes: Optional[int] = None,
841
+ preferred_effect_backend: Optional[str] = None,
842
+ ) -> Optional[List[VideoConfig]]:
843
+ """
844
+ Get the compositions inside a Lambda function.
845
+
846
+ Args:
847
+ input_props (Optional[Dict[str, Any]]): Input properties passed to the project.
848
+ env_variables (Optional[Dict[str, str]]): Environment variables for the render function.
849
+ chromium_options (Optional[Dict[str, Any]]): Chromium options.
850
+ log_level (str): Log level ("error", "warning", "info", "verbose").
851
+ force_bucket_name (Optional[str]): Force the bucket to upload input props to.
852
+ timeout_in_milliseconds (int): Timeout for getting compositions.
853
+ offthread_video_cache_size_in_bytes (Optional[int]): Size limit for the offthread video cache.
854
+ media_cache_size_in_bytes (Optional[int]): Size limit for the media cache.
855
+ preferred_effect_backend (Optional[str]): Preferred effect backend.
856
+
857
+ Returns:
858
+ Optional[List[VideoConfig]]: The compositions, or None if no compositions response.
859
+ """
860
+ params_json_str = self.construct_get_compositions_request(
861
+ input_props=input_props,
862
+ env_variables=env_variables,
863
+ chromium_options=chromium_options,
864
+ log_level=log_level,
865
+ force_bucket_name=force_bucket_name,
866
+ timeout_in_milliseconds=timeout_in_milliseconds,
867
+ offthread_video_cache_size_in_bytes=offthread_video_cache_size_in_bytes,
868
+ media_cache_size_in_bytes=media_cache_size_in_bytes,
869
+ preferred_effect_backend=preferred_effect_backend,
870
+ )
871
+ response_data = self._invoke_lambda(
872
+ function_name=self.function_name, payload=params_json_str
873
+ )
874
+ if response_data and "compositions" in response_data:
875
+ compositions: List[VideoConfig] = []
876
+ for composition in response_data["compositions"]:
877
+ video_config = VideoConfig()
878
+ video_config.__dict__.update(composition)
879
+ compositions.append(video_config)
880
+ return compositions
881
+ return None
@@ -1,2 +1,2 @@
1
1
  # pylint: disable=missing-module-docstring, missing-final-newline
2
- VERSION = "4.0.539"
2
+ VERSION = "4.0.541"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: remotion-lambda
3
- Version: 4.0.539
3
+ Version: 4.0.541
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
@@ -317,6 +317,8 @@ def test_construct_render_request_client_error_from_serialize_input_props(
317
317
 
318
318
  mock_render_params = Mock()
319
319
  mock_render_params.input_props = {"dummy": "data"}
320
+ mock_render_params.force_bucket_name = None
321
+ mock_render_params.bucket_name = None
320
322
  mock_render_params.serialize_params.return_value = {"serialized": "params"}
321
323
 
322
324
  with pytest.raises(RemotionInvalidArgumentException) as excinfo:
@@ -327,7 +329,8 @@ def test_construct_render_request_client_error_from_serialize_input_props(
327
329
  assert "AccessDenied" in str(excinfo.value) # Ensure the original ClientError info is present
328
330
  mock_serialize_input_props.assert_called_once_with(
329
331
  input_props=mock_render_params.input_props,
330
- render_type="still"
332
+ render_type="still",
333
+ user_specified_bucket_name=None,
331
334
  )
332
335
 
333
336