DEV Community

Duc Anh Phung
Duc Anh Phung

Posted on

Batch video editing with Adobe Premiere scripting: lessons learned

Scripting a single Premiere Pro edit is a fun weekend project. Running the same script over fifty folders of footage overnight, and finding fifty usable exports in the morning, is a different problem. Most of the difficulty is not in the editing logic. It is in everything around it: timing, file paths, partial failures and the render queue.

This post collects the lessons that apply to any batch pipeline built on Premiere's scripting layer (ExtendScript, usually reached from a CEP panel). The examples are simplified and illustrative, not production code.

Lesson 1: separate the plan from the timeline

The most useful design decision is to never let analysis code touch the timeline directly. Instead, each job produces a plain JSON edit plan, and a separate, boring step applies that plan to Premiere.

{
  "job_id": "C017",
  "source": "D:/footage/C017/main.mp4",
  "sequence_preset": "1080p25",
  "segments": [
    { "in": 3.20, "out": 18.75 },
    { "in": 21.10, "out": 47.40 }
  ],
  "captions_srt": "D:/footage/C017/C017.srt",
  "exports": ["16x9", "9x16"]
}
Enter fullscreen mode Exit fullscreen mode

This gives you three things for free. You can inspect and diff a plan before anything is cut. You can re-apply a plan after Premiere crashes without re-running analysis. And you can generate plans with whatever tool you like, whether that is a rule-based script or an AI agent, while the apply step stays deterministic.

Lesson 2: measure silence on the source file, not on the timeline

Cutting dead air is the first thing most people automate. It is tempting to inspect audio levels inside Premiere, but it is slower and harder to test than running ffmpeg on the source once:

ffmpeg -hide_banner -i main.mp4 -af silencedetect=noise=-35dB:d=0.6 -f null - 2> silence.log
Enter fullscreen mode Exit fullscreen mode

silencedetect writes silence_start and silence_end lines to stderr. Turning them into keep-segments is a few lines of Python:

import re

def keep_segments(log_text: str, duration: float, pad: float = 0.15):
    starts = [float(x) for x in re.findall(r"silence_start: ([\d.]+)", log_text)]
    ends = [float(x) for x in re.findall(r"silence_end: ([\d.]+)", log_text)]
    segments, cursor = [], 0.0
    for s, e in zip(starts, ends):
        if s - cursor > 0.3:  # ignore tiny islands of sound
            segments.append({"in": max(0.0, cursor - pad), "out": s + pad})
        cursor = e
    if duration - cursor > 0.3:
        segments.append({"in": max(0.0, cursor - pad), "out": duration})
    return segments
Enter fullscreen mode Exit fullscreen mode

The threshold (-35dB) and minimum duration (0.6s) depend on the microphone and the room. Tune them per series, store them in the plan, and keep the padding so words are not clipped.

Lesson 3: Premiere counts time in ticks

When you apply a plan, remember that Premiere's scripting API represents time in ticks, with 254,016,000,000 ticks per second. Floating-point seconds are fine in your plan, but convert once, at the boundary, and round consistently:

// ExtendScript (ES3-era JavaScript)
var TICKS_PER_SECOND = 254016000000;

function secondsToTicks(sec) {
  return String(Math.round(sec * TICKS_PER_SECOND));
}

function insertSegment(seq, projectItem, seg, atSeconds) {
  var t = new Time();
  t.ticks = secondsToTicks(atSeconds);
  // In real code, set the in/out on a subclip or trim the track item after inserting.
  seq.videoTracks[0].insertClip(projectItem, t);
}
Enter fullscreen mode Exit fullscreen mode

Many "off by one frame" bugs in batch pipelines come from converting seconds to frames in one place and seconds to ticks in another. Pick one direction and stick to it.

Lesson 4: make every job resumable

A batch of fifty jobs will fail somewhere: a corrupt clip, a missing font, a full disk. The pipeline should treat each job as a small state machine and write its state to disk after each step:

planned -> imported -> assembled -> captioned -> queued -> exported
Enter fullscreen mode Exit fullscreen mode

On restart, the runner skips finished steps and continues from the last good one. Two rules make this reliable:

  • Idempotent steps. Running "import" twice must not create duplicate bins. Check before you create.
  • One project per job, or one clearly named sequence per job. Sharing a sequence across jobs makes partial failures very hard to clean up.

Lesson 5: let Adobe Media Encoder own the render queue

Rendering inside Premiere blocks the scripting thread. Queueing exports to Adobe Media Encoder lets the next job start assembling while the previous one renders:

function queueExport(seq, outPath, presetPath) {
  app.encoder.launchEncoder();
  // workAreaType 0 = entire sequence; last arg: remove from queue when done
  var jobId = app.encoder.encodeSequence(seq, outPath, presetPath, 0, 1);
  return jobId;
}
// After all jobs are queued:
// app.encoder.startBatch();
Enter fullscreen mode Exit fullscreen mode

Keep one .epr preset per output format (16:9 for YouTube, 9:16 for Shorts and Reels) under version control, so a colleague's local preset change does not silently alter your exports.

Lesson 6: validate before you export

Before queueing a render, check what you can check cheaply: every segment has out > in, the caption file exists and its last cue ends before the sequence does, the expected tracks are present, and the output folder is writable. A failed validation should mark the job as needs_review instead of exporting something broken that someone might publish by accident.

Lesson 7: keep a human approval step

Automation is good at the repetitive 80%: trimming silence, placing captions, reframing to vertical, rendering. Judgement calls such as whether a joke lands, whether a product claim is accurate, or whether a clip is safe to publish still belong to a person. A simple review folder with the export and its plan side by side works better than any dashboard.

Where this is going

Tools are starting to wrap this whole loop behind a chat interface. One example is Premiere Pro automation from CoolMe (the page is in Vietnamese), a Windows tool where an AI agent such as Grok or Claude reads the footage, builds an edit plan, applies cuts and captions in Premiere and queues renders, reporting back when jobs finish or fail. Whatever tool you use, the lessons above still apply: plans you can read, steps you can resume and renders you can trust.

What has broken most often in your own batch editing pipelines? I would like to hear about it in the comments.

Top comments (0)