🎥 Make videos programmatically with React
call render
Alex Fernandeza2cb21666bb3
diff --git a/packages/goclient-example/go.mod b/packages/goclient-example/go.modindex 220b63e376..8f731c755c 100644--- a/packages/goclient-example/go.mod+++ b/packages/goclient-example/go.mod@@ -4,7 +4,10 @@ go 1.20replace github.com/remotion-dev/remotion/packages/goclient => ../goclient-require github.com/remotion-dev/remotion/packages/goclient v0.0.0-00010101000000-000000000000+require (+ github.com/joho/godotenv v1.5.1+ github.com/remotion-dev/remotion/packages/goclient v0.0.0-00010101000000-000000000000+)require (github.com/aws/aws-sdk-go v1.44.249 // indirectdiff --git a/packages/goclient-example/go.sum b/packages/goclient-example/go.sumindex d74ca1624b..a934b86c6a 100644--- a/packages/goclient-example/go.sum+++ b/packages/goclient-example/go.sum@@ -6,6 +6,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Ygithub.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=+github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=+github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=diff --git a/packages/goclient-example/main.go b/packages/goclient-example/main.goindex dbb894bbf9..8ffccc99e6 100644--- a/packages/goclient-example/main.go+++ b/packages/goclient-example/main.go@@ -2,17 +2,63 @@ package mainimport ("log"+ "os"+ "github.com/joho/godotenv""github.com/remotion-dev/remotion/packages/goclient")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")+ bucketName := os.Getenv("REMOTION_APP_BUCKET")+input := &goclient.RemotionOptions{- // Set the input parameters here+ ServeUrl: serveUrl,+ FunctionName: functionName,+ Region: region,+ InputProps: nil,+ Composition: "main",+ Type: "start",+ Codec: "h264",+ Version: "3.3.78",+ ImageFormat: "jpeg",+ Crf: 1,+ EnvVariables: []interface{}{},+ Quality: 80,+ MaxRetries: 1,+ Privacy: "public",+ LogLevel: "info",+ FrameRange: nil,+ OutName: nil,+ TimeoutInMilliseconds: 0,+ ChromiumOptions: []interface{}{},+ Scale: 0,+ EveryNthFrame: 1,+ NumberOfGifLoops: 0,+ ConcurrencyPerLambda: 1,+ DownloadBehavior: map[string]interface{}{},+ Muted: false,+ Overwrite: false,+ AudioBitrate: nil,+ VideoBitrate: nil,+ Webhook: nil,+ ForceHeight: nil,+ ForceWidth: nil,+ BucketName: nil,+ AudioCodec: nil,+ ForceBucketName: bucketName,}- err := goclient.Render(input)- if err != nil {+ _, error := goclient.Render(input)+ if error != nil {log.Fatal(err)}}diff --git a/packages/goclient/goclient.go b/packages/goclient/goclient.goindex d0eecfc691..a413612431 100644--- a/packages/goclient/goclient.go+++ b/packages/goclient/goclient.go@@ -9,11 +9,11 @@ import ("github.com/aws/aws-sdk-go/service/lambda")-func invokeLambda(options *RemotionOptions) error {+func invokeLambda(options *RemotionOptions) (interface{}, error) {- println("invoking lambda")// Create a new AWS sessionsess := session.Must(session.NewSessionWithOptions(session.Options{+ Config: aws.Config{Region: aws.String(options.Region)},SharedConfigState: session.SharedConfigEnable,}))@@ -23,13 +23,15 @@ func invokeLambda(options *RemotionOptions) error {// Create input for Lambda function_, err := json.Marshal(options)if err != nil {- return err++ return nil, err}internalParams := constructInternals(options)internalParamByte, err := json.Marshal(internalParams)if err != nil {- return err++ return nil, err}params := &lambda.InvokeInput{@@ -38,24 +40,37 @@ func invokeLambda(options *RemotionOptions) error {}// Invoke Lambda function- resp, err := svc.Invoke(params)+ result, err := svc.Invoke(params)+if err != nil {- return err+ println("Result error " + err.Error())+ return result, err}+ // Inspect the response+ if result.FunctionError != nil {+ println("Invoke Lambda FunctionError " + *result.FunctionError)+ }++ // Get the actual response payload+ response := result.Payload++ fmt.Println("responseXXX")+ fmt.Println(response)+// Handle response from Lambda function- var output RemotionRenderResponse- err = json.Unmarshal(resp.Payload, &output)+ var output interface{}+ err = json.Unmarshal(response, &output)if err != nil {- return err+ return nil, err}// Do something with the output from Lambda functionfmt.Println(output)- return nil+ return nil, err}-func Render(input *RemotionOptions) error {+func Render(input *RemotionOptions) (interface{}, error) {return invokeLambda(input)}