视频
视频标签用于播放简单的视频文件。适用于视频标注任务,如分类和转录。
适用于以下数据类型:视频
视频格式
Label Studio依赖您的网页浏览器来播放视频并计算总帧数。因此,确保视频使用广泛支持的格式和编解码器至关重要。为获得最佳兼容性,我们推荐使用MP4容器格式,视频编码采用H.264(AVC)编解码器,音频编码采用AAC。这种组合在所有现代浏览器中都得到广泛支持,并能最大限度地减少总时长检测错误或播放问题等情况。此外,将视频转换为恒定帧率(CFR)非常重要,理想情况下约为30 fps,以避免帧数差异以及重复帧或丢帧等问题。
文件中的所有音频和视频流必须具有相同的时长,否则将会产生额外的总帧数。
将您的视频转换为这种推荐格式有助于确保它们在Label Studio中流畅播放,并且帧率和时长能被正确识别以实现精准标注。要将任何视频转换为该格式,您可以使用FFmpeg。例如,以下命令可将输入视频转换为MP4格式,包含H.264视频编码、AAC音频编码以及恒定的30帧/秒帧率:
# Extract the exact video stream duration in seconds
DUR=$(ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=nokey=1:noprint_wrappers=1 input.mp4)
# Re-encode media file to recommended format
ffmpeg -i input_video.mp4 -c:v libx264 -profile:v high -level 4.0 -pix_fmt yuv420p -r 30 -c:a aac -b:a 128k -to $DUR output_video.mp4
在此命令中:
-i input_video.mp4指定您的源视频文件。-c:v libx264使用H.264编解码器进行视频编码。-profile:v high -level 4.0设置适用于广泛设备的兼容性参数。-pix_fmt yuv420p确保像素格式与大多数浏览器兼容。-r 30强制设定恒定帧率为30 fps。您也可以省略 -r 选项,ffmpeg会保持当前帧率。如果您100%确定视频具有恒定帧率,这样做没有问题。-c:a aac -b:a 128k以128 kbps的比特率将音频编码为AAC格式。-to会在容器时钟达到视频结束时间戳时立即停止输出写入,因此任何多余的音频尾部都会被自动丢弃。output_video.mp4是转换好的视频文件,可直接用于Label Studio。
使用此FFmpeg命令重新编码您的视频将有助于消除播放问题,并确保Label Studio能准确检测视频总时长,从而提供流畅的标注体验。
建议使用以下命令检查视频的所有参数:
ffprobe -v error -show_format -show_streams -print_format json input.mp4
参数
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| name | string |
Name of the element | |
| value | string |
URL of the video | |
| [frameRate] | number |
24 |
video frame rate per second; default is 24; can use task data like $fps |
| [sync] | string |
object name to sync with | |
| [muted] | boolean |
false |
muted video |
| [height] | number |
600 |
height of the video player |
| [timelineHeight] | number |
64 |
height of the timeline with regions |
示例
在标注界面上显示视频的标注配置
<View>
<Video name="video" value="$video" />
</View>
示例
视频分类
<View>
<Video name="video" value="$video" />
<Choices name="ch" toName="video">
<Choice value="Positive" />
<Choice value="Negative" />
</Choices>
</View>
示例
视频转录
<View>
<Video name="video" value="$video" />
<TextArea name="ta" toName="video" />
</View>