How to Create Split Screen Videos using PHP?

Split screen video refers to displaying multiple video clips at the same time, usually cut horizontally and presented side-by-side. In order to create the split screen effect using PHP, you will need a video editing API capable of processing video footage. Here's how to do that using PHP in just a few lines of code:

Input Code
// Don't forget to install the required library using Composer:
// composer require creatomate/creatomate
$client = new Creatomate\Client('Your API Key');

$output = $client->render([
 'source' => new Creatomate\Source([
  'output_format' => 'mp4',
  'width' => 1920,
  'height' => 1080,
  'duration' => 6,
  'elements' => [
    'type' => 'video',
    'source' => '',
    'x' => '25%',
    'width' => '50%'
    'type' => 'video',
    'source' => '',
    'x' => '75%',
    'width' => '50%'

Output Video

How it works: First, install the Creatomate package from Packagist using Composer. We can now set up a split screen video composition in our PHP code. First, decide on the resolution you want for the final video. In this case, we'll go with a 1080p landscape layout (1920 by 1080) and use two input videos.

To show both videos side-by-side, we'll use the "x" and "width" properties. Remember, these positions are based on the center of each video element. So, to make the videos appear on the left and right sides, we'll set their positions to "25%" and "75%". To make sure they take up half of the screen horizontally, we'll set the width to "50%".

Keep in mind that we're only providing the horizontal properties ("x" and "width") and leaving the vertical ones ("y" and "height") as they are. By default, the "y" position and height of an element are set to "50%" and "100%" respectively, so they fill up the whole vertical space. So there is no need to specify those values.

If you want to try different multi-screen layouts (for example, a vertical splitscreen layout rather than a horizontal one), you can use a video editor that lets you easily drag and drop videos into place. Once you're happy with the video setup, the editor will generate the necessary code for your PHP application automatically.

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.