arXiv(opens in a new tab)cs.CVOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.37341

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

Jiafu Tang, Yifan Xu, Eric Tang, Junjie Zhao, Shipeng Luo, Te Sun, Haoxuan Hu, Yiyan Ji, Xinlong Chen, Zihao Wang, Yang Shi, Yuanxing Zhang, Pengfei Wan, Jiaheng Liu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Video captioning aims to preserve visual information through compact descriptions, predominantly using natural language. However, precisely expressing fine-grained spatial structures and temporal dynamics in natural language often leads to lengthy and potentially ambiguous descriptions. In this work, we explore Code as Video Caption, a paradigm where executable programs serve as a complementary representation of visual content through graphical primitives, layout rules, and functions of time. To examine whether code captions effectively preserve video information, we compare them with natural language captions on downstream question answering and video reconstruction tasks. Our results show that code captions achieve superior reasoning accuracy and reconstruction fidelity. Despite these advantages, realizing the potential of code captioning depends on whether current multimodal large language models (MLLMs) can generate faithful code captions. To systematically assess this capability, we introduce CodeCap-Bench, which comprises 323 videos spanning five categories of structured 2D content, along with fine-grained annotations and a multilevel evaluation framework. Extensive experiments reveal that while leading proprietary MLLMs demonstrate promising code captioning capabilities, they still struggle to faithfully capture complex temporal dynamics, with open-source models lagging substantially behind.

1 Introduction

Video captioning [7; 8; 9; 10; 21; 23; 34; 38; 42; 45; 48] aims to preserve visual information in videos through compact descriptions. Existing methods mainly rely on natural language to describe objects, attributes, actions, and events [13; 24; 49]. However, videos also contain fine-grained spatial structures and temporal dynamics, including complex layouts, motion trajectories, and coordinated changes among multiple objects. Precisely expressing this information in natural language often requires many positional, temporal, and relational constraints, making descriptions lengthy and potentially ambiguous. This motivates us to explore Code as Video Caption, where executable programs provide a complementary way to represent visual content through graphical primitives, layout rules, and temporal logic [12; 33; 52].

As illustrated in Figure 1, executable code has three complementary advantages compared with natural language descriptions in representing video information. First, code captures rule-based spatial structure. In the flight seat-selection interface, grid rules specify seat positions and spacing, while a shared drawing function defines seat geometry, compactly representing repeated elements and their spatial relationships. Second, code supports computable temporal evolution. While the natural language caption states that "the seat map scrolls downward," time functions specify the scrolling interval, displacement, and easing, allowing the scroll position to be computed at any intermediate time. Finally, code provides an executable visual specification. Conditional logic specifies which seat changes color and when a selection mark appears, and executing these rules produces the corresponding visual states. Together, these properties make spatial layouts, motion, and state changes explicit, reduce ambiguity in how visual details are interpreted, and allow the rendered video to be directly compared with the reference video.

To examine the practical value of code as video caption, we compare code and natural language captions through question answering and video reconstruction (Section 4.3.6). Under the evaluated settings, videos rendered from code captions support more accurate question answering and better preserve the appearance, motion patterns, and spatial structure of the original videos in reconstruction, providing evidence of the potential of code captions to preserve and utilize video information.

∗^{*}Equal Contribution. †\daggerCorresponding Author. ♠\spadesuitProject Lead.

Figure

Figure 1: Illustration of video captioning with executable code. The reference video shows a flight seat-selection interface. (a) and (b) present natural language and code captions of the same segment, respectively. The code caption encodes spatial structure, temporal dynamics, and visual state changes through executable rules and functions.

Despite this promise, a dedicated benchmark for this task is still lacking, and the ability of current multimodal large language models [1; 4; 28; 30; 40; 41; 51] to generate faithful code captions has yet to be systematically evaluated. In particular, how accurately models can represent spatial layouts, motion trajectories, and state changes, and how these capabilities vary across content types and generation settings, remain open questions.

To address these questions, we introduce CodeCap-Bench, a benchmark for systematically evaluating the code captioning capabilities of MLLMs. We focus on structured 2D videos whose visual content can be represented programmatically. CodeCap-Bench comprises 323 videos across five categories: desktop and application interfaces, 2D games, visual design and media animation, data and scientific visualization, and icons and abstract motion graphics. We provide fine-grained focal-point annotations of key static and dynamic content, together with object-level spatio-temporal annotations. By rendering generated code into videos, we evaluate caption fidelity along three complementary dimensions: visual similarity, object-level spatio-temporal IoU, and fine-grained visual information retention. This framework enables systematic assessment of how faithfully models preserve visual appearance, spatial structure, and temporal dynamics through executable code.

We conduct extensive experiments to investigate the ability of current MLLMs to generate code captions. Our evaluation reveals substantial differences across models, with dynamic visual information consistently less faithfully preserved than static content. We further examine the effects of agentic workflows, thinking effort, and generation cost on caption fidelity and reliability. These results reveal the capabilities and limitations of current models in generating faithful code captions and provide empirical evidence to help connect video understanding with programmatic generation.

Our contributions can be summarized as follows:

• We explore Code as Video Caption, investigating executable code as a complementary representation for preserving fine-grained visual information, spatial structure, and temporal dynamics. Code captions have an explicit visual interpretation that can be checked through rendering, with question-answering and video reconstruction comparisons providing further empirical support for their value.

• We introduce CodeCap-Bench, a benchmark comprising 323 videos across five categories of structured 2D content, with fine-grained focal-point and object-level spatio-temporal annotations. We establish a multi-level evaluation framework covering global visual similarity, object-level spatio-temporal alignment, and fine-grained visual information retention.

• We systematically evaluate MLLMs across generation settings, finding that leading proprietary models show promise but struggle with complex temporal dynamics, while open-source models lag substantially behind. We also analyze the relationships among caption fidelity, generation reliability, and cost.

References (43)