Skip to content

NilBangoriya/Video-Authenticator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 Video-Authenticator

AI-Powered Video Ad Compliance & Brand-Safety Auditor

Python FastAPI LangGraph Azure Status


An autonomous LangGraph agent that pulls a YouTube video, understands everything said and everything shown on screen, retrieves the specific regulatory/platform rules that apply, and returns a structured PASS/FAIL compliance report β€” served through a REST API or a CLI.

Overview

Brand and legal teams manually scrub sponsored video content for FTC disclosure violations and platform ad-policy breaches β€” a slow process that doesn't scale with volume. Video-Authenticator (referred to internally, in the code and API title, as Brand Guardian AI) automates the first pass: give it a YouTube URL, and it downloads the video, extracts the spoken transcript and on-screen text, retrieves the exact compliance rules that are relevant via RAG, and returns a categorized, severity-tagged violation report.

Table of Contents

Key Features

  • πŸŽ₯ Automated ingestion β€” pulls YouTube videos directly via yt-dlp, no manual upload step
  • 🧠 Multimodal understanding β€” extracts the spoken transcript and on-screen OCR text using Azure AI Video Indexer
  • πŸ“š Retrieval-augmented auditing β€” embeds the video's content and retrieves the most relevant rules from a real compliance knowledge base (the FTC's Disclosures 101 for Social Media Influencers + YouTube's ad specifications) via Azure AI Search
  • βš–οΈ Structured LLM verdicts β€” Azure OpenAI returns severity-tagged, categorized violations as strict JSON, not free text
  • ⚑ Production-shaped API β€” FastAPI service with Pydantic request/response validation, auto-generated Swagger docs, and a /health endpoint
  • πŸ“Š Built-in observability β€” requests are traced end-to-end via Azure Monitor OpenTelemetry when configured
  • πŸ” Secure by default β€” every Azure call authenticates through a service principal (ClientSecretCredential); no hardcoded keys anywhere in the codebase
  • 🧩 Modular graph design β€” a typed LangGraph StateGraph makes it straightforward to add new audit nodes (e.g. visual moderation, logo detection) without touching existing ones

Architecture

flowchart TD
    Start(["POST /audit β€” video_url"]) --> Indexer

    subgraph Indexer["Indexer Node"]
        A["Download video<br/>(yt-dlp)"] --> B["Upload to Azure<br/>AI Video Indexer"]
        B --> C["Poll until processed"]
        C --> D["Extract transcript +<br/>on-screen OCR text"]
    end

    Indexer --> Auditor

    subgraph Auditor["Auditor Node"]
        E["Embed transcript + OCR<br/>(Azure OpenAI Embeddings)"] --> F[("Azure AI Search<br/>compliance knowledge base")]
        F --> G["Retrieve top-3<br/>relevant rules"]
        G --> H["GPT compliance review<br/>(Azure OpenAI)"]
    end

    Auditor --> Finish(["JSON report<br/>PASS/FAIL + violations"])
Loading

The workflow is a two-node LangGraph StateGraph:

START β†’ indexer (video β†’ transcript + OCR) β†’ auditor (RAG + LLM β†’ verdict) β†’ END

Design notes:

  • Typed, mergeable state β€” compliance_results and errors are declared as Annotated[List, operator.add] reducers in a shared VideoAuditState, so additional nodes can append findings without overwriting each other
  • No hardcoded secrets β€” every Azure call authenticates via a service principal; all configuration lives in environment variables
  • Defensive JSON parsing β€” the LLM is prompted for strict JSON, with a regex fallback that strips markdown code fences before parsing
  • Explicit failure states β€” a failed download, failed indexing, or quarantined video all resolve to a clean FAIL status rather than an unhandled exception

Tech Stack

Layer Technology
Agent orchestration LangGraph, LangChain
LLM & embeddings Azure OpenAI (chat deployment + text-embedding-3-small)
Retrieval (RAG) Azure AI Search
Video intelligence Azure AI Video Indexer (transcript + OCR)
Video acquisition yt-dlp
API FastAPI Β· Uvicorn Β· Pydantic
Auth Azure Identity (service principal)
Observability Azure Monitor OpenTelemetry
Tooling uv Β· Python 3.13

API

POST /audit

Runs the full compliance workflow against a YouTube video.

