AI Ad Generation System

Ad Library Scraping • Video Speech-to-Text • AI Creative Scoring • Auto-Brief Generation

Watch Demo Video
Write to our Agent & Get personal pricing
AI Ad Generation System Case Study — Arihant Web Tech

AI Ad Generation System Case Study — Arihant Web Tech

Client Focus Direct-to-Consumer (D2C) Brand
Core Tech GPT-4o Vision, Whisper, Playwright
Architecture DOE Framework (Directives, Operations, Eval)
Deployment AWS EC2 + FastAPI + Google Sheets

What This System Does

We engineered an autonomous AI agent for a fast-growing D2C brand that was spending 15–20 hours per week manually reviewing competitor Facebook and Instagram ads. The system automatically monitors competitor ad libraries, analyzes creative formats, transcribes text and speech, and writes actionable briefs for designers and media buyers.

15-20h Time Saved Eliminated manual ad-library review & brief copywriting
100+ Ads / Run Processed across multiple competitors in parallel
9 AI Stages Unified audio, text, and visual analysis pipelines
Auto Briefs Brand-aligned briefs generated for elite/strong creatives
Live Delivery FastAPI dashboard and automatic Google Sheets export

"The result is a major operational shift: the creative team opens a custom dashboard every Monday morning and immediately finds a prioritized list of ad briefs adapted to their exact brand voice and visual style, based on what competitors ran successfully the previous week. Intelligence that used to take a full-time analyst is delivered in under 30 minutes of compute time."

The Problem We Were Solving

Performance marketing teams fight a constant creative arms race. Winning on paid social requires iterating fast: spotting a competitor's hook mechanic, adapting it to your brand, and launching it before market fatigue sets in. But doing this manually is slow and error-prone.

What the Client Did Before

  • A marketing analyst manually checked the Meta Ad Library 2–3 times per week for each competitor brand.
  • Screenshots were saved to a shared folder, and notes were scattered across Google Docs.
  • A separate strategist reviewed the notes to decide which ideas to develop.
  • A copywriter wrote the brief—often 7-10 days after the competitor's ad first appeared.
  • Video ads were largely ignored because transcribing and analyzing them was too time-consuming.
1

Speed Bottlenecks

By the time a competitor's creative pattern was identified and actioned, it was already in creative fatigue. The window to capitalize is narrow.

2

Incomplete Coverage

Human reviewers missed ads. The Meta Ad Library shows hundreds of active creatives across multiple competitors, making manual coverage impossible.

3

Shallow Analysis

Manual review produced surface-level notes ('hook: before/after'). It couldn't quantify trend frequency, predict CTR, or cross-reference trends.

4

Video Blindspot

Video ads (which often outperform static images) were skipped entirely because transcription and visual frame parsing were too expensive manually.

The Solution: AI Ad Generation System

We designed and built a fully autonomous AI agent following the DOE Framework (Directives, Operations, and Evaluations). The agent runs on a weekly schedule, processing competitor ads end-to-end to surface only what matters.

Directives

LLM Reasoning

Six carefully engineered system prompts govern how the language model reasons at each stage. Includes strict JSON schema constraints so outputs are validated before moving downstream.

  • Creative & Video analysis
  • Pattern & Trend detection
  • Performance prediction
Operations

Async Pipeline

Thirteen async Python functions form the backbone of the pipeline. Each operation has a single responsibility, returns structured JSON, and can be toggled via config flags.

  • Parallel media downloads
  • Concurrent pattern detection
  • Asyncio.gather processing
Evaluations

Quality Gates

Three automated validators run after every LLM step to check analysis coverage, pattern confidence scores, and brief quality. Low-quality outputs are flagged and excluded.

  • Coverage verification
  • Confidence score filter
  • Brief quality validation

How It Works: Step by Step

Every scheduled execution runs an end-to-end pipeline. The system features a persistent memory store, deduplicating assets across runs by media URL to keep API costs minimal and performance high.

1

Scrape Meta Ad Library

Headless Chromium running via Playwright scrapes live competitor ads—capturing ad copy text, media URLs, CTA actions, and run durations (up to 50 ads per competitor brand).

Sequential
2

Collect & Classify Assets

Deduplicate ads by media URL to save API budget. Separate image vs. video creatives and cache assets locally to avoid redundant network overhead.

Sequential
3

Media Processing

Download image assets and video clips concurrently. Extract video audio streams via FFmpeg and transcribe vocal dialogue with OpenAI Whisper.

Parallel Execution
4

AI Creative Analysis

GPT-4o Vision processes static images and video keyframes alongside transcripts to identify hook type, emotional tone, CTA placement, and design quality.

Parallel Execution
5

Pattern Detection

LLM clusters ads into recurring creative archetypes (e.g. 'pain-point opener', 'UGC testimonial', 'before/after') and calculates frequency metrics.

Parallel Execution
6

Messaging Trend Analysis

Analyze narrative framing shifts across the entire ad corpus over a rolling timeframe, checking which marketing angles are gaining or losing share of voice.

Parallel Execution
7

Performance Prediction

A heuristic scoring model predicts CTR probability, scroll-stop power, and creative fatigue risk, categorizing ads into Elite, Strong, Average, or Weak tiers.

Sequential
8

Adaptation Brief Generation

For every Elite or Strong ad, the brief engine automatically rewrites the proven competitor hook and framework into the client's brand voice, visual guidelines, and product context.

Sequential
9

Export & Strategy Report

Output structured database records to a shared Google Sheet via idempotent batch writes, and write a summary strategy JSON report with weekly creative priorities.

Parallel Execution

Parallelism for Speed: By executing downloads, vision analysis, pattern/trend detection, and exporting concurrently using asyncio.gather, we bypass sequential queue bottlenecks. A standard weekly run processing 100+ creative variants completes in 20 to 30 minutes instead of several hours.

Technology Stack

We constructed the pipeline with a robust, enterprise-grade open-source stack that runs entirely on your own cloud infrastructure—eliminating recurring SaaS seat fees.

Scraping Layer Playwright Headless Chromium automation; parses dynamic, JS-rendered Meta Ad Library layouts stably.
Cognitive Vision GPT-4o API Multi-modal reasoning for visual styling, emotional tone, and hook structure analysis.
Audio Processing OpenAI Whisper Converts audio tracks extracted from competitor video ads into accurate text scripts.
Video Processing FFmpeg Server-side command line tool that demuxes and extracts audio streams from mp4 files.
Orchestration Python Asyncio Asynchronous concurrent tasks and pipeline workers with structured error boundaries.
Web Dashboard FastAPI & Jinja2 Performant backend routing with JWT authentication and HTML brief viewer templates.
Database Layer PostgreSQL Relational storage mapping competitor campaigns, creative metrics, briefs, and logs.
External Integrations Google Sheets API Idempotent batch write syncs to client's shared spreadsheets in single, clean requests.

Key Features & Capabilities

The system delivers senior-level strategic creative direction at scale, resolving several long-standing marketing analysis limitations.

👁️

Full-Funnel Creative Analysis

While basic tools only scrape copy, our system digests video completely. It extracts audio with Whisper, visual frames via GPT-4o Vision, and evaluates pacing, emotional tone, and CTA quality.

📈

Compounding Pattern Detection

Instead of analyzing ads in isolation, the database tracks how the frequency of ad styles changes over rolling 12-week windows, warning you when competitor formats show fatigue.

🎯

Performance Triage

Every ad is rated for CTR potential, scroll-stop power, and fatigue risk. Only "Elite" and "Strong" creatives trigger adaptation brief generation, focusing creative resources on high-probability concepts.

📝

Ready-to-Brief Ad Adaptations

Converts competitor mechanics into design-ready briefs. Includes rewritten hooks, typography directions, visual styling constraints, CTA suggestions, and production checklists.

💾

Deduplicating Memory Store

Features a JSON-backed MemoryStore. Tracks previously scraped media URLs to avoid analyzing identical creative variations, saving substantial API execution costs.

🔒

Secure Admin Dashboard

A secure internal dashboard protected by JWT token authentication and HTTP-only cookies, allowing team members to execute manual runs and browse visual brief history.

Problems Solved for Our Customers

Our AI system converts structural marketing bottlenecks into streamlined automated operational workflows.

Losing the Creative Iteration Race

Solution: Spot and replicate competitor hooks in real time. The agent closes the loop between competitor execution and your designer briefs to under 24 hours.

Teams Drowning in Manual Research

Solution: Eliminates screenshotting, copy-pasting, and doc sorting. The system handles raw research autonomously, freeing staff to make high-level decisions.

Video Creative is a Blindspot

Solution: Audio extraction combined with frame-by-frame LLM vision parsing translates video assets into structural briefs just as easily as static images.

