class pixeltable.iterators.FrameIterator
Iterator over frames of a video. At most one offps, num_frames, or keyframes_only may be specified. If fps
is specified, then frames will be extracted at the specified rate (frames per second). If num_frames is specified,
then the exact number of frames will be extracted. If neither is specified, then all frames will be extracted.
If fps or num_frames is large enough to exceed the native framerate of the video, then all frames will be
extracted. (Frames will never be duplicated; the maximum number of frames extracted is the total number of frames
in the video.)
Parameters:
-
fps(float | None): Number of frames to extract per second of video. This may be a fractional value, such as0.5(one frame per two seconds). The first frame of the video will always be extracted. -
num_frames(int | None): Exact number of frames to extract. The frames will be spaced as evenly as possible: the video will be divided intonum_framesevenly spaced intervals, and the midpoint of each interval will be used for frame extraction. -
keyframes_only(bool, default:False): If True, only extract keyframes. -
all_frame_attrs(bool, default:False): If True, outputs apxt.Jsoncolumnframe_attrswith the followingpyav-provided attributes (for more information, seepyav’s documentation on VideoFrame and Frame):index(int)pts(int | None)dts(int | None)time(float | None)is_corrupt(bool)key_frame(bool)pict_type(int)interlaced_frame(bool)
frame_idx,pos_msec, andpos_frameas separate columns.