import { useState } from 'react'; interface CodeBlockProps { lang: string; children: string; } function CodeBlock({ lang, children }: CodeBlockProps) { const [copied, setCopied] = useState(false); const copy = () => { navigator.clipboard.writeText(children.trim()); setCopied(true); setTimeout(() => setCopied(false), 1500); }; return (
{lang}
        {children.trim()}
      
); } function Section({ title, children }: { title: string; children: React.ReactNode }) { return (

{title}

{children}
); } function Endpoint({ method, path, desc }: { method: string; path: string; desc: string }) { const color = method === 'POST' ? 'text-amber-400 bg-amber-400/10' : 'text-emerald-400 bg-emerald-400/10'; return (
{method}
{path}

{desc}

); } function ParamTable({ params }: { params: { name: string; type: string; desc: string; required?: boolean }[] }) { return (
{params.map((p) => ( ))}
Parameter Type Description
{p.name} {p.required && *} {p.type} {p.desc}
); } export default function ApiDocs() { return (
{/* Core Library */}

The core engine is isomorphic — same code runs in the browser and on Node.js. It operates on raw Y-plane (luminance) buffers with no platform dependencies.

Embed a watermark

{` import { embedWatermark } from '@core/embedder'; import { getPreset } from '@core/presets'; const config = getPreset('moderate'); const payload = new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]); const result = embedWatermark(yPlane, width, height, payload, secretKey, config); // result.yPlane → Uint8Array (watermarked luminance) // result.psnr → number (quality in dB, higher = less visible) `}

Detect a watermark

{` import { detectWatermarkMultiFrame } from '@core/detector'; import { getPreset } from '@core/presets'; const config = getPreset('moderate'); const result = detectWatermarkMultiFrame(yPlanes, width, height, secretKey, config); // result.detected → boolean // result.payload → Uint8Array | null (the 4-byte payload) // result.confidence → number (0–1) // result.tilesDecoded → number `}

Auto-detect (tries all presets)

{` import { autoDetectMultiFrame } from '@core/detector'; const result = autoDetectMultiFrame(yPlanes, width, height, secretKey); // result.presetUsed → 'light' | 'moderate' | 'strong' | 'fortress' | null `}
{/* HTTP API */}

Base URL: https://lightricks-ltmarx.hf.space (HF Space) or http://localhost:7860 (local). For private Spaces, add Authorization: Bearer hf_YOUR_TOKEN header.

{` curl -X POST https://lightricks-ltmarx.hf.space/api/embed \\ -H "Content-Type: application/json" \\ -H "Authorization: Bearer hf_YOUR_TOKEN" \\ -d '{ "videoBase64": "'$(base64 -i input.mp4)'", "key": "my-secret", "preset": "moderate", "payload": "DEADBEEF" }' `}
{` { "detected": true, "payload": "DEADBEEF", "confidence": 0.97, "preset": "moderate", "tilesDecoded": 12, "tilesTotal": 16 } `}
{/* CLI */}

Requires Node.js and FFmpeg installed locally.

{` # Embed a watermark npx tsx server/cli.ts embed \\ -i input.mp4 -o output.mp4 \\ --key SECRET --preset moderate --payload DEADBEEF # Detect a watermark (auto-tries all presets) npx tsx server/cli.ts detect -i video.mp4 --key SECRET # List available presets npx tsx server/cli.ts presets `}
{/* Presets reference */}
{[ { name: 'Light', delta: 50, bch: '(63,36,5)', mask: 'Yes', use: 'Near-invisible, mild compression' }, { name: 'Moderate', delta: 62, bch: '(63,36,5)', mask: 'Yes', use: 'Near-invisible with perceptual masking' }, { name: 'Strong', delta: 110, bch: '(63,36,5)', mask: 'Yes', use: 'More frequencies, handles rescaling' }, { name: 'Fortress', delta: 150, bch: '(63,36,5)', mask: 'Yes', use: 'Maximum robustness' }, ].map((p) => ( ))}
Preset Delta BCH Masking Use case
{p.name} {p.delta} {p.bch} {p.mask} {p.use}
); }