rerun-mp4
它能做什么
该技能展示智能体如何把 MP4 视频文件添加到 Rerun 录制中,而不是把它变成图片。适用于希望把摄像头视频与其他数据并排显示的人。
适用场景
- ✓当你想把 MP4 摄像头视频添加到 Rerun 录制中时。
- ✓当你需要为视频在流模式和资源模式之间做选择时。
- ✓当视频时间与录制的其他数据对不齐,需要修正时。
技能链接
https://github.com/rerun-io/rerun/blob/main/skills/rerun-mp4/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我该如何把 MP4 摄像头视频添加到 Rerun 录制中,使其与传感器数据对齐?”
每周 5 个新技能,1 分钟读完。
工作原理
该技能说明智能体如何为单个视频文件构建读取器,以及应选择哪些设置。流模式会让每一帧都能按时间搜索,而资源模式会把整个文件存为一个整体。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Rerun mp4 ingestion
Mp4Reader turns one .mp4 file into a lazy chunk stream on one entity:
compressed video samples, no decode to pixels, nothing re-encoded unless it has
to be. Everything is configured on the constructor; stream() takes no
arguments. Stream mechanics after .stream() (filter, map, merge, collect,
write) are in rerun-chunk-processing.
The API
from rerun.experimental import Mp4Reader, Mp4TranscodeOptions
reader = Mp4Reader(video_path, entity_path="/camera/front") # mode="stream" by default
stream = reader.stream() # lazy: nothing is decoded yet
Every parameter after path is keyword-only. One reader handles one file — for
several cameras, build one reader per file and LazyChunkStream.merge(...) them
(see below).
Two modes
mode |
emits | when |
|---|---|---|
"stream" (default) |
a codec chunk, per-GOP sample chunks, a keyframe marker | almost always — every frame is time-indexed and queryable |
"asset" |
the whole file as one blob, plus a frame index | the codec cannot be a VideoStream, or the source starts mid-GOP |
Reach for stream mode; the next section covers exactly what it emits. Asset mode
copies the entire file into the recording as one blob, so nothing downstream can
look at a single frame without the whole asset. It is the fallback for codecs a
VideoStream cannot carry (mp4v, image-sequence mp4), and it is what rerun video.mp4 and the built-in file importer use.
What stream mode emits
For tests/assets/video/Big_Buck_Bunny_1080_1s_h264_nobframes.mp4 (30 frames,
one GOP) with entity_path="/camera/front", the whole output is three chunks:
[0] entity=/camera/front static=True rows=1 timelines=[] cols=['VideoStream:codec']
[1] entity=/camera/front static=False rows=30 timelines=['video'] cols=['VideoStream:sample']
[2] entity=/camera/front static=False rows=1 timelines=['video'] cols=['VideoStream:is_keyframe']
- One static chunk, one row, holding
VideoStream:codec. It carries no timeline — code that walks the stream must handle that (if chunk.is_static: continue). - One temporal chunk per GOP: a keyframe plus every sample that depends on it, up to (not including) the next keyframe. Samples only — the keyframe flags are not a column here.
- One trailing
is_keyframemarker chunk, holding a sparseTruerow at each keyframe's time and nothing else. Keeping it out of the sample chunks is what lets a keyframe-only query skip the sample payload, and whatcollect(optimize=…)accepts as canonical. It is list-per-row, so a row reads back as[True], notTrue. - Timeline
video,duration[ns], values are the mp4 PTS from the start of the video. - Every chunk on the same entity.
entity_path=None(the default) derives it from the file's absolute path, sofoo/video.mp4run from/databecomes/data/foo/video.mp4. Passentity_pathexplicitly in any real pipeline.
A short clip is often a single GOP, so "three chunks total" is the normal shape —
not a sign that something was dropped. chunk_by_gop=False emits one Rerun
chunk per sample instead (the marker chunk is unaffected). That is a debugging
shape — one chunk per frame is a poor storage layout, and it also makes a
following optimize pass 6× more expensive (measured below) — so leave the
default alone unless you are inspecting individual samples.
Distinguish the three by their columns, not by position or is_static: the codec
chunk is the static one, sample chunks carry VideoStream:sample, and the marker
chunk carries only VideoStream:is_keyframe.
Supported stream-mode codecs are exactly the five VideoCodec values: H264,
H265, AV1, VP8, VP9.
Transcoding through FFmpeg
VideoStream cannot yet model DTS != PTS, so an H.264/H.265 source with
container-level B-frame reordering cannot be emitted directly. The reader
handles that itself: it re-encodes through FFmpeg with -bf 0, streams the
result back as a fragmented mp4, and turns each fragment into one GOP chunk, so
only one GOP is resident at a time. This is automatic and invisible in the API —
the output has the same shape as a clean source.
常见问题
流模式和资源模式有什么区别?
流模式是默认模式,会让每一帧都能按时间搜索。资源模式把整个文件存为一个数据块,用于视频无法作为流处理的情况。
视频可以重新编码吗?
可以。该技能涵盖通过 FFmpeg 进行转码,包括 B 帧、输出编解码器和关键帧间隔等设置。
如何使用多个摄像头?
为每个视频文件创建一个读取器,然后把生成的流合并在一起。
详情
作者的原始描述
Ingest .mp4 video into Rerun chunk streams with rerun.experimental.Mp4Reader. Read when converting video into a VideoStream, choosing stream vs asset mode, transcoding (B-frames, output codec, GOP size) through FFmpeg, or aligning video PTS onto a recording's wall-clock timeline. Builds on rerun-chunk-processing (stream mechanics) and rerun-data-model (where the video belongs in the recording).
repo: rerun-io/rerun
热度
- GitHub 星标
- 12k
- 排名
- #11556
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
investigate-puffin
12k帮你的智能体分析 Puffin 性能分析录制文件(.puffin 文件),找出耗时较长的代码段,并比较变更前后的跟踪记录。
rerun-blueprint
12k教你的智能体通过为录制或表格编写蓝图,改变 Rerun 查看器的外观,包括布局、视图和隐藏的列。
rerun-catalog-queries
12k帮你的智能体从 Python 更快地查询 Rerun 目录,并附有关于往返次数、载荷大小和数据集读取缓慢的提示。
rerun-chunk-processing
12k教你的智能体使用读取器和 lens 构建 Rerun 数据流水线,将 MCAP、Parquet、视频或 RRD 文件转换为录制。