Glide - load single frame from video at specific time?

后端 未结 3 1345
孤城傲影
孤城傲影 2020-12-09 18:40

I\'m trying to use Glide to step through frames in a video file (without running into the keyframe seeking issue that Android suffers from). I can do this in Picasso by doin

3条回答
  •  一向
    一向 (楼主)
    2020-12-09 19:11

    You'll need to pass ".override(width, height)" to make Sam Judd's method to work. Otherwise you'll get only the first frame of the video as I've tested variety of approaches for hours. Hope it saves time for someone.

    BitmapPool bitmapPool = Glide.get(getApplicationContext()).getBitmapPool();
    int microSecond = 6000000;// 6th second as an example
    VideoBitmapDecoder videoBitmapDecoder = new VideoBitmapDecoder(microSecond);
    FileDescriptorBitmapDecoder fileDescriptorBitmapDecoder = new FileDescriptorBitmapDecoder(videoBitmapDecoder, bitmapPool, DecodeFormat.PREFER_ARGB_8888);
    Glide.with(getApplicationContext())
        .load(yourUri)
        .asBitmap()
        .override(50,50)// Example
        .videoDecoder(fileDescriptorBitmapDecoder)
        .into(yourImageView);
    

提交回复
热议问题