Check ad video length for Pinterest, LinkedIn and Google in Python

A short Python check of a video-inspect probe against Pinterest, LinkedIn and Google Video action length limits read on 2026-10-08, before you upload an ad.

5 min readSume
All posts

Read duration_seconds from a Sume video-inspect probe and compare it with a small table: Pinterest 4 seconds to 15 minutes, LinkedIn video ads 3 seconds to 30 minutes, Google Video action campaigns at least 10 seconds. The script below does that in plain Python with no network call, so you can test it on a saved probe before wiring it to the API.

The limits

All four numbers come from each platform's own page, read on 2026-10-08. Google's page gives only a minimum, so its maximum is left open.

Length limits used by the script (vendors read 2026-10-08)
PlatformMinimum secondsMaximum seconds
Pinterest video ad4900
LinkedIn video ad31800
Google Video action10No maximum on the page

The script

Paste the duration_seconds value from your probe into PROBE. The check returns a short sentence per platform.

LIMITS = {
    "pinterest": (4, 900),
    "linkedin": (3, 1800),
    "google_action": (10, None),
}
PROBE = {"duration_seconds": 8.4}


def verdict(name, lo, hi, d):
    if d < lo:
        return f"{name}: too short ({d}s < {lo}s)"
    if hi is not None and d > hi:
        return f"{name}: too long ({d}s > {hi}s)"
    return f"{name}: ok"


def main():
    d = PROBE["duration_seconds"]
    for name, (lo, hi) in LIMITS.items():
        print(verdict(name, lo, hi, d))


main()

Getting a real probe

Import the clip with POST /v1/media-imports, then call POST /v1/video-inspect with frames: false. By default the call waits up to 30 seconds and returns the probe; if it takes longer, poll /v1/jobs/:id/status and read /v1/jobs/:id/result. The probe also carries width, height, fps, size_bytes and has_audio, which you can add to the table as the next checks.

With the sample value 8.4, the script reports Pinterest and LinkedIn as ok and Google Video action as too short. Fix that with a trim or a Timeline render of at least 10 seconds, then probe the new file again.

Reading the verdicts

The script is deliberately small. It does not fetch anything, so you can run it in CI against a stored probe, and it keeps the limits in one dictionary so a change on a platform page is a one-line edit. Reread each vendor page when you edit it, because specification pages change without notice, and update the read date in your own notes.

Length is only the first gate. The same probe carries width, height, fps, size_bytes and has_audio, so extend LIMITS with a second dictionary per field when you need it. Keep each platform's rules separate: LinkedIn video ads, for example, have a different length ceiling from LinkedIn Page video, and the comparison post in this batch lists both.

If a clip fails on length, the repair is a video trim at $0.02 per job, or a Timeline render at $0.10 per output minute when you need to join clips or add sound. Probe the result again before upload, since a trim that clamps to the source can still land under the minimum and report trim_clamped_to_source in its warnings.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume