Skip to content

🎥 Make videos programmatically with React

add option to call render

Alex Fernandezaeaecf96723d
diff --git a/packages/it-tests/src/lambda/php-package.test.ts b/packages/it-tests/src/lambda/php-package.test.ts
index 152e5b2f4f..37e456f0db 100644
--- a/packages/it-tests/src/lambda/php-package.test.ts
+++ b/packages/it-tests/src/lambda/php-package.test.ts
@@ -14,7 +14,7 @@ test("Set the right version for phpunit", () => {
const version = referenceVersionJson.version;
expect(typeof version).toBe("string");
- const VERSION = `<?php \nnamespace remotion;\n\nconst VERSION = "${version}";`;
+ const VERSION = `<?php \nnamespace Remotion\\LambdaPhp;\n\nconst VERSION = "${version}";`;
writeFileSync(
path.join(process.cwd(), "..", "lambda-php", "src", "Version.php"),
VERSION
diff --git a/packages/lambda-php-example/src/render.php b/packages/lambda-php-example/src/render.php
index 623e48c01e..e8cc2d2d41 100644
--- a/packages/lambda-php-example/src/render.php
+++ b/packages/lambda-php-example/src/render.php
@@ -1,3 +1,16 @@
<?php
+require_once dirname(__DIR__) . '/vendor/autoload.php';
-print("alex");
+use Remotion\LambdaPhp\PHPClient;
+use Remotion\LambdaPhp\RenderParams;
+$client = new PHPClient(
+ "us-east-1",
+ "testbed",
+ "remotion-render",
+ null);
+
+$params = new RenderParams();
+$params->setComposition("react-svg");
+$internalParams = $client->constructInternals($params);
+
+print($internalParams);
diff --git a/packages/lambda-php/src/Exceptions.php b/packages/lambda-php/src/Exceptions.php
index 8e0b85aab3..2f056f4c6d 100644
--- a/packages/lambda-php/src/Exceptions.php
+++ b/packages/lambda-php/src/Exceptions.php
@@ -1,6 +1,6 @@
<?php
-namespace Remotion;
+namespace Remotion\LambdaPhp;
class ValidationException extends Exception
{}
diff --git a/packages/lambda-php/src/PHPClient.php b/packages/lambda-php/src/PHPClient.php
index 839a02b513..618760e2df 100644
--- a/packages/lambda-php/src/PHPClient.php
+++ b/packages/lambda-php/src/PHPClient.php
@@ -1,6 +1,6 @@
<?php
-namespace Remotion;
+namespace Remotion\LambdaPhp;
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Aws\Lambda\LambdaClient;
@@ -44,17 +44,17 @@ class PHPClient
$render->setInputProps($input);
$render->setServerUrl($this->getServeUrl());
$render->setRegion($this->getRegion());
- return json_encode($render->toJson());
+ return json_encode($render->serializeParams());
}
- public function invokeLambda(RenderParams $render) : ? string
+ public function render(RenderParams $render) : ? string
{
- // $this->constructInternals($data, )
+ $params = $this->constructInternals($render);
$result = $this->client->invoke([
'InvocationType' => 'RequestResponse',
'FunctionName' => $functionName,
- 'Payload' => json_encode($data),
+ 'Payload' => json_encode($params),
]);
// Check if the invocation was successful
diff --git a/packages/lambda-php/src/PHPClientTest.php b/packages/lambda-php/src/PHPClientTest.php
index f01bc6335f..f9b7ad3ed7 100644
--- a/packages/lambda-php/src/PHPClientTest.php
+++ b/packages/lambda-php/src/PHPClientTest.php
@@ -4,8 +4,8 @@ require_once dirname(__DIR__) . '/vendor/autoload.php';
require_once __DIR__ . '/PHPClient.php';
require_once __DIR__ . '/RenderParams.php';
-use Remotion\PHPClient;
-use Remotion\RenderParams;
+use Remotion\LambdaPhp\PHPClient;
+use Remotion\LambdaPhp\RenderParams;
class PHPClientTest extends PHPUnit\Framework\TestCase
@@ -23,7 +23,7 @@ class PHPClientTest extends PHPUnit\Framework\TestCase
$params->setComposition("react-svg");
$internalParams = $client->constructInternals($params);
$this->assertEquals($client->getRegion(), "us-east-1");
- print($internalParams);
+ print(json_encode($internalParams));
}
}
diff --git a/packages/lambda-php/src/RenderParams.php b/packages/lambda-php/src/RenderParams.php
index 26cfd2df98..8d1a0bd447 100644
--- a/packages/lambda-php/src/RenderParams.php
+++ b/packages/lambda-php/src/RenderParams.php
@@ -1,5 +1,5 @@
<?php
-namespace Remotion;
+namespace Remotion\LambdaPhp;
require_once __DIR__ . '/Version.php';
use stdClass;
@@ -11,6 +11,7 @@ class RenderParams
private $data = array();
private $bucketName = null;
private $region = null;
+ private $outName = null;
private $composition = 'main';
private $serverUrl = null;
private $framesPerLambda = null;
@@ -81,7 +82,8 @@ class RenderParams
? bool $dumpBrowserLogs = false,
? int $framesPerLambda = null,
? string $rendererFunctionName = null,
- ? string $proResProfile = null
+ ? string $proResProfile = null,
+ ? string $pixelFormat = null
) {
$this->data = $data;
$this->composition = $composition;
@@ -112,15 +114,15 @@ class RenderParams
$this->forceWidth = $forceWidth;
$this->audioCodec = $audioCodec;
$this->dumpBrowserLogs = $dumpBrowserLogs;
- $this->outName = $outName;
+ $this->setOutName($outName);
$this->proResProfile = $proResProfile;
$this->pixelFormat = $pixelFormat;
}
private array $inputProps = array();
- public function toJson()
+ public function serializeParams()
{
- $json = [
+ $parameters = [
'rendererFunctionName' => $this->getRendererFunctionName(),
'framesPerLambda' => $this->getFramesPerLambda(),
'composition' => $this->getComposition(),
@@ -172,7 +174,7 @@ class RenderParams
$json['quality'] = $this->getQuality();
}
- return json_encode($json);
+ return $parameters;
}
/**
diff --git a/packages/lambda-php/src/Version.php b/packages/lambda-php/src/Version.php
index 820b8907e7..6bac2e4a44 100644
--- a/packages/lambda-php/src/Version.php
+++ b/packages/lambda-php/src/Version.php
@@ -1,4 +1,4 @@
<?php
-namespace remotion;
+namespace Remotion\LambdaPhp;
const VERSION = "3.3.90";
\ No newline at end of file