Uncertainty on Which Competitor Ads Actually Work

Solution: Heuristic prediction score filters out low-performing ad tests, focusing your design resources purely on proven hook archetypes.

Brief Writing Takes Days

Solution: The brief writing engine automatically populates copy angles, production checklists, and brand parameters, allowing copywriters to refine rather than write from scratch.

No Institutional Trend Memory

Solution: 12-week rolling historical database compiles market share-of-voice trends, highlighting when competitor creative concepts begin to saturate.

How We Implement It

Onboarding a brand onto the Creative Intelligence Agent is a fast, 3-step process that completes in under 5 business days.

Step 1 — Days 1-2

Configuration & Rules

  • Compile competitor brand lists and Meta Ad Library search parameters.
  • Ingest your brand guidelines: tone of voice, visual styling parameters, and fonts.
  • Provide historically high-performing briefs to align output styling.
  • Establish secure credentials and link Google Sheets workspaces.
Step 2 — Days 2-3

First Validation Run

  • Trigger first pipeline executions on active competitor campaigns.
  • Collect and review initial batch of briefs with the brand's creative lead.
  • Adjust brand adaptation prompts and response guidelines.
  • Verify visual quality and Google Sheet formatting rules.
Step 3 — Days 4-5

Schedule & Handover

  • Schedule automatic execution runs (typically weekly on Sunday nights).
  • Establish admin access and review dashboard layouts.
  • Provide full code walkthroughs and engineering documentation.
  • Initialize 30-day technical support window.

Technical Highlights & Design Decisions

A deep dive into our core architectural decisions that optimize cost, speed, and accuracy.

Scraping Architecture Playwright vs. Static HTTP
The Meta Ad Library is a highly dynamic single-page React app. Static requests fail to load actual ad assets. Playwright spins up a real headless Chromium container, automatically scrolls to trigger lazy loading, and extracts clean selectors. Custom delay parameters ensure scraper stability under varying network traffic conditions.
Cognitive Processing GPT-4o vs. Custom CV
Traditional computer vision model structures classify images based on static tag rules (e.g. identifying a human face). Analyzing marketing assets requires qualitative, creative analysis (e.g. evaluating emotional weight or layout hierarchy). GPT-4o Vision delivers complex brand logic at production speed, constrained with JSON schemas for machine parsing.
Cost Optimization Deduplication by Media URL
Meta often duplicates single creative assets across dozens of individual ad variants for split-testing. Tracking by Ad ID would run LLM processing on the identical creative repeatedly, wasting api budget. By hashing and tracking media URLs in a local datastore, we process each unique creative precisely once, cutting costs by over 70%.
Integrations Idempotent Batch Writes
Rather than appending rows during every runtime (creating messy duplicates), the Google Sheets exporter flushes and rewrites rows in single batch API requests. This ensures your shared spreadsheet remains a clean, deduplicated representation of active competitor campaigns while minimizing Google Sheets API quota usage.
Robustness Output Quality Gates
LLM models occasionally write malformed arrays, blank objects, or incomplete text values despite schema rules. Our system applies three independent validation filters. If a brief fails to meet confidence, size, or quality rules, the system logs a detailed error status and flags it for exclusion rather than sending broken briefs.

Who This Is For

We constructed the system for scaling brands seeking to institutionalize competitive intelligence and creative output velocity.

🎯

Ideal System Fit

  • Meta Ad Spend $50K+ Monthly: Creative variations represent your primary conversion multiplier.
  • 2+ Active Competitors: Competitors regularly update campaigns on Facebook/Instagram.
  • Creative Output 10+ Ads/Mo: Your design team requires structural briefs to scale creation.
  • Seeking Institutional Asset Base: You want a persistent trend database rather than manual reviews.
⚠️

Might Not Be a Fit

  • Niche/Low Ad Spend: Ad volumes are low, and creative iteration speed is not a priority.
  • Fewer Than 2 Main Competitors: Very little competitor activity to monitor.
  • Restricted/Niche Industries: Niche categories where Meta Ad Library coverage is restricted or delayed.
  • No Internal Design Team: No setup to digest automated briefs and build design assets.

Ready to Automate Your Ad Briefs?

We build tailored Creative Intelligence systems on your own cloud infrastructure—giving you complete code ownership with no recurring SaaS fees or seat licenses. Get in touch to schedule a demo.

Start Your Project Today