curl -X POST http://localhost:8000/audit \
  -H "Content-Type: application/json" \
  -d '{"video_url": "https://youtu.be/dT7S75eYhcQ"}'

Example response:

{
  "session_id": "ce6c43bb-c71a-4f16-a377-8b493502fee2",
  "video_id": "vid_ce6c43bb",
  "status": "FAIL",
  "final_report": "Video contains 2 critical violations...",
  "compliance_results": [
    {
      "category": "Misleading Claims",
      "severity": "CRITICAL",
      "description": "Absolute guarantee at 00:32"
    }
  ]
}

GET /health

Lightweight liveness check for load balancers and uptime monitors.

Interactive Swagger docs are auto-generated at /docs once the server is running.

Getting Started

Prerequisites

  • Python 3.13+
  • uv package manager
  • An Azure subscription with:
    • An Azure AI Video Indexer account (ARM-based)
    • An Azure OpenAI resource with a chat deployment + embedding deployment
    • An Azure AI Search service with an index populated from backend/data/
    • An Azure AD App Registration (service principal) with access to the above
    • (Optional) Application Insights for telemetry

backend/scripts/index_documents.py β€” which will automate loading the PDFs in backend/data/ into Azure AI Search β€” is a work in progress (see Roadmap). Until then, the index needs to be populated by another method.

Installation

git clone https://github.com/NilBangoriya/Video-Authenticator.git
cd Video-Authenticator
uv sync

Configuration

Create a .env file in the project root:

# Azure AD service principal
AZURE_TENANT_ID=
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP=

# Azure AI Video Indexer
AZURE_VI_ACCOUNT_ID=
AZURE_VI_LOCATION=
AZURE_VI_NAME=project-brand-guardian-001

# Azure OpenAI
AZURE_OPENAI_CHAT_DEPLOYMENT=
AZURE_OPENAI_API_VERSION=

# Azure AI Search
AZURE_SEARCH_ENDPOINT=
AZURE_SEARCH_API_KEY=
AZURE_SEARCH_INDEX_NAME=

# Optional β€” telemetry is skipped if unset
APPLICATIONINSIGHTS_CONNECTION_STRING=

Run

# REST API
uv run uvicorn backend.src.api.server:app --reload
# β†’ http://localhost:8000/docs

# or the CLI demo (runs one sample video end-to-end)
uv run python main.py

Project Structure

Video-Authenticator/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ data/                    # Compliance knowledge base source docs
β”‚   β”‚   β”œβ”€β”€ 1001a-influencer-guide-508_1.pdf   # FTC "Disclosures 101"
β”‚   β”‚   └── youtube-ad-specs.pdf               # YouTube ad specifications
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   └── index_documents.py   # Ingests data/ into Azure AI Search (WIP)
β”‚   └── src/
β”‚       β”œβ”€β”€ api/
β”‚       β”‚   β”œβ”€β”€ server.py        # FastAPI app β€” /audit, /health
β”‚       β”‚   └── telemetry.py     # Azure Monitor OpenTelemetry setup
β”‚       β”œβ”€β”€ graph/
β”‚       β”‚   β”œβ”€β”€ workflow.py      # LangGraph StateGraph wiring
β”‚       β”‚   β”œβ”€β”€ nodes.py         # indexer + auditor node logic
β”‚       β”‚   └── state.py         # Typed shared state schema
β”‚       └── services/
β”‚           └── video_indexer.py # Azure AI Video Indexer + yt-dlp client
β”œβ”€β”€ main.py                      # CLI entry point
β”œβ”€β”€ pyproject.toml
└── uv.lock

Roadmap

  • Implement index_documents.py to auto-chunk and embed compliance docs into Azure AI Search
  • Add a pytest suite covering graph nodes and API contracts
  • Dockerize + docker-compose for one-command local setup
  • GitHub Actions CI (lint, test, build)
  • Extra graph node for frame-level visual moderation (logo/brand detection)
  • Hosted demo on Azure Container Apps

License

No license has been specified yet. Consider adding a LICENSE file (MIT is a common, permissive default for portfolio projects) so others know how they're allowed to use this code.


Built by Nil Bangoriya Β· GitHub Β· LinkedIn Β· Email

About

LangGraph-orchestrated AI agent that audits YouTube video ads for FTC & platform compliance violations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages