Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 2.8 KB

video_frame.md

File metadata and controls

78 lines (56 loc) · 2.8 KB

Video Frame

Translations: 简体中文

Sketch supports decoding video frames, powered by the following Decoder:

Registered

Select the appropriate Decoder according to the situation, and then register it as follows:

/* Register for all ImageRequests */
class MyApplication : Application(), SketchFactory {

    override fun createSketch(): Sketch {
        return Sketch.Builder(this).apply {
            components {
                addBitmapDecoder(FFmpegVideoFrameBitmapDecoder.Factory())
            }
        }.build()
    }
}

/* Register for a single ImageRequest */
imageView.displayImage("file:///sdcard/sample.mp4") {
    components {
        addBitmapDecoder(FFmpegVideoFrameBitmapDecoder.Factory())
    }
}

Configure

DisplayRequest and LoadRequest support some video frame-related configurations, as follows:

imageView.displayImage("file:///sdcard/sample.mp4") {
    // Extract the frame at 1000000 microseconds
    videoFrameMicros(1000000)

    // or extract the frame at 10000 ms
    videoFrameMillis(10000)

    // or get the frame in the middle of the extraction
    videoFramePercentDuration(0.5f)

    // Set the processing strategy when frames cannot be extracted at the specified time
    videoFrameOption(MediaMetadataRetriever.OPTION_CLOSEST)
}