使用 VapourSynth ffms2 插件获取视频帧的时间戳

Get timestamp of video frame using VapourSynth ffms2 plugin

我正在使用此片段作为视频源以稍后处理它:

import vapoursynth as vs
core = vs.core
core.std.LoadPlugin("/usr/local/lib/libffms2.so")

video = core.ffms2.Source("videotest.mkv")

如何获取指定帧的时间戳或获取每一帧的时间戳列表?

根据 FFMS2 and The VapourSynth API-Reference 的文档,可以通过访问每个帧的 _AbsoluteTime 属性来获取帧的时间戳。

使用video.frames()获取每一帧的迭代器:

for frame in video.frames():
    print(frame.props["_AbsoluteTime"])

再举个例子:

>>> import vapoursynth
>>> s = vapoursynth.core.ffms2.Source(r"Z:\Anime\Serien\Incomplete\Akanesasu Shoujo\[HorribleSubs] Akanesasu Shoujo - 01 [1080p].mkv")
>>> f = s.get_frame(0)
>>> f.props
<vapoursynth.VideoProps {'_AbsoluteTime': 0.043, '_ChromaLocation': 0, '_ColorRange': 1, '_DurationDen': 1000, '_DurationNum': 41, '_FieldBased': 0, '_Matrix': 2, '_PictType': b'I', '_Primaries': 2, '_SARDen': 1, '_SARNum': 1, '_Transfer': 2}>
>>> f.props._AbsoluteTime
0.043