CodeCap-Bench: Can Code Serve as a Good Video Caption?

Jiafu Tang1,2,∗,♠ Yifan Xu1,2,∗ Eric Tang3 Junjie Zhao4 Shipeng Luo5 Te Sun4 Haoxuan Hu1 Yiyan Ji1 Xinlong Chen5 Zihao Wang2 Yang Shi6,2,† Yuanxing Zhang2,♠ Pengfei Wan2 Jiaheng Liu1,†

1 NJU2 Kling AI3 TJU 4 SJTU5 CASIA6 PKU

∗ Equal contribution   ·   † Corresponding author   ·   ♠ Project lead

Links coming soon.

Flight seat-selection reference frames compared with natural-language and code captions. Code expresses the seat layout, scrolling motion, and hover and selection states through executable rules.
Code as Video Caption. Executable rules specify spatial structure, compute scrolling motion, and reproduce timed hover and selection states.

Abstract

Can executable code serve as a video caption? CodeCap-Bench evaluates this idea on 323 structured 2D videos across five categories. Code captions describe appearance, layout, and motion through graphical primitives and time-dependent rules; rendering makes their fidelity directly assessable. Our experiments reveal substantial differences across models, with dynamic information consistently less faithfully preserved than static content. Under the evaluated settings, code captions also retain more question-answering information and reconstruct videos more faithfully than the tested natural language pipelines.

Benchmark Construction

Five categories cover apps, 2D games, visual design, scientific visualization, and abstract motion graphics. Each video includes static and dynamic focal points and object spatio-temporal annotations, checked through human review.

CodeCap-Bench construction pipeline: collect videos from multiple sources, filter for structured 2D content, annotate static and dynamic focal points and object locations, and review annotations manually.
Data construction pipeline. Collect and filter structured 2D videos, annotate visual content and timing, then review spatial and temporal accuracy.

Dataset Statistics

The benchmark contains 323 videos, with a mean duration of 19.01 seconds, an average of 16.8 annotated reference objects, and 8.63 focal points per video.

Dataset statistics for 323 videos: category proportions, video duration, number of annotated reference objects, and static and dynamic focal-point counts.
Dataset statistics. Distribution of video categories, durations, reference object counts, and static and dynamic focal-point annotations.

Evaluation

Rendered code captions are compared with the reference video at three levels. Visual content is generated programmatically, without reference imagery or external visual assets.

Visual similarity
Video feature cosine similarity measures overall visual consistency.
Object-level spatio-temporal IoU
Checks whether key objects appear at the correct locations and times.
Fine-grained visual information retention
Scores static appearance and layout, and dynamic motion, state changes, and timing.

Main Results

Complete results at medium thinking effort. Agentic models use tools and rendering feedback; non-agentic models generate code in one pass.

CodeCap-Bench · Medium thinking effort · All metrics ↑ higher is better
Model Harness Video success
(%) ↑
Visual
similarity ↑
Spatio-temporal
IoU ↑
Fine-grained visual retention
Dynamic ↑Static ↑Overall ↑
Agentic
GPT-6-astraCodex99.40.973575.3768.6180.7273.24
GPT-6-astraPi Agent99.70.977174.4567.6681.3572.87
Opus-5Pi Agent97.80.944961.4555.4965.1058.84
Opus-5Claude Code99.40.955558.5553.2363.4056.88
GPT-6-solCodex100.00.956355.6343.9264.0451.34
Qwen3.8-maxPi Agent93.20.886948.9044.8155.8848.83
Gemini-3.8-flashPi Agent98.80.925742.7543.6655.1847.73
GPT-6-solPi Agent99.10.942350.4240.3359.8847.53
DeepSeek-v4.1-flashPi Agent91.60.869245.1440.4551.2744.29
GPT-5.6-solPi Agent99.10.932046.1038.6053.3644.02
GPT-5.6-solCodex99.70.933642.9037.6751.8542.98
Non-agentic
GPT-6-astra-98.50.962269.9669.0076.8572.00
GPT-6-sol-95.70.916858.0148.5461.0753.08
GPT-5.6-sol-96.90.922349.8846.5056.0350.05
Gemini-3.8-flash-97.20.902635.5643.3549.6845.57
Qwen3.8-max-82.00.775442.4143.3947.1544.67

IoU and retention use a 0–100 scale. Bold marks the highest value in each column within each group. Tasks that fail to produce a video receive 0 on the fidelity metrics. On small screens, scroll the table horizontally.

