Skip to content

Latest commit

 

History

History
73 lines (49 loc) · 3.19 KB

video_frame_zh.md

File metadata and controls

73 lines (49 loc) · 3.19 KB

Video Frame

翻译:English

Sketch 提供了 sketch-video-* 系列模块以支持解码视频帧

Module DecoderProvider Decoder Android iOS Desktop Web
sketch-video VideoFrameDecoderProvider VideoFrameDecoder ✅(API 27)
sketch-video-ffmpeg FFmpegVideoFrameDecoderProvider FFmpegVideoFrameDecoder

安装组件

${LAST_VERSION}: Download (不包含 'v')

implementation("io.github.panpf.sketch4:sketch-video:${LAST_VERSION}")
// or
implementation("io.github.panpf.sketch4:sketch-video-ffmpeg:${LAST_VERSION}")

Important

上述组件都支持自动注册,你只需要导入即可,无需额外配置,如果你需要手动注册, 请阅读文档:《注册组件》

配置

ImageRequestImageOptions 支持一些视频帧相关的配置,如下:

ImageRequest(context, "file:///sdcard/sample.mp4") {
    // 提取 1000000 微秒处的帧
    videoFrameMicros(1000000)

    // 或提取 10000 毫秒处的帧
    videoFrameMillis(10000)

    // 或获取提取中间的帧
    videoFramePercentDuration(0.5f)

    // 设置指定时间处无法提取帧时的处理策略
    videoFrameOption(MediaMetadataRetriever.OPTION_CLOSEST)
}