zoukankan      html  css  js  c++  java
  • 获取视频的第一帧

    public static Bitmap getVideoFirstFrame(Context context, Uri uri) {
    Bitmap bitmap = null;
    String className = "android.media.MediaMetadataRetriever";
    Object objectMediaMetadataRetriever = null;
    Method release = null;
    try {
    //反射获取视频第一帧
    objectMediaMetadataRetriever = Class.forName(className).newInstance();
    Method setDataSourceMethod = Class.forName(className).getMethod("setDataSource", Context.class, Uri.class);
    setDataSourceMethod.invoke(objectMediaMetadataRetriever, context, uri);
    Method getFrameAtTimeMethod = Class.forName(className).getMethod("getFrameAtTime");
    bitmap = (Bitmap) getFrameAtTimeMethod.invoke(objectMediaMetadataRetriever);
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    try {
    if (release != null) {
    release.invoke(objectMediaMetadataRetriever);
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    return bitmap;
    }

  • 相关阅读:
    Memcached安装
    linux 安装telnet
    varnish应用
    linux 安装apache
    varnishlog、Varnishstat详解
    varnish CLI管理
    varnish 子程序流程
    python3 cms识别类
    python3 fofa爬取类
    每日健康打卡
  • 原文地址:https://www.cnblogs.com/xxwn/p/4615573.html
Copyright © 2011-2022 走看看