73.24 overall retentionGPT-6-astra + Codex leads the agentic group, with 75.37 spatio-temporal IoU.

Dynamics remain harderDynamic retention is below static retention in every configuration.

Success and fidelity differAgentic generation improves success rates for all paired models; retention gains vary by model.

Results by Video Category

Four-model comparison across apps, games, design, science, and motion categories, measuring visual similarity, spatio-temporal IoU, and visual retention.
Category comparison. Pi Agent · Medium effort. GPT-6-astra leads IoU and retention in all five categories; scientific visualization has the highest IoU for each model.

Further Analysis

Thinking Effort

Pi Agent thinking-effort comparison. GPT-6-sol retention rises from 47.53 at medium to 63.29 at xhigh; Qwen3.8-max rises from 42.02 at low to 51.55 at xhigh. Generation cost is plotted on the right axes.
More reasoning, higher cost. With Pi Agent, GPT-6-sol continues to gain fidelity at higher effort; Qwen3.8-max improves most from low to medium, with smaller gains thereafter.

Generation Cost and Efficiency

Pi Agent comparison of visual retention versus generation cost, alongside input and output tokens, model turns, and mean generation time for seven models.
Cost does not determine fidelity. GPT-6-astra scores above Opus-5 at lower cost. Lower monetary costs for Qwen3.8-max and DeepSeek-v4.1-flash accompany higher token use and longer generation times than the GPT series.

Tool Use

Stacked bars show the share of tool calls used to view reference frames, extract and analyze frames, render and compare results, edit and test code, and perform other tasks across seven Pi Agent models.
Different observation and feedback strategies. Seven models with Pi Agent distribute their tool calls differently across reference inspection, frame processing, and rendered-result checks.

Evaluation Validity

Same generated outputs, scored by two evaluation models
GeneratorMetricEvaluation model
GPT-6-solGemini-3.1-
pro-preview
GPT-6-solDynamic40.3335.73
Static59.8859.55
Overall47.5344.39
DeepSeek-
v4.1-flash
Dynamic40.4535.30
Static51.2750.18
Overall44.2940.81

Generators: Pi Agent · Medium effort. Both evaluation configurations preserve the overall ranking of these two models.

Scatter plot comparing human scores with GPT-6-sol visual-retention scores for outputs from four models, with Pearson correlation r equals 0.942.
Human agreement: Pearson r = 0.942. Human and VLM scores are paired over four models on 50 reference videos, sampled evenly across the five categories.

Code vs. Natural Language

Compare the information retained by code and natural language captions through question answering and video reconstruction.

Question-Answering Accuracy

100 videos from DVBench, VideoMathQA, and GUI-World · Answers evaluated against ground truth · Accuracy (%) ↑
Caption generatorCode-rendered video ↑Natural language caption ↑
GPT-5.6-sol76.4273.58
Opus-583.0272.64
Qwen3.8-max81.1378.30
Original video reference83.96

Gemini-3.8-flash answers from either the rendered video or the caption text. Code-rendered videos score higher for all three generators; Opus-5 reaches 83.02%, compared with 72.64% for natural language.

Video Reconstruction Fidelity

CodeCap-Bench · Direct code rendering vs. natural language captions reconstructed with Seedance-2.5 · Higher is better
Caption generatorReconstruction pathAS ↑MPS ↑KSS ↑
GPT-5.6-solCode rendering0.89070.54120.8068
Natural language0.66280.51560.5925
Opus-5Code rendering0.91480.55720.8165
Natural language0.69320.51500.5958
Qwen3.8-maxCode rendering0.87730.54880.7817
Natural language0.67540.51850.5984

AS: Appearance Similarity · MPS: Motion Pattern Similarity · KSS: Keyframe Structural Similarity. Bold marks the better path for each model and metric. Code rendering scores higher on all three metrics for each tested generator.

Case Study

GPT-6-astra + Codex reconstructs a bubble-chart video by measuring object trajectories and timing, then uses rendering feedback to correct a slider that is one year ahead.

Bubble-chart reconstruction case study: inspect three reference frames, extract bubble trajectories, year-switch times and the pointer path, generate the animation, and correct a slider that is one year ahead.
Bubble-chart reconstruction. Reference inspection → motion and timing extraction → code generation → rendering comparison → temporal correction.