Convert Vertical Video to Horizontal

After Effects
April 4, 2025

/**
* This script creates a new composition with a blurred background effect.
* It duplicates the selected footage, scales it to fit the composition,
* applies a Gaussian Blur and Levels effect to the duplicated layer,
* and renames the layers accordingly.
*/

// Get the active project
var project = app.project;
if (!project) {
   alert("No project open.");
} else {
   app.beginUndoGroup("Create Blurred Background");
   
   // Get the selected items
   var selectedItems = project.selection;
   if (selectedItems.length === 0) {
       alert("No footage selected.");
   } else {
       var footage = selectedItems[0];
   
       // Create a new composition
       var compWidth = 1920;
       var compHeight = 1080;
       var compDuration = footage.duration;
       var compFPS = footage.frameRate;
       var comp = project.items.addComp("Blurred Background Comp", compWidth, compHeight, 1, compDuration, compFPS);
   
       // Add the footage to the composition
       var layer = comp.layers.add(footage);
       // Scale to fit height
       var scaleFactor = (compHeight / footage.height) * 100;
       layer.transform.scale.setValue([scaleFactor, scaleFactor]);
       layer.transform.position.setValue([compWidth / 2, compHeight / 2]);
   
       // Duplicate the layer
       var duplicateLayer = layer.duplicate();
       duplicateLayer.moveBefore(layer);
   
       // Scale the duplicated layer to fill width
       var duplicateScaleFactor = (compWidth / footage.width) * 100;
       duplicateLayer.transform.scale.setValue([duplicateScaleFactor, duplicateScaleFactor]);
   
       // Add Gaussian Blur effect to duplicated layer
       var blurEffect = duplicateLayer.Effects.addProperty("ADBE Gaussian Blur 2");
       blurEffect.property("Blurriness").setValue(100);
   
       // Add Levels effect to duplicated layer
       var levelsEffect = duplicateLayer.property("Effects").addProperty("ADBE Easy Levels");
   
       // Rename the layers
       duplicateLayer.name = "Background Layer";
       layer.name = "Foreground Layer";
   
       // Reorder layers to ensure original layer is on top
       layer.moveToBeginning();
   
       // Open the new composition
       comp.openInViewer();
   
       app.endUndoGroup();
   }
}

How to use the script

Always check code before running it on your computer. Even basic scripts like this one. If you’re not a developer, ask an LLM like ChatGPT, Claude, or Gemini to verify it for you.

Option 1: Install to your AE Folder

Download and install the below .jsx file in your After Effects Script folder. You can then run it using the scripts menu, or by using a launcher like Quick Menu 3.

Option 2: Adapt the script yourself

Alternatively copy the code below and develop your own version. If you’re not a developer you can do this easily with an LLM like ChatGPT.

How to use the script

Always check code before running it on your computer. Even basic scripts like this one. If you’re not a developer, ask an LLM like ChatGPT, Claude, or Gemini to verify it for you.

Option 1: Install to your AE Folder

Download and install the below .jsx file in your After Effects Script folder. You can then run it using the scripts menu, or by using a launcher like Quick Menu 3.

Option 2: Adapt the script yourself

Alternatively copy the code below and develop your own version. If you’re not a developer you can do this easily with an LLM like ChatGPT.

Research, interviews, and tools for modern motion designers.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.