Skip to content

🎥 Make videos programmatically with React

Merge remote-tracking branch 'origin/main' into fix/lambda-python-async-client

Jonny Burgere97cbc28d728
diff --cc packages/docs/docs/lambda/python.mdx
index 2707176493,3b7a7d7728..e4e856d201
--- a/packages/docs/docs/lambda/python.mdx
+++ b/packages/docs/docs/lambda/python.mdx
@@@ -82,51 -82,28 +82,73 @@@ if render_response
print("Render done!", progress_response.outputFile)
```
+## Asynchronous rendering<AvailableFrom v="4.0.535" />
+
+Use `AsyncRemotionClient` in `asyncio` applications to make requests without blocking the event loop. It accepts the same constructor options as `RemotionClient`, returns the same response objects, and raises the same exceptions.
+
+Await `render_media_on_lambda()`, `render_still_on_lambda()`, `get_render_progress()`, and `cancel_render_on_lambda()`:
+
+```python title="render_media_async.py"
+import asyncio
+import os
+from remotion_lambda import AsyncRemotionClient, RenderMediaParams
+
+
+async def main():
+ client = AsyncRemotionClient(
+ region=os.environ['REMOTION_APP_REGION'],
+ serve_url=os.environ['REMOTION_APP_SERVE_URL'],
+ function_name=os.environ['REMOTION_APP_FUNCTION_NAME'],
+ )
+
+ response = await client.render_media_on_lambda(
+ RenderMediaParams(composition="react-svg")
+ )
+ if response is None:
+ return
+
+ while True:
+ progress = await client.get_render_progress(
+ render_id=response.render_id,
+ bucket_name=response.bucket_name,
+ )
+ if progress is None:
+ return
+ if progress.fatalErrorEncountered:
+ raise RuntimeError(progress.errors)
+ if progress.done:
+ print("Render done!", progress.outputFile)
+ return
+ await asyncio.sleep(1)
+
+
+asyncio.run(main())
+```
+
+Cancelling an awaited request does not stop the AWS request or the render. To cancel a render, start it with `enable_cancellation=True` and await `cancel_render_on_lambda()` with its render ID and bucket name.
+
+ ## Rendering an image sequence<AvailableFrom v="4.0.535" />
+
+ Use `render_frames_on_lambda()` with `RenderFramesParams`. Images default to PNG; the options follow [`renderFramesOnLambda()`](/docs/lambda/renderframesonlambda).
+
+ ```python title="render_frames.py"
+ from remotion_lambda import RenderFramesParams
+
+ render_params = RenderFramesParams(
+ composition="main",
+ frame_range=[0, 99],
+ frames_per_lambda=20,
+ output_prefix="exports/my-sequence/",
+ image_sequence_pattern="element-[frame].[ext]",
+ )
+
+ render_response = client.render_frames_on_lambda(render_params)
+ if render_response:
+ print(render_response.render_id, render_response.bucket_name)
+ ```
+
+ Poll `get_render_progress()` until `done` or `fatalErrorEncountered`. `framesUploaded` reports uploaded frames, and `outputSequence['manifestUrl']` points to the completed manifest. Use `ImageSequenceOutputPrefix(bucket_name=..., key_prefix=..., s3_output_provider=...)` as `output_prefix` to select another bucket or provider.
+
## Configuring the AWS clients
### config?<AvailableFrom v="4.0.380" />