remotion-lambda 4.0.533__tar.gz → 4.0.535__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.
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/PKG-INFO +1 -1
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda/__init__.py +3 -0
- remotion_lambda-4.0.535/remotion_lambda/asyncremotionclient.py +111 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda/models.py +82 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda/remotionclient.py +12 -1
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda/version.py +1 -1
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda.egg-info/PKG-INFO +1 -1
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda.egg-info/SOURCES.txt +1 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/LICENSE +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/README.md +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda/exception.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda.egg-info/dependency_links.txt +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda.egg-info/requires.txt +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda.egg-info/top_level.txt +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/setup.cfg +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/setup.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/__init__.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/conftest.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/constants.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_get_render_progress_client.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_large_payload_compression.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_remotion_client.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_render_client_render_media.py +0 -0
- {remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_render_client_render_still.py +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# pylint: disable=missing-module-docstring
|
|
2
2
|
from .models import (
|
|
3
|
+
RenderFramesParams,
|
|
4
|
+
ImageSequenceOutputPrefix,
|
|
3
5
|
RenderMediaParams,
|
|
4
6
|
RenderMediaProgress,
|
|
5
7
|
RenderMediaResponse,
|
|
@@ -21,4 +23,5 @@ from .models import (
|
|
|
21
23
|
Webhook,
|
|
22
24
|
)
|
|
23
25
|
from .remotionclient import RemotionClient
|
|
26
|
+
from .asyncremotionclient import AsyncRemotionClient
|
|
24
27
|
from .version import VERSION
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
|
2
|
+
"""Awaitable client for rendering with Remotion Lambda."""
|
|
3
|
+
import asyncio
|
|
4
|
+
from typing import Optional, Union
|
|
5
|
+
|
|
6
|
+
from boto3.session import Session
|
|
7
|
+
from botocore.config import Config
|
|
8
|
+
|
|
9
|
+
from .models import (
|
|
10
|
+
CustomCredentials,
|
|
11
|
+
RenderMediaParams,
|
|
12
|
+
RenderMediaProgress,
|
|
13
|
+
RenderMediaResponse,
|
|
14
|
+
RenderStillParams,
|
|
15
|
+
RenderStillResponse,
|
|
16
|
+
RenderType,
|
|
17
|
+
)
|
|
18
|
+
from .remotionclient import RemotionClient
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AsyncRemotionClient:
|
|
22
|
+
"""Run RemotionClient operations without blocking the asyncio event loop."""
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
region: str,
|
|
27
|
+
serve_url: str,
|
|
28
|
+
function_name: str,
|
|
29
|
+
access_key: Optional[str] = None,
|
|
30
|
+
secret_key: Optional[str] = None,
|
|
31
|
+
force_path_style: bool = False,
|
|
32
|
+
session: Optional[Session] = None,
|
|
33
|
+
config: Optional[Config] = None,
|
|
34
|
+
):
|
|
35
|
+
"""Accept the same configuration and credentials as RemotionClient."""
|
|
36
|
+
self._client = RemotionClient(
|
|
37
|
+
region=region,
|
|
38
|
+
serve_url=serve_url,
|
|
39
|
+
function_name=function_name,
|
|
40
|
+
access_key=access_key,
|
|
41
|
+
secret_key=secret_key,
|
|
42
|
+
force_path_style=force_path_style,
|
|
43
|
+
session=session,
|
|
44
|
+
config=config,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
async def construct_render_request(
|
|
48
|
+
self,
|
|
49
|
+
render_params: Union[RenderMediaParams, RenderStillParams],
|
|
50
|
+
render_type: RenderType,
|
|
51
|
+
) -> str:
|
|
52
|
+
"""Construct a render request, including any required S3 uploads."""
|
|
53
|
+
return await asyncio.get_running_loop().run_in_executor(
|
|
54
|
+
None, self._client.construct_render_request, render_params, render_type
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
async def construct_render_progress_request(
|
|
58
|
+
self,
|
|
59
|
+
render_id: str,
|
|
60
|
+
bucket_name: str,
|
|
61
|
+
log_level: str = "info",
|
|
62
|
+
s3_output_provider: Optional[CustomCredentials] = None,
|
|
63
|
+
) -> str:
|
|
64
|
+
"""Construct a render progress request in JSON format."""
|
|
65
|
+
return await asyncio.get_running_loop().run_in_executor(
|
|
66
|
+
None,
|
|
67
|
+
self._client.construct_render_progress_request,
|
|
68
|
+
render_id,
|
|
69
|
+
bucket_name,
|
|
70
|
+
log_level,
|
|
71
|
+
s3_output_provider,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
async def render_media_on_lambda(
|
|
75
|
+
self, render_params: RenderMediaParams
|
|
76
|
+
) -> Optional[RenderMediaResponse]:
|
|
77
|
+
"""Start a media render and return its render ID and bucket name."""
|
|
78
|
+
return await asyncio.get_running_loop().run_in_executor(
|
|
79
|
+
None, self._client.render_media_on_lambda, render_params
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
async def render_still_on_lambda(
|
|
83
|
+
self, render_params: RenderStillParams
|
|
84
|
+
) -> Optional[RenderStillResponse]:
|
|
85
|
+
"""Render a still and return its output information."""
|
|
86
|
+
return await asyncio.get_running_loop().run_in_executor(
|
|
87
|
+
None, self._client.render_still_on_lambda, render_params
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
async def get_render_progress(
|
|
91
|
+
self,
|
|
92
|
+
render_id: str,
|
|
93
|
+
bucket_name: str,
|
|
94
|
+
log_level: str = "info",
|
|
95
|
+
s3_output_provider: Optional[CustomCredentials] = None,
|
|
96
|
+
) -> Optional[RenderMediaProgress]:
|
|
97
|
+
"""Get the progress of a media render."""
|
|
98
|
+
return await asyncio.get_running_loop().run_in_executor(
|
|
99
|
+
None,
|
|
100
|
+
self._client.get_render_progress,
|
|
101
|
+
render_id,
|
|
102
|
+
bucket_name,
|
|
103
|
+
log_level,
|
|
104
|
+
s3_output_provider,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
async def cancel_render_on_lambda(self, render_id: str, bucket_name: str) -> None:
|
|
108
|
+
"""Cancel a render started with enable_cancellation=True."""
|
|
109
|
+
await asyncio.get_running_loop().run_in_executor(
|
|
110
|
+
None, self._client.cancel_render_on_lambda, render_id, bucket_name
|
|
111
|
+
)
|
|
@@ -156,6 +156,18 @@ class OutNameInputObject:
|
|
|
156
156
|
key: str
|
|
157
157
|
s3_output_provider: Optional[CustomCredentials] = None
|
|
158
158
|
|
|
159
|
+
def serialize_params(self) -> Dict:
|
|
160
|
+
"""Serialize the output destination and any custom storage credentials."""
|
|
161
|
+
return {
|
|
162
|
+
'bucketName': self.bucketName,
|
|
163
|
+
'key': self.key,
|
|
164
|
+
's3OutputProvider': (
|
|
165
|
+
self.s3_output_provider.serialize_params()
|
|
166
|
+
if self.s3_output_provider is not None
|
|
167
|
+
else None
|
|
168
|
+
),
|
|
169
|
+
}
|
|
170
|
+
|
|
159
171
|
|
|
160
172
|
class DeleteAfter(Enum):
|
|
161
173
|
"""
|
|
@@ -337,6 +349,8 @@ class RenderMediaParams:
|
|
|
337
349
|
encoding_max_rate: Optional[str] = None
|
|
338
350
|
is_production: Optional[bool] = None
|
|
339
351
|
sample_rate: int = 48000
|
|
352
|
+
disable_shared_memory_capture: bool = False
|
|
353
|
+
separate_audio_to: Optional[Union[str, OutNameInputObject]] = None
|
|
340
354
|
|
|
341
355
|
def serialize_params(self) -> Dict:
|
|
342
356
|
"""
|
|
@@ -362,6 +376,11 @@ class RenderMediaParams:
|
|
|
362
376
|
'logLevel': self.log_level,
|
|
363
377
|
'frameRange': self.frame_range,
|
|
364
378
|
'outName': self.out_name,
|
|
379
|
+
'separateAudioTo': (
|
|
380
|
+
self.separate_audio_to.serialize_params()
|
|
381
|
+
if isinstance(self.separate_audio_to, OutNameInputObject)
|
|
382
|
+
else self.separate_audio_to
|
|
383
|
+
),
|
|
365
384
|
'preferLossless': self.prefer_lossless,
|
|
366
385
|
'sampleRate': self.sample_rate,
|
|
367
386
|
'timeoutInMilliseconds': self.timeout_in_milliseconds,
|
|
@@ -395,11 +414,13 @@ class RenderMediaParams:
|
|
|
395
414
|
'audioCodec': self.audio_codec,
|
|
396
415
|
'x264Preset': self.x264_preset,
|
|
397
416
|
'gopSize': self.gop_size,
|
|
417
|
+
'disableSharedMemoryCapture': self.disable_shared_memory_capture,
|
|
398
418
|
'deleteAfter': self.delete_after,
|
|
399
419
|
'encodingBufferSize': self.encoding_buffer_size,
|
|
400
420
|
'encodingMaxRate': self.encoding_max_rate,
|
|
401
421
|
'isProduction': self.is_production,
|
|
402
422
|
'type': 'start',
|
|
423
|
+
'output': {'type': 'media'},
|
|
403
424
|
}
|
|
404
425
|
|
|
405
426
|
if self.crf is not None:
|
|
@@ -433,6 +454,64 @@ class RenderMediaParams:
|
|
|
433
454
|
return parameters
|
|
434
455
|
|
|
435
456
|
|
|
457
|
+
@dataclass
|
|
458
|
+
class ImageSequenceOutputPrefix:
|
|
459
|
+
"""Destination bucket and prefix for an image sequence."""
|
|
460
|
+
|
|
461
|
+
bucket_name: str
|
|
462
|
+
key_prefix: str
|
|
463
|
+
s3_output_provider: Optional[CustomCredentials] = None
|
|
464
|
+
|
|
465
|
+
def serialize_params(self) -> Dict:
|
|
466
|
+
"""Convert the destination to the Lambda payload format."""
|
|
467
|
+
return {
|
|
468
|
+
'bucketName': self.bucket_name,
|
|
469
|
+
'keyPrefix': self.key_prefix,
|
|
470
|
+
's3OutputProvider': (
|
|
471
|
+
self.s3_output_provider.serialize_params()
|
|
472
|
+
if self.s3_output_provider is not None else None
|
|
473
|
+
),
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
@dataclass
|
|
478
|
+
class RenderFramesParams(RenderMediaParams):
|
|
479
|
+
"""Parameters for rendering a PNG or JPEG image sequence."""
|
|
480
|
+
|
|
481
|
+
codec: Optional[str] = None
|
|
482
|
+
image_format: Literal['png', 'jpeg'] = 'png'
|
|
483
|
+
jpeg_quality: Optional[int] = None
|
|
484
|
+
frame_range: Optional[Union[int, List[int]]] = None
|
|
485
|
+
output_prefix: Optional[Union[str, ImageSequenceOutputPrefix]] = None
|
|
486
|
+
image_sequence_pattern: Optional[str] = None
|
|
487
|
+
|
|
488
|
+
def serialize_params(self) -> Dict:
|
|
489
|
+
"""Convert the sequence parameters to the Lambda payload format."""
|
|
490
|
+
if self.image_format not in ('png', 'jpeg'):
|
|
491
|
+
raise ValueError('image_format must be "png" or "jpeg".')
|
|
492
|
+
if self.jpeg_quality is not None and self.image_format != 'jpeg':
|
|
493
|
+
raise ValueError('jpeg_quality can only be passed with image_format="jpeg".')
|
|
494
|
+
|
|
495
|
+
parameters = super().serialize_params()
|
|
496
|
+
parameters.update({
|
|
497
|
+
'codec': None,
|
|
498
|
+
'muted': True,
|
|
499
|
+
'outName': None,
|
|
500
|
+
'numberOfGifLoops': None,
|
|
501
|
+
'jpegQuality': self.jpeg_quality if self.jpeg_quality is not None else 80,
|
|
502
|
+
'output': {
|
|
503
|
+
'type': 'sequence',
|
|
504
|
+
'outputPrefix': (
|
|
505
|
+
self.output_prefix.serialize_params()
|
|
506
|
+
if isinstance(self.output_prefix, ImageSequenceOutputPrefix)
|
|
507
|
+
else self.output_prefix
|
|
508
|
+
),
|
|
509
|
+
'imageSequencePattern': self.image_sequence_pattern,
|
|
510
|
+
},
|
|
511
|
+
})
|
|
512
|
+
return parameters
|
|
513
|
+
|
|
514
|
+
|
|
436
515
|
@dataclass
|
|
437
516
|
class RenderStillParams:
|
|
438
517
|
"""
|
|
@@ -587,3 +666,6 @@ class RenderMediaProgress:
|
|
|
587
666
|
outputSizeInBytes: Optional[int] = None
|
|
588
667
|
lambdasInvoked: int = 0
|
|
589
668
|
framesRendered: Optional[int] = None
|
|
669
|
+
framesUploaded: Optional[int] = None
|
|
670
|
+
outputSequence: Optional[Dict[str, Any]] = None
|
|
671
|
+
separateAudio: Optional[Dict[str, Any]] = None
|
|
@@ -6,6 +6,7 @@ import json
|
|
|
6
6
|
import hashlib
|
|
7
7
|
import time
|
|
8
8
|
from math import ceil
|
|
9
|
+
from threading import Lock
|
|
9
10
|
from typing import Optional, Union, List, Dict, Any
|
|
10
11
|
from enum import Enum
|
|
11
12
|
import warnings
|
|
@@ -17,6 +18,7 @@ from botocore.response import StreamingBody # For Lambda payload
|
|
|
17
18
|
from .models import (
|
|
18
19
|
CostsInfo,
|
|
19
20
|
CustomCredentials,
|
|
21
|
+
RenderFramesParams,
|
|
20
22
|
RenderMediaParams,
|
|
21
23
|
RenderMediaProgress,
|
|
22
24
|
RenderMediaResponse,
|
|
@@ -213,6 +215,7 @@ class RemotionClient:
|
|
|
213
215
|
self.function_name = function_name.strip()
|
|
214
216
|
self.force_path_style = force_path_style
|
|
215
217
|
self.config = config or Config() # Provide default empty config
|
|
218
|
+
self._session_lock = Lock()
|
|
216
219
|
|
|
217
220
|
def _generate_hash(self, payload: str) -> str: # Added type hints
|
|
218
221
|
"""Generate a hash for the payload."""
|
|
@@ -257,7 +260,9 @@ class RemotionClient:
|
|
|
257
260
|
if current_config:
|
|
258
261
|
client_kwargs['config'] = current_config
|
|
259
262
|
|
|
260
|
-
|
|
263
|
+
# boto3 sessions cannot create clients concurrently across threads.
|
|
264
|
+
with self._session_lock:
|
|
265
|
+
return self.session.client(service_name, **client_kwargs) # type: ignore[call-overload]
|
|
261
266
|
|
|
262
267
|
def _create_s3_client(self) -> Any: # Returns an S3 client type
|
|
263
268
|
"""Creates and returns a boto3 S3 client."""
|
|
@@ -627,6 +632,12 @@ class RemotionClient:
|
|
|
627
632
|
|
|
628
633
|
return None
|
|
629
634
|
|
|
635
|
+
def render_frames_on_lambda(
|
|
636
|
+
self, render_params: RenderFramesParams
|
|
637
|
+
) -> Optional[RenderMediaResponse]:
|
|
638
|
+
"""Start an image sequence render and track it with get_render_progress()."""
|
|
639
|
+
return self.render_media_on_lambda(render_params)
|
|
640
|
+
|
|
630
641
|
def cancel_render_on_lambda(self, render_id: str, bucket_name: str) -> None:
|
|
631
642
|
"""Cancel a render started with ``enable_cancellation=True``."""
|
|
632
643
|
s3_client = self._create_s3_client()
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# pylint: disable=missing-module-docstring, missing-final-newline
|
|
2
|
-
VERSION = "4.0.
|
|
2
|
+
VERSION = "4.0.535"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/remotion_lambda.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_get_render_progress_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_render_client_render_media.py
RENAMED
|
File without changes
|
{remotion_lambda-4.0.533 → remotion_lambda-4.0.535}/tests/test_render_client_render_still.py
RENAMED
|
File without changes
|