How to Create Videos using PHP?

To create video using PHP, you need an API capable of rendering dynamic video. The following example shows how to do that with Creatomate's PHP library. Perhaps you're developing a Laravel application for generating videos based on incoming data or user input. Here's how you'd accomplish this with just a few lines of code:

Input Code
// composer require creatomate/creatomate
$client = new Creatomate\Client('Your API Key');

$output = $client->render([
 // The ID of the template that you created in the online editor.
 'template_id' => '2e8bccbf-e40a-41d5-a815-f58518ed9835',

 // Inserting dynamic data into the template.
 'modifications' => [
  'Text' => 'Your Text And Video Here',
  'Video' => 'https://cdn.creatomate.com/demo/drone.mp4'
 ])
]);

var_dump($output);
Output Video

How it works: First, install the Creatomate package from Packagist using Composer. This PHP library makes it easier to work with Creatomate's video API. Creatomate is a managed API for generating video from your PHP application without managing your own infrastructure. It is as simple as invoking the API and receiving the MP4 file back.

There are several approaches to creating videos with PHP, but the easiest way is using a video template. This video template can be created using the online video editor. Once you have a template, you can reference the template in your PHP application and programmatically produce a video based on any given data. This is shown in the code example above. By using the "modifications" parameter, you can specify what data you want to insert into the template, whether it's text, video clips, or additional scenes.

Another way to make videos with PHP is to give the API video editing instructions. It lets you do any common video editing task straight from your PHP application, like stitching, merging, cropping, overlaying text, and more. You can see how in the related examples further down this page.

To get started, follow this quick tutorial or check out the API documentation.

Edit this Code Example in the Video Editor

Easily design your own video templates using the online editor. Then, export your templates as JSON and integrate them into your PHP application to create any kind of video – completely through code.

Related PHP Video Editing Questions

Start automating today

Start with a full-featured trial with 50 credits – no credit card required.