Skip to content

🎥 Make videos programmatically with React

Add Lambda image sequence rendering to PHP, Python, Go, and Ruby SDKs

Jonny Burger589ef3eaf836
diff --git a/packages/docs/docs/lambda/go.mdx b/packages/docs/docs/lambda/go.mdx
index d46c9e49b4..c6914aac00 100644
--- a/packages/docs/docs/lambda/go.mdx
+++ b/packages/docs/docs/lambda/go.mdx
@@ -116,6 +116,30 @@ func main() {
}
```
+## Rendering an image sequence<AvailableFrom v="4.0.535" />
+
+Use `RenderFramesOnLambda()` with `RenderFramesOptions`. Images default to PNG; the options follow [`renderFramesOnLambda()`](/docs/lambda/renderframesonlambda).
+
+```go title="render-frames.go"
+renderResponse, err := lambda_go_sdk.RenderFramesOnLambda(lambda_go_sdk.RenderFramesOptions{
+ ServeUrl: serveUrl,
+ FunctionName: functionName,
+ Region: region,
+ Composition: "main",
+ FrameRange: [2]int{0, 99},
+ FramesPerLambda: new(20),
+ OutputPrefix: "exports/my-sequence/",
+ ImageSequencePattern: "element-[frame].[ext]",
+})
+if err != nil {
+ log.Fatal(err)
+}
+
+fmt.Println(renderResponse.RenderId, renderResponse.BucketName)
+```
+
+Poll `GetRenderProgress()` until `Done` or `FatalErrorEncountered`. `FramesUploaded` reports uploaded frames, and `OutputSequence.ManifestUrl` points to the completed manifest. Pass an `ImageSequenceOutputPrefix` as `OutputPrefix` to select another bucket or provider.
+
## Cancelling a render<AvailableFrom v="4.0.515" />
Set `EnableCancellation` when starting the render, then pass its response to `CancelRenderOnLambda()`:
diff --git a/packages/docs/docs/lambda/php.mdx b/packages/docs/docs/lambda/php.mdx
index fc93ab7f73..65bbe94a1e 100644
--- a/packages/docs/docs/lambda/php.mdx
+++ b/packages/docs/docs/lambda/php.mdx
@@ -87,6 +87,27 @@ while (!$renderProgressResponse->done) {
print_r("Render is done!\n");
```
+## Rendering an image sequence<AvailableFrom v="4.0.535" />
+
+Use `renderFramesOnLambda()` with `RenderFramesParams`. Images default to PNG; the options follow [`renderFramesOnLambda()`](/docs/lambda/renderframesonlambda).
+
+```php title="render-frames.php"
+use Remotion\LambdaPhp\RenderFramesParams;
+
+$params = new RenderFramesParams(
+ composition: 'main',
+ frameRange: [0, 99],
+ framesPerLambda: 20,
+ outputPrefix: 'exports/my-sequence/',
+ imageSequencePattern: 'element-[frame].[ext]',
+);
+
+$renderResponse = $client->renderFramesOnLambda($params);
+print_r($renderResponse);
+```
+
+Poll `getRenderProgress()` until `done` or `fatalErrorEncountered`. `framesUploaded` reports uploaded frames, and `outputSequence['manifestUrl']` points to the completed manifest. `outputPrefix` also accepts an array with `bucketName`, `keyPrefix`, and optional `s3OutputProvider`.
+
## Cancelling a render<AvailableFrom v="4.0.515" />
Enable cancellation before starting the render, then call `cancelRenderOnLambda()`:
diff --git a/packages/docs/docs/lambda/python.mdx b/packages/docs/docs/lambda/python.mdx
index aadaaf1599..3b7a7d7728 100644
--- a/packages/docs/docs/lambda/python.mdx
+++ b/packages/docs/docs/lambda/python.mdx
@@ -82,6 +82,28 @@ if render_response:
print("Render done!", progress_response.outputFile)
```
+## 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" />
diff --git a/packages/docs/docs/lambda/ruby.mdx b/packages/docs/docs/lambda/ruby.mdx
index fbece9dd88..2bbeb683c7 100644
--- a/packages/docs/docs/lambda/ruby.mdx
+++ b/packages/docs/docs/lambda/ruby.mdx
@@ -14,7 +14,7 @@ The version should be the same version of the `@remotion/lambda` NPM package ver
## Notes
- This module is experimental and might have breaking changes in minor versions. Check on this page for up-to-date examples.
-- The implemented methods are [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda), [`getRenderProgressOnLambda()`](/docs/lambda/getrenderprogress), and [`cancelRenderOnLambda()`](/docs/lambda/cancelrenderonlambda).
+- The implemented methods are [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), [`renderFramesOnLambda()`](/docs/lambda/renderframesonlambda), [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda), [`getRenderProgressOnLambda()`](/docs/lambda/getrenderprogress), and [`cancelRenderOnLambda()`](/docs/lambda/cancelrenderonlambda).
- We will maintain the Ruby SDK to ensure the fields stay in sync with the Node.js functions.
- The fields in the input payload are `snake_case` versions of the Node.js field names.
- Nested field names, e.g. `s3_output_provder.accessKeyId` have the original `camelCase` capitalization.
@@ -58,6 +58,26 @@ while true
end
```
+## Rendering an image sequence<AvailableFrom v="4.0.535" />
+
+Use `get_render_frames_on_lambda_payload()` and `render_frames_on_lambda()`. Images default to PNG; the options follow [`renderFramesOnLambda()`](/docs/lambda/renderframesonlambda).
+
+```ruby title="Rendering an image sequence from Ruby"
+payload = get_render_frames_on_lambda_payload(
+ composition: "main",
+ serve_url: ENV.fetch('REMOTION_APP_SERVE_URL'),
+ frame_range: [0, 99],
+ frames_per_lambda: 20,
+ output_prefix: "exports/my-sequence/",
+ image_sequence_pattern: "element-[frame].[ext]",
+)
+
+res = client.render_frames_on_lambda(function_name, payload)
+puts res
+```
+
+Poll `get_render_progress()` until `done` or `fatalErrorEncountered`. `framesUploaded` reports uploaded frames, and `outputSequence['manifestUrl']` points to the completed manifest. `output_prefix` also accepts a hash with `bucketName`, `keyPrefix`, and optional `s3OutputProvider`.
+
## Cancelling a render<AvailableFrom v="4.0.515" />
Enable cancellation in the render payload, then call `cancel_render_on_lambda()`:
diff --git a/packages/lambda-go/internalops.go b/packages/lambda-go/internalops.go
index c174a31be4..1de15b0e6c 100644
--- a/packages/lambda-go/internalops.go
+++ b/packages/lambda-go/internalops.go
@@ -52,7 +52,7 @@ func constructRenderInternals(options *RemotionOptions) (*renderInternalOptions,
RendererFunctionName: &options.RendererFunctionName,
DeleteAfter: options.DeleteAfter,
Type: "start",
- Output: map[string]string{"type": "media"},
+ Output: map[string]interface{}{"type": "media"},
JpegQuality: jpegQuality,
}
@@ -63,11 +63,11 @@ func constructRenderInternals(options *RemotionOptions) (*renderInternalOptions,
if options.RendererFunctionName == "" {
internalParams.RendererFunctionName = nil
}
- if options.Codec == "" {
- internalParams.Codec = "h264"
- } else {
- internalParams.Codec = options.Codec
+ codec := options.Codec
+ if codec == "" {
+ codec = "h264"
}
+ internalParams.Codec = &codec
if options.EveryNthFrame == 0 {
internalParams.EveryNthFrame = 1
} else {
@@ -101,7 +101,7 @@ func constructRenderInternals(options *RemotionOptions) (*renderInternalOptions,
if options.Scale == 0 {
internalParams.Scale = 1
} else {
- internalParams.Scale = options.Scale
+ internalParams.Scale = float64(options.Scale)
}
if options.MaxRetries == 0 {
@@ -129,7 +129,7 @@ func constructRenderInternals(options *RemotionOptions) (*renderInternalOptions,
} else {
internalParams.TimeoutInMilliseconds = options.TimeoutInMilliseconds
}
- if internalParams.Codec == "gif" {
+ if codec == "gif" {
internalParams.NumberOfGifLoops = &options.NumberOfGifLoops
}
diff --git a/packages/lambda-go/invocations.go b/packages/lambda-go/invocations.go
index 4ba196f055..b5df3b53a2 100644
--- a/packages/lambda-go/invocations.go
+++ b/packages/lambda-go/invocations.go
@@ -9,7 +9,18 @@ import (
"github.com/aws/aws-sdk-go-v2/service/lambda"
)
-func invokeRenderLambda(options RemotionOptions) (*RemotionRenderResponse, error) {
+func invokeRenderLambda(options RemotionOptions, sequenceOptions *RenderFramesOptions) (*RemotionRenderResponse, error) {
+ if sequenceOptions != nil {
+ if options.ImageFormat == "" {
+ options.ImageFormat = "png"
+ }
+ if options.ImageFormat != "png" && options.ImageFormat != "jpeg" {
+ return nil, fmt.Errorf("imageFormat must be \"png\" or \"jpeg\"")
+ }
+ if sequenceOptions.JpegQuality != nil && options.ImageFormat != "jpeg" {
+ return nil, fmt.Errorf("jpegQuality can only be passed with imageFormat: \"jpeg\"")
+ }
+ }
awsConfig, configError := awsconfig.LoadDefaultConfig(
context.Background(),
@@ -26,6 +37,33 @@ func invokeRenderLambda(options RemotionOptions) (*RemotionRenderResponse, error
return nil, validateError
}
+ if sequenceOptions != nil {
+ var pattern interface{}
+ if sequenceOptions.ImageSequencePattern != "" {
+ pattern = sequenceOptions.ImageSequencePattern
+ }
+ internalParams.Output = map[string]interface{}{
+ "type": "sequence",
+ "outputPrefix": sequenceOptions.OutputPrefix,
+ "imageSequencePattern": pattern,
+ }
+ internalParams.Codec = nil
+ internalParams.Muted = true
+ internalParams.FramesPerLambda = sequenceOptions.FramesPerLambda
+ if sequenceOptions.MaxRetries != nil {
+ internalParams.MaxRetries = *sequenceOptions.MaxRetries
+ }
+ if sequenceOptions.JpegQuality != nil {
+ internalParams.JpegQuality = *sequenceOptions.JpegQuality
+ }
+ if sequenceOptions.Scale != 0 {
+ internalParams.Scale = sequenceOptions.Scale
+ }
+ if sequenceOptions.ForceBucketName != "" {
+ internalParams.BucketName = sequenceOptions.ForceBucketName
+ }
+ }
+
internalParamJsonObject, marshallingError := json.Marshal(internalParams)
if marshallingError != nil {
return nil, fmt.Errorf("could not serialize render parameters: %w", marshallingError)
diff --git a/packages/lambda-go/lambda_go_sdk.go b/packages/lambda-go/lambda_go_sdk.go
index c53ce968d1..c5a6f84bfd 100644
--- a/packages/lambda-go/lambda_go_sdk.go
+++ b/packages/lambda-go/lambda_go_sdk.go
@@ -3,7 +3,46 @@ package lambda_go_sdk
import "github.com/go-playground/validator/v10"
func RenderMediaOnLambda(input RemotionOptions) (*RemotionRenderResponse, error) {
- return invokeRenderLambda(input)
+ return invokeRenderLambda(input, nil)
+}
+
+// RenderFramesOnLambda starts an image sequence render. Track it with GetRenderProgress.
+func RenderFramesOnLambda(input RenderFramesOptions) (*RemotionRenderResponse, error) {
+ return invokeRenderLambda(RemotionOptions{
+ ServeUrl: input.ServeUrl,
+ FunctionName: input.FunctionName,
+ Region: input.Region,
+ Composition: input.Composition,
+ InputProps: input.InputProps,
+ ImageFormat: input.ImageFormat,
+ FrameRange: input.FrameRange,
+ Concurrency: input.Concurrency,
+ ConcurrencyPerLambda: input.ConcurrencyPerLambda,
+ EveryNthFrame: input.EveryNthFrame,
+ EnvVariables: input.EnvVariables,
+ Privacy: input.Privacy,
+ ChromiumOptions: input.ChromiumOptions,
+ DownloadBehavior: input.DownloadBehavior,
+ Overwrite: input.Overwrite,
+ Webhook: input.Webhook,
+ ForceWidth: input.ForceWidth,
+ ForceHeight: input.ForceHeight,
+ ForceFps: input.ForceFps,
+ ForceDurationInFrames: input.ForceDurationInFrames,
+ RendererFunctionName: input.RendererFunctionName,
+ ForceBucketName: input.ForceBucketName,
+ ForcePathStyle: input.ForcePathStyle,
+ StorageClass: input.StorageClass,
+ IsProduction: input.IsProduction,
+ LicenseKey: input.LicenseKey,
+ LogLevel: input.LogLevel,
+ TimeoutInMilliseconds: input.TimeoutInMilliseconds,
+ DeleteAfter: input.DeleteAfter,
+ OffthreadVideoCacheSizeInBytes: input.OffthreadVideoCacheSizeInBytes,
+ OffthreadVideoThreads: input.OffthreadVideoThreads,
+ MediaCacheSizeInBytes: input.MediaCacheSizeInBytes,
+ EnableCancellation: input.EnableCancellation,
+ }, &input)
}
func GetRenderProgress(input RenderConfig) (*RenderProgress, error) {
diff --git a/packages/lambda-go/models.go b/packages/lambda-go/models.go
index 6add33b0c5..e1ceb937cb 100644
--- a/packages/lambda-go/models.go
+++ b/packages/lambda-go/models.go
@@ -59,16 +59,66 @@ type RemotionOptions struct {
SampleRate int `json:"sampleRate"`
}
+// RenderFramesOptions configures a PNG or JPEG image sequence render.
+type RenderFramesOptions struct {
+ ServeUrl string `json:"serveUrl" validate:"required"`
+ FunctionName string `json:"functionName" validate:"required"`
+ Region string `json:"region" validate:"required"`
+ Composition string `json:"composition" validate:"required"`
+ InputProps interface{} `json:"inputProps"`
+ ImageFormat string `json:"imageFormat"`
+ OutputPrefix interface{} `json:"outputPrefix"`
+ ImageSequencePattern string `json:"imageSequencePattern"`
+ JpegQuality *int `json:"jpegQuality"`
+ FrameRange interface{} `json:"frameRange"`
+ FramesPerLambda *int `json:"framesPerLambda"`
+ Concurrency *int `json:"concurrency"`
+ ConcurrencyPerLambda int `json:"concurrencyPerLambda"`
+ EveryNthFrame int `json:"everyNthFrame"`
+ EnvVariables interface{} `json:"envVariables"`
+ Privacy string `json:"privacy"`
+ ChromiumOptions interface{} `json:"chromiumOptions"`
+ Scale float64 `json:"scale"`
+ DownloadBehavior map[string]interface{} `json:"downloadBehavior"`
+ Overwrite bool `json:"overwrite"`
+ MaxRetries *int `json:"maxRetries"`
+ Webhook interface{} `json:"webhook"`
+ ForceWidth interface{} `json:"forceWidth"`
+ ForceHeight interface{} `json:"forceHeight"`
+ ForceFps interface{} `json:"forceFps"`
+ ForceDurationInFrames interface{} `json:"forceDurationInFrames"`
+ RendererFunctionName string `json:"rendererFunctionName"`
+ ForceBucketName string `json:"forceBucketName"`
+ ForcePathStyle bool `json:"forcePathStyle"`
+ StorageClass interface{} `json:"storageClass"`
+ IsProduction *bool `json:"isProduction"`
+ LicenseKey interface{} `json:"licenseKey"`
+ LogLevel string `json:"logLevel"`
+ TimeoutInMilliseconds int `json:"timeoutInMilliseconds"`
+ DeleteAfter *string `json:"deleteAfter"`
+ OffthreadVideoCacheSizeInBytes interface{} `json:"offthreadVideoCacheSizeInBytes"`
+ OffthreadVideoThreads interface{} `json:"offthreadVideoThreads"`
+ MediaCacheSizeInBytes interface{} `json:"mediaCacheSizeInBytes"`
+ EnableCancellation bool `json:"enableCancellation"`
+}
+
+// ImageSequenceOutputPrefix selects a custom bucket or S3-compatible provider.
+type ImageSequenceOutputPrefix struct {
+ BucketName string `json:"bucketName"`
+ KeyPrefix string `json:"keyPrefix"`
+ S3OutputProvider interface{} `json:"s3OutputProvider"`
+}
+
type renderInternalOptions struct {
EnableCancellation bool `json:"enableCancellation"`
RendererFunctionName *string `json:"rendererFunctionName"`
- FramesPerLambda *string `json:"framesPerLambda"`
+ FramesPerLambda *int `json:"framesPerLambda"`
Composition string `json:"composition" validate:"required"`
ServeUrl string `json:"serveUrl" validate:"required"`
InputProps interface{} `json:"inputProps"`
Type string `json:"type,omitempty"`
- Output map[string]string `json:"output"`
- Codec string `json:"codec"`
+ Output map[string]interface{} `json:"output"`
+ Codec *string `json:"codec"`
ProResProfile interface{} `json:"proResProfile"`
PixelFormat interface{} `json:"pixelFormat"`
ImageFormat string `json:"imageFormat"`
@@ -84,7 +134,7 @@ type renderInternalOptions struct {
OutName interface{} `json:"outName"`
TimeoutInMilliseconds int `json:"timeoutInMilliseconds"`
ChromiumOptions interface{} `json:"chromiumOptions"`
- Scale int `json:"scale"`
+ Scale float64 `json:"scale"`
EveryNthFrame int `json:"everyNthFrame"`
NumberOfGifLoops *int `json:"numberOfGifLoops,omitempty"`
ConcurrencyPerLambda int `json:"concurrencyPerLambda"`
@@ -183,24 +233,35 @@ type FunctionErrorInfo struct {
}
type RenderProgress struct {
- OverallProgress float64 `json:"overallProgress"`
- Chunks int `json:"chunks"`
- Done bool `json:"done"`
- EncodingStatus *EncodingStatus `json:"encodingStatus,omitempty"`
- Costs *Costs `json:"costs,omitempty"`
- RenderId string `json:"renderId"`
- RenderMetadata *RenderMetadata `json:"renderMetadata,omitempty"`
- OutputFile *string `json:"outputFile,omitempty"`
- OutKey *string `json:"outKey,omitempty"`
- TimeToFinish *int `json:"timeToFinish,omitempty"`
- Errors []FunctionErrorInfo `json:"errors,omitempty"`
- FatalErrorEncountered bool `json:"fatalErrorEncountered"`
- CurrentTime int64 `json:"currentTime"`
- RenderSize int64 `json:"renderSize"`
- OutputSizeInBytes *int64 `json:"outputSizeInBytes,omitempty"`
- LambdasInvoked int `json:"lambdasInvoked"`
- FramesRendered *int `json:"framesRendered,omitempty"`
- MostExpensiveFrameRanges []FrameRange `json:"mostExpensiveFrameRanges,omitempty"`
+ OverallProgress float64 `json:"overallProgress"`
+ Chunks int `json:"chunks"`
+ Done bool `json:"done"`
+ EncodingStatus *EncodingStatus `json:"encodingStatus,omitempty"`
+ Costs *Costs `json:"costs,omitempty"`
+ RenderId string `json:"renderId"`
+ RenderMetadata *RenderMetadata `json:"renderMetadata,omitempty"`
+ OutputFile *string `json:"outputFile,omitempty"`
+ OutputSequence *ImageSequenceOutput `json:"outputSequence"`
+ FramesUploaded *int `json:"framesUploaded"`
+ OutKey *string `json:"outKey,omitempty"`
+ TimeToFinish *int `json:"timeToFinish,omitempty"`
+ Errors []FunctionErrorInfo `json:"errors,omitempty"`
+ FatalErrorEncountered bool `json:"fatalErrorEncountered"`
+ CurrentTime int64 `json:"currentTime"`
+ RenderSize int64 `json:"renderSize"`
+ OutputSizeInBytes *int64 `json:"outputSizeInBytes,omitempty"`
+ LambdasInvoked int `json:"lambdasInvoked"`
+ FramesRendered *int `json:"framesRendered,omitempty"`
+ MostExpensiveFrameRanges []FrameRange `json:"mostExpensiveFrameRanges,omitempty"`
+}
+
+type ImageSequenceOutput struct {
+ BucketName string `json:"bucketName"`
+ KeyPrefix string `json:"keyPrefix"`
+ ManifestKey string `json:"manifestKey"`
+ ManifestUrl string `json:"manifestUrl"`
+ ImageFormat string `json:"imageFormat"`
+ FrameCount int `json:"frameCount"`
}
type EncodingStatus struct {
diff --git a/packages/lambda-php/src/GetRenderProgressResponse.php b/packages/lambda-php/src/GetRenderProgressResponse.php
index 4dab3d034b..25d021f65e 100644
--- a/packages/lambda-php/src/GetRenderProgressResponse.php
+++ b/packages/lambda-php/src/GetRenderProgressResponse.php
@@ -9,6 +9,9 @@ class GetRenderProgressResponse
public float $overallProgress;
public string $type;
public ?string $outputFile;
+ public ?array $outputSequence = null;
+ public ?int $framesUploaded = null;
+ public ?int $framesRendered = null;
public int $lambdasInvoked;
public int $renderSize;
public int $currentTime;
diff --git a/packages/lambda-php/src/PHPClient.php b/packages/lambda-php/src/PHPClient.php
index ffe792696c..33436465ad 100644
--- a/packages/lambda-php/src/PHPClient.php
+++ b/packages/lambda-php/src/PHPClient.php
@@ -274,6 +274,11 @@ class PHPClient
return $this->handleLambdaResponseRender($result);
}
+ public function renderFramesOnLambda(RenderFramesParams $render): RenderMediaOnLambdaResponse
+ {
+ return $this->renderMediaOnLambda($render);
+ }
+
public function makeRenderProgressPayload(string $renderId, string $bucketName, string $logLevel = "info", $forcePathStyle = false)
{
return json_encode([
@@ -403,6 +408,9 @@ class PHPClient
$classResponse->outBucket = $response['outBucket'];
$classResponse->outKey = $response['outKey'];
$classResponse->outputFile = $response['outputFile'];
+ $classResponse->outputSequence = $response['outputSequence'] ?? null;
+ $classResponse->framesUploaded = $response['framesUploaded'] ?? null;
+ $classResponse->framesRendered = $response['framesRendered'] ?? null;
$classResponse->overallProgress = $response['overallProgress'];
$classResponse->renderSize = $response['renderSize'];
$classResponse->timeToFinish = $response['timeToFinish'];
diff --git a/packages/lambda-php/src/RenderFramesParams.php b/packages/lambda-php/src/RenderFramesParams.php
new file mode 100644
index 0000000000..b2a74febad
--- /dev/null
+++ b/packages/lambda-php/src/RenderFramesParams.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Remotion\LambdaPhp;
+
+use InvalidArgumentException;
+
+class RenderFramesParams extends RenderParams
+{
+ private string|array|null $outputPrefix;
+ private ?string $imageSequencePattern;
+ private bool $jpegQualityProvided;
+
+ public function __construct(
+ string|array|null $outputPrefix = null,
+ ?string $imageSequencePattern = null,
+ string $imageFormat = 'png',
+ int|array|null $frameRange = null,
+ ...$options
+ ) {
+ parent::__construct(...array_merge($options, ['imageFormat' => $imageFormat]));
+ $this->frameRange = $frameRange;
+ $this->outputPrefix = $outputPrefix;
+ $this->imageSequencePattern = $imageSequencePattern;
+ $this->jpegQualityProvided = array_key_exists('jpegQuality', $options);
+ }
+
+ public function setOutputPrefix(string|array|null $outputPrefix)
+ {
+ $this->outputPrefix = $outputPrefix;
+ return $this;
+ }
+
+ public function setImageSequencePattern(?string $imageSequencePattern)
+ {
+ $this->imageSequencePattern = $imageSequencePattern;
+ return $this;
+ }
+
+ public function setJpegQuality($jpegQuality)
+ {
+ $this->jpegQualityProvided = true;
+ return parent::setJpegQuality($jpegQuality);
+ }
+
+ public function serializeParams()
+ {
+ if (!in_array($this->getImageFormat(), ['png', 'jpeg'], true)) {
+ throw new InvalidArgumentException('imageFormat must be "png" or "jpeg".');
+ }
+ if ($this->jpegQualityProvided && $this->getImageFormat() !== 'jpeg') {
+ throw new InvalidArgumentException('jpegQuality can only be passed with imageFormat: "jpeg".');
+ }
+
+ $parameters = parent::serializeParams();
+ $parameters['codec'] = null;
+ $parameters['muted'] = true;
+ $parameters['outName'] = null;
+ $parameters['numberOfGifLoops'] = null;
+ $parameters['output'] = [
+ 'type' => 'sequence',
+ 'outputPrefix' => $this->outputPrefix,
+ 'imageSequencePattern' => $this->imageSequencePattern,
+ ];
+ return $parameters;
+ }
+}
diff --git a/packages/lambda-python/remotion_lambda/__init__.py b/packages/lambda-python/remotion_lambda/__init__.py
index c4123d092b..94d304fc91 100644
--- a/packages/lambda-python/remotion_lambda/__init__.py
+++ b/packages/lambda-python/remotion_lambda/__init__.py
@@ -1,5 +1,7 @@
# pylint: disable=missing-module-docstring
from .models import (
+ RenderFramesParams,
+ ImageSequenceOutputPrefix,
RenderMediaParams,
RenderMediaProgress,
RenderMediaResponse,
diff --git a/packages/lambda-python/remotion_lambda/models.py b/packages/lambda-python/remotion_lambda/models.py
index f4daf5c769..cec443e75d 100644
--- a/packages/lambda-python/remotion_lambda/models.py
+++ b/packages/lambda-python/remotion_lambda/models.py
@@ -436,6 +436,64 @@ class RenderMediaParams:
return parameters
+@dataclass
+class ImageSequenceOutputPrefix:
+ """Destination bucket and prefix for an image sequence."""
+
+ bucket_name: str
+ key_prefix: str
+ s3_output_provider: Optional[CustomCredentials] = None
+
+ def serialize_params(self) -> Dict:
+ """Convert the destination to the Lambda payload format."""
+ return {
+ 'bucketName': self.bucket_name,
+ 'keyPrefix': self.key_prefix,
+ 's3OutputProvider': (
+ self.s3_output_provider.serialize_params()
+ if self.s3_output_provider is not None else None
+ ),
+ }
+
+
+@dataclass
+class RenderFramesParams(RenderMediaParams):
+ """Parameters for rendering a PNG or JPEG image sequence."""
+
+ codec: Optional[str] = None
+ image_format: Literal['png', 'jpeg'] = 'png'
+ jpeg_quality: Optional[int] = None
+ frame_range: Optional[Union[int, List[int]]] = None
+ output_prefix: Optional[Union[str, ImageSequenceOutputPrefix]] = None
+ image_sequence_pattern: Optional[str] = None
+
+ def serialize_params(self) -> Dict:
+ """Convert the sequence parameters to the Lambda payload format."""
+ if self.image_format not in ('png', 'jpeg'):
+ raise ValueError('image_format must be "png" or "jpeg".')
+ if self.jpeg_quality is not None and self.image_format != 'jpeg':
+ raise ValueError('jpeg_quality can only be passed with image_format="jpeg".')
+
+ parameters = super().serialize_params()
+ parameters.update({
+ 'codec': None,
+ 'muted': True,
+ 'outName': None,
+ 'numberOfGifLoops': None,
+ 'jpegQuality': self.jpeg_quality if self.jpeg_quality is not None else 80,
+ 'output': {
+ 'type': 'sequence',
+ 'outputPrefix': (
+ self.output_prefix.serialize_params()
+ if isinstance(self.output_prefix, ImageSequenceOutputPrefix)
+ else self.output_prefix
+ ),
+ 'imageSequencePattern': self.image_sequence_pattern,
+ },
+ })
+ return parameters
+
+
@dataclass
class RenderStillParams:
"""
@@ -590,3 +648,5 @@ class RenderMediaProgress:
outputSizeInBytes: Optional[int] = None
lambdasInvoked: int = 0
framesRendered: Optional[int] = None
+ framesUploaded: Optional[int] = None
+ outputSequence: Optional[Dict[str, Any]] = None
diff --git a/packages/lambda-python/remotion_lambda/remotionclient.py b/packages/lambda-python/remotion_lambda/remotionclient.py
index 9ba127cb1d..96fe1caceb 100644
--- a/packages/lambda-python/remotion_lambda/remotionclient.py
+++ b/packages/lambda-python/remotion_lambda/remotionclient.py
@@ -17,6 +17,7 @@ from botocore.response import StreamingBody # For Lambda payload
from .models import (
CostsInfo,
CustomCredentials,
+ RenderFramesParams,
RenderMediaParams,
RenderMediaProgress,
RenderMediaResponse,
@@ -627,6 +628,12 @@ class RemotionClient:
return None
+ def render_frames_on_lambda(
+ self, render_params: RenderFramesParams
+ ) -> Optional[RenderMediaResponse]:
+ """Start an image sequence render and track it with get_render_progress()."""
+ return self.render_media_on_lambda(render_params)
+
def cancel_render_on_lambda(self, render_id: str, bucket_name: str) -> None:
"""Cancel a render started with ``enable_cancellation=True``."""
s3_client = self._create_s3_client()
diff --git a/packages/lambda-ruby/lib/remotion_lambda.rb b/packages/lambda-ruby/lib/remotion_lambda.rb
index 7ecf2e0544..537b8f564c 100644
--- a/packages/lambda-ruby/lib/remotion_lambda.rb
+++ b/packages/lambda-ruby/lib/remotion_lambda.rb
@@ -3,6 +3,7 @@ require 'json'
require 'logger'
require_relative 'remotion_lambda/version'
require_relative 'remotion_lambda/render_media_on_lambda_payload'
+require_relative 'remotion_lambda/render_frames_on_lambda_payload'
require_relative 'remotion_lambda/render_progress_payload'
require_relative 'remotion_lambda/render_still_on_lambda_payload'
require_relative 'remotion_lambda/s3_output_provider'
diff --git a/packages/lambda-ruby/lib/remotion_lambda/render_frames_on_lambda_payload.rb b/packages/lambda-ruby/lib/remotion_lambda/render_frames_on_lambda_payload.rb
new file mode 100644
index 0000000000..773880a142
--- /dev/null
+++ b/packages/lambda-ruby/lib/remotion_lambda/render_frames_on_lambda_payload.rb
@@ -0,0 +1,33 @@
+require_relative 'render_media_on_lambda_payload'
+
+def get_render_frames_on_lambda_payload(
+ image_format: 'png',
+ jpeg_quality: nil,
+ output_prefix: nil,
+ image_sequence_pattern: nil,
+ **options
+)
+ unless ['png', 'jpeg'].include?(image_format)
+ raise ArgumentError, 'image_format must be "png" or "jpeg".'
+ end
+ if !jpeg_quality.nil? && image_format != 'jpeg'
+ raise ArgumentError, 'jpeg_quality can only be passed with image_format: "jpeg".'
+ end
+
+ payload = get_render_media_on_lambda_payload(
+ **options,
+ codec: nil,
+ image_format: image_format,
+ jpeg_quality: jpeg_quality.nil? ? 80 : jpeg_quality,
+ muted: true,
+ out_name: nil,
+ number_of_gif_loops: nil,
+ download_behavior: options[:download_behavior] || {type: 'play-in-browser'}
+ )
+ payload[:output] = {
+ type: 'sequence',
+ outputPrefix: output_prefix,
+ imageSequencePattern: image_sequence_pattern
+ }
+ payload
+end
diff --git a/packages/lambda-ruby/lib/remotion_lambda/sdk.rb b/packages/lambda-ruby/lib/remotion_lambda/sdk.rb
index ee35317035..213d75fde8 100644
--- a/packages/lambda-ruby/lib/remotion_lambda/sdk.rb
+++ b/packages/lambda-ruby/lib/remotion_lambda/sdk.rb
@@ -31,6 +31,12 @@ module RemotionLambda
body
end
+ def render_frames_on_lambda(function_name, payload)
+ body = invoke(function_name, payload)
+ raise "Failed to call renderFramesOnLambda: #{body['message']}" if body["type"] == "error"
+ body
+ end
+
def render_still_on_lambda(function_name, payload)
body = invoke(function_name, payload)
raise "Failed to call renderStillOnLambda: #{body['message']}" if body["type"] == "error"
@@ -81,7 +87,7 @@ module RemotionLambda
if @aws_profile
Aws::SharedCredentials.new(profile_name: @aws_profile)
else
- Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
+ Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'], ENV['AWS_SESSION_TOKEN'])
end
end
end