Building a Multimodal Content Production Skill: A Practical AIGC Pipeline Guide

    Learn how to build a reusable multimodal content production Skill for AIGC pipelines, covering prompt engineering, audio-driven timelines, FFmpeg video composition, stability, and cost control.

    1. Problem Definition: Why a “Multimodal Content Production Skill”

    As short videos, course slides, and product demos become increasingly video-centric, teams routinely need to turn “a script -> a cover -> a set of shots -> voiceover -> a finished video.” But this workflow is inherently cross-modal and cross-tool:

    • Understanding the script requires a language model.
    • The cover and storyboard frames require text-to-image.
    • Motion shots require text-to-video or image-to-video.
    • Narration requires speech synthesis.
    • Alignment, transcoding, and stitching require local media processing.

    When people manually move files between multiple tools, the efficiency loss concentrates on “waiting” and “mismatch”: generation is asynchronous, so waiting breaks the workflow; file names and durations are maintained by hand, making audio/video desync almost inevitable.

    The goal is therefore not another script that calls a single generation API, but a clearly scoped Skill defined inside an AI coding environment: turn domain knowledge (storyboard breakdown rules, prompt templates, timeline alignment strategy) into a reusable capability so that “a one-line request” can converge reliably into a deliverable.

    A mature Skill usually has four parts: instruction set (when and how to use it), templates and resources (prompt skeletons, layout templates, subtitle styles), scripts and tools (deterministic logic kept in scripts rather than left to the model’s discretion), and output spec (directory structure, naming rules, manifest file). The sections below follow these four layers.

    2. Overall Architecture: A Five-Layer Pipeline

    Split the pipeline into “orchestration layer - generation layer - rendering layer - asset layer - control layer,” and avoid mixing network calls, file processing, and business logic in one giant script.

    1. ┌─────────────── Orchestration (Skill instructions + flow state machine) ───────────────┐
    2. │ Requirement parsing → Storyboard → Task dispatch → Progress summary → Delivery manifest │
    3. └───────┬───────────┬───────────┬───────────┬────────────────────┘
    4. │ │ │ │
    5. Generation Rendering Assets Control
    6. Text-to-image Layout/ Local dirs Retries/ concurrency/
    7. Text-to-video Subtitles/ and cost and quota
    8. Image-to-video TTS sync metadata tracking
    9. Reference FFmpeg manifests
    10. video/TTS composition

    Three design points matter:

    1. Generation over the network, processing locally. Submit model-dependent tasks (images, video, audio) asynchronously to cloud model services, and keep only credentials and outputs locally; do pure computation such as format conversion, concatenation, and subtitle burn-in locally, avoiding unnecessary bandwidth and time spent uploading large media.
    2. Deterministic logic in scripts, judgment logic in the model. Storyboard creativity and prompt rewriting suit the model; duration detection, timeline calculation, and transcoding parameters must be scripts, otherwise the output duration and audio offset drift every time.
    3. Everything revolves around the manifest. Write each step’s output into a unified manifest; downstream steps depend on the manifest rather than directory scanning, which makes resume-from-checkpoint and failure retry feasible.

    3. Generation Layer Capability Abstraction

    When integrating a cloud vendor’s model services, abstract the capabilities into four categories and rely on the official documentation for exact interfaces; do not hardcode assumptions in code:

    Capability Typical use Key constraints
    Text-to-image Cover, storyboard base frames, style exploration Resolution, aspect ratio, negative prompts, batch size limit
    Image-to-video Adding subtle camera motion to static covers/frames First-frame consistency; excessive motion tends to break
    Text-to-video Concept shots with no reference material Short clips, requires multiple segments to concatenate
    Reference video driving Unifying style and pacing across multiple shots Reference asset copyright and duration limits
    Speech synthesis Narration, voiceover, multi-voice dialogue Sample rate, speech rate, pause markers, concurrency limits

    Wrap a single CapabilityClient so “submit - poll - download - persist” follows the same semantics, hiding differences between capabilities:

    1. class CapabilityClient:
    2. def submit(self, kind: str, prompt: str, **params) -> str:
    3. """Submit an asynchronous task and return task_id; kind determines the capability and default parameters"""
    4. def poll(self, task_id: str, interval=5, timeout=600):
    5. """Poll until success/failure; raise a clear exception on timeout for the retry policy to handle"""
    6. def fetch(self, task_id: str, target: Path) -> Path:
    7. """Download the output to a specified path in the asset layer and return the local path"""

    Asynchrony is essential here. Image generation is usually seconds, while video generation is often minutes; waiting serially could block a 10-shot pipeline for over ten minutes. Therefore the orchestration layer should maintain a task pool, run a bounded concurrency (e.g., 3-5) to fill the quota, and persist the “submitted tasks” table so that after a process interruption you can continue polling instead of resubmitting and incurring duplicate charges.

    4. Covers and Storyboards: Prompt Engineering Is the Key Asset

    Variance in generation quality mainly comes from prompts, not from model choice. Structure prompts into slots assembled by a template:

    1. [subject] + [action/state] + [environment] + [camera language] + [lighting and color] + [style anchor] + [quality constraints]

    Three practical tips:

    • Fix style anchors. Write the base style of the whole content (e.g., ink wash, isometric illustration, realistic photography) into Skill resource files and reuse it per shot to avoid style drift within the same video. For “reference image to unify style,” prefer image-to-image or reference driving rather than stacking adjectives.
    • Design the cover separately. The cover must convey information and attract clicks; use layout-based generation: first have the generation model produce a clean background image (leave a text safe area), then overlay the title and subtitle locally with a fixed layout. Compared with asking the model to “generate an image with text,” this separation is much more stable in text accuracy and reusability.
    • Align negative prompts and dimensions. Put elements prone to breaking (extra fingers, garbled text, watermark-like artifacts) into negative prompts; also determine the aspect ratio according to the final output (landscape or portrait) to avoid cropping breaking the composition later.

    Describe the cover layout with a declarative template, then render it locally:

    1. COVER_TEMPLATE = {
    2. "canvas": (1080, 1440), # portrait cover canvas
    3. "safe_area": (96, 240, 984, 1100),
    4. "title": {"size": 88, "weight": "bold", "max_lines": 3, "color": "#FFFFFF"},
    5. "subtitle": {"size": 40, "opacity": 0.85},
    6. "gradient": {"from": "#00000000", "to": "#000000AA", "direction": "bottom"},
    7. }

    5. Audio and Video Composition: Make the Timeline the Single Source of Truth

    The most error-prone part of a multimodal pipeline is not single-point quality but alignment. The recommended approach is audio first, then visuals, then subtitles, letting audio duration drive how long each shot stays on screen.

    First, synthesize speech sentence by sentence from the storyboard script to get each audio segment’s real duration (measured with local media tools, not estimated by character count). Second, calculate the timeline as “shot duration = max(voiceover duration + breathing gap, minimum shot duration)” and generate a structured timeline:

    1. {
    2. "fps": 30,
    3. "segments": [
    4. {"idx": 1, "image": "assets/img/s01.png", "audio": "assets/audio/s01.wav",
    5. "duration": 4.32, "transition": "fade", "subtitle": "First narration sentence"},
    6. {"idx": 2, "image": "assets/img/s02.mp4", "audio": "assets/audio/s02.wav",
    7. "duration": 5.08, "transition": "slide_left", "subtitle": "Second narration sentence"}
    8. ]
    9. }

    Third, use command-line media tools to do three things: turn static images into dynamic clips with slow push/pull/pan (Ken Burns effect), unify sample rate and frame rate, and concatenate audio tracks by offset with light loudness normalization.

    1. # Static image → clip with a slow push (illustrative)
    2. ffmpeg -loop 1 -i s01.png -t 4.32 -vf \
    3. "scale=2560:-1,zoompan=z='min(zoom+0.0008,1.12)':d=130:s=1920x1080,fps=30" \
    4. -c:v libx264 -pix_fmt yuv420p s01.mp4
    5. # Audio track concatenation (offset by timeline)
    6. ffmpeg -i a01.wav -i a02.wav -filter_complex \
    7. "[0:a]adelay=0|0[a0];[1:a]adelay=4320|4320[a1];[a0][a1]amix=inputs=2:normalize=0[a]" \
    8. -map "[a]" -ar 44100 voice.wav

    Fourth, concatenate the clips according to the timeline, mux with the audio track, and burn in subtitles as needed. Always use a standard subtitle file with style control rather than hardcoding coordinates, so changing the aspect ratio only requires swapping the stylesheet.

    Two engineering details need attention: unify pixel format and frame rate (mixing sources with different yuv420p/yuv444p or directly concatenating causes green edges and misalignment), and unify loudness (inconsistent TTS volumes across segments are very jarring; normalize loudness toward a common broadcast reference).

    6. Putting the Skill in Place

    A maintainable Skill directory could look like this, separating “knowledge” from “code” so prompts can iterate without touching logic:

    1. media-pipeline-skill/
    2. ├── SKILL.md # trigger conditions, input/output contract, usage examples
    3. ├── references/
    4. │ ├── storyboard.md # storyboard breakdown and pacing rules
    5. │ ├── prompt-styles.md # style anchors and prompt slot descriptions
    6. │ └── subtitle-style.ass # subtitle style template
    7. ├── scripts/
    8. │ ├── client.py # unified generation capability wrapper (async submit/poll/download)
    9. │ ├── plan.py # copy → storyboard script JSON
    10. │ ├── timeline.py # audio duration → timeline calculation
    11. │ ├── render.py # cover layout and clip rendering
    12. │ └── compose.py # concatenation, muxing, subtitles, output manifest
    13. └── outputs/<task_id>/ # each task has its own directory: assets/ clips/ final/ manifest.json

    The input/output contract in SKILL.md must be clear, as it is a prerequisite for the model to use the Skill correctly:

    1. ## When to use
    2. When the user provides a script/topic and wants a short video with a cover and voiceover.
    3. ## Input
    4. - content: script or outline (required)
    5. - aspect: "9:16" | "16:9" (default 9:16)
    6. - voice: voice identifier (optional)
    7. - style: visual style anchor (optional; defaults to references/prompt-styles.md)
    8. ## Output
    9. - outputs/<task_id>/final/video.mp4
    10. - outputs/<task_id>/cover.png
    11. - outputs/<task_id>/manifest.json (with duration, cost placeholder, failure details)

    7. Stability, Cost, and Engineering

    Classify failures for retry. Network jitter, rate limiting, content moderation rejection, and invalid parameters need entirely different handling: rate limiting should retry with exponential backoff; invalid parameters must fail immediately with a readable error; moderation rejection should fall back to rewriting prompts rather than retrying in place (which would just burn quota).

    Front-load cost control. Include a “preview mode” by default in the Skill: first generate only the cover and storyboard script, and after the user confirms the style, batch-generate images and videos. Video capabilities have significantly higher per-unit cost than images; putting irreversible high-cost steps after a confirmation point is the most effective cost-saving measure. Also record the number of calls and output size per task into the manifest for accounting.

    Idempotency and resume. Before submitting, use the hash of “prompt + parameters + random seed” as the task key, persist a .done marker, and skip completed steps on rerun. This is almost essential when batch-generating 20+ shots.

    Observability. Output structured logs at each step (stage, duration, retry count, output paths) and print a summary at task end; archive failed samples separately to form a replayable regression set for evaluating whether prompt template changes actually improve results.

    Compliance and security. Inject credentials via environment variables or secret management, not into the repository; keep prompts and model info with generated assets for traceability; when involving real persons’ likenesses, third-party assets, or reference videos, first confirm authorization and copyright boundaries.

    8. Common Pitfalls Quick Reference

    • Audio/video desync: almost always caused by estimating duration from character count; switch to measuring real audio duration.
    • Concatenation errors or visual glitches: materials have inconsistent frame rate/resolution/pixel format; unify before concat.
    • Object deformation in video generation: motion magnitude and shot complexity too high; shorten per-segment duration and split into multiple segments for stability.
    • Blurry cover text: caused by letting the model generate text directly; switch to background generation + local text rendering.
    • Duplicate charges in batch tasks: missing task keys and completion markers; add idempotency.
    • Repeated content moderation failures: rewrite prompts before resubmitting, and prepare neutral fallback styles.

    9. Summary

    Turning “script to finished video” into a Skill is essentially engineering a cross-modal media processing pipeline: use a unified capability wrapper to hide differences between asynchronous generation interfaces, use structured prompts and fixed style anchors to stabilize visual quality, use “audio-driven timelines” to solve audio/video alignment, and use manifests, idempotency, and preview confirmation to control cost and maintainability. With this layered approach, the whole workflow can be compressed from a dozen minutes of manual shuffling into one command of automated execution, with a clear path to extend to multi-voice dialogue, automatic remix, and batch distribution.