🎥 Make videos programmatically with React
initial documentation and set default values
Alex Fernandezbbd7c17436d4
diff --git a/packages/docs/docs/lambda/go.md b/packages/docs/docs/lambda/go.mdnew file mode 100644index 0000000000..bf22183b37--- /dev/null+++ b/packages/docs/docs/lambda/go.md@@ -0,0 +1,131 @@+---+title: Triggering renders from Go+slug: /lambda/php+sidebar_label: Rendering from Go+crumb: "@remotion/lambda"+---++To trigger a Lambda render using Go, you will need to utilize, a go package. Note the following:++- You first need to [complete the Lambda setup](/docs/lambda/setup).+- Sending large input props (>200KB) is not supported with Go at the moment.+++:::warning+The go package utilised on this example is in early stage of development.+:::++```go title="main.go"+package main++import (+ "fmt"+ "log"+ "os"++ "github.com/go-playground/validator/v10"+ "github.com/joho/godotenv"+ "github.com/remotion-dev/remotion/packages/goclient"+)++type ValidationError struct {+ Field string+ Message string+}++func msgForTag(fe validator.FieldError) string {+ switch fe.Tag() {+ case "required":+ return "This field is required"++ }+ return fe.Error() // default error+}++func main() {++ // Load the environment variables from the .env file+ err := godotenv.Load()+ if err != nil {+ log.Fatal(err)+ }++ serveUrl := os.Getenv("REMOTION_APP_SERVER_URL")+ functionName := os.Getenv("REMOTION_APP_FUNCTION_NAME")+ region := os.Getenv("REMOTION_APP_REGION")++ input := goclient.RemotionOptions{+ ServeUrl: serveUrl,+ FunctionName: functionName,+ Region: region,+ InputProps: map[string]interface{}{+ "data": "Let's play",+ },+ Composition: "main",+ Type: "start",+ Codec: "h264",+ Version: "3.3.78",+ ImageFormat: "jpeg",+ Crf: 1,+ Privacy: "public",+ LogLevel: "info",+ Scale: 1,+ }+ response, error := goclient.RenderMediaOnLambda(input)++ if error != nil {++ validationOut := make([]ValidationError, len(error.(validator.ValidationErrors)))++ for i, fieldError := range error.(validator.ValidationErrors) {+ //println(fieldError.Value().(int))+ validationOut[i] = ValidationError{fieldError.Field(), msgForTag(fieldError)}+ }++ for _, apiError := range validationOut {+ fmt.Printf("%s: %s\n", apiError.Field, apiError.Message)+ }+ return++ }++ var bucketName string+ var renderId string++ output, ok := response.(map[string]interface{})+ if !ok {++ log.Fatal("%s %s", "invalid response format", err)+ }++ for key, value := range output {+ switch key {+ case "bucketName":+ bucketName, _ = value.(string)+ case "renderId":+ renderId, _ = value.(string)++ }+ }++ fmt.Printf("bucketName: %s\nRenderId: %s\n", bucketName, renderId)++}++```++## Reference applications++ Reference projects are available:++- Ensure that [remotion-app](https://github.com/alexfernandez803/remotion-serverless/tree/main/remotion-app) is already deployed on your AWS Account.+++## Checking progress++For retrieving the progress of a Lambda render, you need to send another request to the Lambda function. Currently we do not have instructions for it, as a reference you may see [here](https://github.com/remotion-dev/remotion/blob/main/packages/lambda/src/api/get-render-progress.ts) for the payload that is being sent by the TypeScript SDK.++## See also++- [Using Lambda without IAM user](/docs/lambda/without-iam)+- [Permissions](/docs/lambda/permissions)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 2ac7224e1c..866bd49bd5 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -447,6 +447,7 @@ module.exports = {],},"lambda/php",+ "lambda/go","lambda/serverless-framework-integration","lambda/sqs","lambda/multiple-buckets",diff --git a/packages/goclient-example/main.go b/packages/goclient-example/main.goindex 003409678b..c6b2b75e84 100644--- a/packages/goclient-example/main.go+++ b/packages/goclient-example/main.go@@ -43,40 +43,17 @@ func main() {InputProps: map[string]interface{}{"data": "Let's play",},- Composition: "main",- Type: "start",- Codec: "h264",- Version: "3.3.78",- ImageFormat: "jpeg",- Crf: 1,- EnvVariables: []interface{}{},- Quality: 101,- MaxRetries: 1,- Privacy: "public",- LogLevel: "info",- FrameRange: nil,- OutName: nil,- TimeoutInMilliseconds: 30000,- ChromiumOptions: []interface{}{},- Scale: 1,- EveryNthFrame: 1,- NumberOfGifLoops: 0,- ConcurrencyPerLambda: 1,- DownloadBehavior: map[string]interface{}{- "type": "play-in-browser",- },- Muted: false,- Overwrite: false,- AudioBitrate: nil,- VideoBitrate: nil,- Webhook: nil,- ForceHeight: nil,- ForceWidth: nil,- BucketName: nil,- AudioCodec: nil,- ForceBucketName: nil,+ Composition: "main",+ Type: "start",+ Codec: "h264",+ Version: "3.3.78",+ ImageFormat: "jpeg",+ Crf: 1,+ Privacy: "public",+ LogLevel: "info",+ Scale: 1,}- response, error := goclient.RenderMedia(input)+ response, error := goclient.RenderMediaOnLambda(input)if error != nil {diff --git a/packages/goclient/goclient.go b/packages/goclient/goclient.goindex c019830bbc..adb8ede9f5 100644--- a/packages/goclient/goclient.go+++ b/packages/goclient/goclient.go@@ -60,6 +60,6 @@ func invokeLambda(options RemotionOptions) (map[string]interface{}, error) {return output, nil}-func RenderMedia(input RemotionOptions) (interface{}, error) {+func RenderMediaOnLambda(input RemotionOptions) (interface{}, error) {return invokeLambda(input)}diff --git a/packages/goclient/internalops.go b/packages/goclient/internalops.goindex 6c13bf4203..35c15039d4 100644--- a/packages/goclient/internalops.go+++ b/packages/goclient/internalops.go@@ -22,43 +22,80 @@ func constructInternals(options RemotionOptions) (*internalOptions, error) {}internalParams := &internalOptions{- ServeUrl: options.ServeUrl,- InputProps: inputProps,- Composition: options.Composition,- Region: options.Region,- Type: options.Type,- Version: options.Version,- ImageFormat: options.ImageFormat,- Crf: options.Crf,- EnvVariables: options.EnvVariables,- Quality: options.Quality,- MaxRetries: options.MaxRetries,- Privacy: options.Privacy,- LogLevel: options.LogLevel,- FrameRange: options.FrameRange,- OutName: options.OutName,- TimeoutInMilliseconds: options.TimeoutInMilliseconds,- ChromiumOptions: options.ChromiumOptions,- Scale: options.Scale,- EveryNthFrame: options.EveryNthFrame,- NumberOfGifLoops: options.NumberOfGifLoops,- ConcurrencyPerLambda: options.ConcurrencyPerLambda,- DownloadBehavior: options.DownloadBehavior,- Muted: options.Muted,- Overwrite: options.Overwrite,- AudioBitrate: options.AudioBitrate,- VideoBitrate: options.VideoBitrate,- Webhook: options.Webhook,- ForceHeight: options.ForceHeight,- ForceWidth: options.ForceWidth,- BucketName: options.BucketName,- AudioCodec: options.AudioCodec,- ForceBucketName: options.ForceBucketName,+ ServeUrl: options.ServeUrl,+ InputProps: inputProps,+ Composition: options.Composition,+ Region: options.Region,+ Type: options.Type,+ Version: options.Version,+ ImageFormat: options.ImageFormat,+ Crf: options.Crf,+ EnvVariables: options.EnvVariables,+ Privacy: options.Privacy,+ LogLevel: options.LogLevel,+ FrameRange: options.FrameRange,+ OutName: options.OutName,+ EveryNthFrame: options.EveryNthFrame,+ DownloadBehavior: options.DownloadBehavior,+ AudioBitrate: options.AudioBitrate,+ VideoBitrate: options.VideoBitrate,+ Webhook: options.Webhook,+ ForceHeight: options.ForceHeight,+ ForceWidth: options.ForceWidth,+ BucketName: options.BucketName,+ AudioCodec: options.AudioCodec,+ ForceBucketName: options.ForceBucketName,}+ /*+ Default values+ */++ if &options.Scale == nil {+ internalParams.Scale = 1+ }+ if &options.Crf == nil {+ internalParams.Crf = 1+ }if &options.Codec == nil {internalParams.Codec = "h264"}+ if &options.MaxRetries == nil {+ internalParams.MaxRetries = 3+ }+ if &options.Quality == nil {+ internalParams.Quality = 80+ }+ if &options.Scale == nil {+ internalParams.Scale = 1+ }+ if &options.Muted == nil {+ internalParams.Muted = false+ }+ if &options.Overwrite == nil {+ internalParams.Overwrite = false+ }+ if &options.ConcurrencyPerLambda == nil {+ internalParams.ConcurrencyPerLambda = 1+ }+ if &options.TimeoutInMilliseconds == nil {+ internalParams.TimeoutInMilliseconds = 30000+ }+ if &options.NumberOfGifLoops == nil {+ internalParams.NumberOfGifLoops = 0+ }+ if &options.DownloadBehavior == nil {+ internalParams.DownloadBehavior = map[string]interface{}{+ "type": "play-in-browser",+ }+ }+ if &options.ChromiumOptions == nil {+ internalParams.ChromiumOptions = []interface{}{}+ }++ if &options.EnvVariables == nil {+ internalParams.EnvVariables = []interface{}{}+ }return internalParams, nil}diff --git a/packages/goclient/models.go b/packages/goclient/models.goindex 95295b37e6..02ac531bda 100644--- a/packages/goclient/models.go+++ b/packages/goclient/models.go@@ -25,7 +25,7 @@ type RemotionOptions struct {ImageFormat string `json:"imageFormat"`Crf int `json:"crf"`EnvVariables []interface{} `json:"envVariables"`- Quality int `json:"quality" validate:"required,min=1,max=100"`+ Quality int `json:"quality"`MaxRetries int `json:"maxRetries"`Privacy PrivacyType `json:"privacy" validate:"required,privacyTypeValidator"`LogLevel string `json:"logLevel"`