video_split_by_key_frame_mapper¶
Splits a video into segments based on key frames.
This operator processes video data by splitting it into multiple segments at key frame boundaries. It uses the key frames to determine where to make the splits. The original sample can be kept or discarded based on the keep_original_sample
parameter. If save_dir
is specified, the split video files will be saved in that directory; otherwise, they will be saved in the same directory as the input files. The operator processes each video in the sample and updates the sample with the new video keys and text placeholders. The Fields.source_file
field is updated to reflect the new video segments. This operator works in batch mode, processing multiple samples at once.
根据关键帧将视频分割成片段。
此算子通过在关键帧边界处将视频分割成多个片段来处理视频数据。它使用关键帧来确定分割的位置。根据 keep_original_sample
参数,可以选择保留或丢弃原始样本。如果指定了 save_dir
,则分割后的视频文件将保存在该目录中;否则,它们将保存在与输入文件相同的目录中。该算子处理样本中的每个视频,并更新样本的新视频键和文本占位符。Fields.source_file
字段更新以反映新的视频片段。此算子以批处理模式运行,一次处理多个样本。
Type 算子类型: mapper
Tags 标签: cpu, multimodal
🔧 Parameter Configuration 参数配置¶
name 参数名 |
type 类型 |
default 默认值 |
desc 说明 |
---|---|---|---|
|
<class ‘bool’> |
|
whether to keep the original sample. If |
|
<class ‘str’> |
|
The directory where generated video files will be stored. |
|
|
extra args |
|
|
|
extra args |
📊 Effect demonstration 效果演示¶
test¶
VideoSplitByKeyFrameMapper(keep_original_sample=False)
📥 input data 输入数据¶
<__dj__video> 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。
<__dj__video> 身穿白色上衣的男子,拿着一个东西,拍打自己的胃部。<|__dj__eoc|>
<__dj__video> 两个长头发的女子正坐在一张圆桌前讲话互动。 <|__dj__eoc|>
📤 output data 输出数据¶
<__dj__video><__dj__video><__dj__video> 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。<|__dj__eoc|>
<__dj__video><__dj__video><__dj__video> 身穿白色上衣的男子,拿着一个东西,拍打自己的胃部。<|__dj__eoc|>
<__dj__video><__dj__video><__dj__video><__dj__video><__dj__video><__dj__video> 两个长头发的女子正坐在一张圆桌前讲话互动。 <|__dj__eoc|>
✨ explanation 解释¶
This example demonstrates the basic functionality of the VideoSplitByKeyFrameMapper operator. It splits each video into segments based on key frames and updates the text with placeholders for the new video segments. The original sample is not kept, so only the split videos are included in the output. The ‘split_frames_num’ field shows how many segments each video was split into. For clarity, the displayed output data includes the ‘split_frames_num’ field, which is not part of the original output from the operator; the actual raw output would be the updated samples with the new video segments. 这个示例展示了VideoSplitByKeyFrameMapper算子的基本功能。它根据关键帧将每个视频分割成多个片段,并更新文本以包含新的视频片段占位符。原始样本没有被保留,因此输出中只包含了分割后的视频。’split_frames_num’字段显示了每个视频被分割成的片段数量。为了便于理解,显示的输出数据包括’split_frames_num’字段,但这不是算子原始输出的一部分;实际的原始输出会是带有新视频片段的更新后的样本。
test_keep_ori_sample¶
VideoSplitByKeyFrameMapper()
📥 input data 输入数据¶
<__dj__video> 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。
<__dj__video> 身穿白色上衣的男子,拿着一个东西,拍打自己的胃部。<|__dj__eoc|>
<__dj__video> 两个长头发的女子正坐在一张圆桌前讲话互动。 <|__dj__eoc|>
📤 output data 输出数据¶
<__dj__video> 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。
<__dj__video><__dj__video><__dj__video> 白色的小羊站在一旁讲话。旁边还有两只灰色猫咪和一只拉着灰狼的猫咪。<|__dj__eoc|>
<__dj__video> 身穿白色上衣的男子,拿着一个东西,拍打自己的胃部。<|__dj__eoc|>
<__dj__video><__dj__video><__dj__video> 身穿白色上衣的男子,拿着一个东西,拍打自己的胃部。<|__dj__eoc|>
<__dj__video> 两个长头发的女子正坐在一张圆桌前讲话互动。 <|__dj__eoc|>
<__dj__video><__dj__video><__dj__video><__dj__video><__dj__video><__dj__video> 两个长头发的女子正坐在一张圆桌前讲话互动。 <|__dj__eoc|>
✨ explanation 解释¶
This example illustrates the behavior of the VideoSplitByKeyFrameMapper operator when the ‘keep_original_sample’ parameter is set to True (default). In this case, the operator keeps the original sample and adds the split videos as additional samples. The output contains both the original unsplit videos and the new split videos. The ‘split_frames_num’ field in the output data shows the number of segments each video was split into. Note that the ‘split_frames_num’ field is added for clarity and is not part of the original output from the operator; the actual raw output would be the updated samples with the new video segments. 这个示例展示了当’keep_original_sample’参数设置为True(默认值)时,VideoSplitByKeyFrameMapper算子的行为。在这种情况下,算子保留了原始样本,并将分割后的视频作为额外的样本添加进来。输出中同时包含了未分割的原始视频和新的分割视频。输出数据中的’split_frames_num’字段显示了每个视频被分割成的片段数量。请注意,为了便于理解,’split_frames_num’字段是额外添加的,并不是算子原始输出的一部分;实际的原始输出会是带有新视频片段的更新后的样本。