Get thumbnail image of video from video url

后端 未结 8 1684
时光取名叫无心
时光取名叫无心 2021-01-04 19:30

Is it possible to get the thumbnail image from a video Url? I need to thumbnails of videos in a list view.

8条回答
  •  没有蜡笔的小新
    2021-01-04 20:25

    Yes its possible to get the thumbnail of a video using ThumbnailUtils.

    FileOutputStream out;
    File land=new File(Environment.getExternalStorageDirectory().getAbsoluteFile()
                    +"/portland.jpg");// image file use to create image u can give any path.
    Bitmap bitmap=ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.FULL_SCREEN_KIND);//filePath is your video file path.
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            byte[] byteArray = stream.toByteArray();
    
            out=new  FileOutputStream(land.getPath());
            out.write(byteArray);
            out.close();
    

提交回复
热议问题