Get thumbnail image of video from video url

后端 未结 8 1643
时光取名叫无心
时光取名叫无心 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();
    
    0 讨论(0)
  • 2021-01-04 20:25

    It is possible to get a thumbnail from a video file or url using FFMPEG.

    FFMPEG must be built using the NDK (or you can find some Android built FFMPEG binaries). Here is a GitHub project to build FFMPEG:

    https://github.com/guardianproject/android-ffmpeg

    You can then include the FFMPEG binaries with your app and execute FFMPEG from code in your app to generate an image from the video (local or URL) using a command like:

    ffmpeg -i videosite.com/video.flv -ss 00:00:15.000 -vframes 1 thumbnail_out.png
    

    One thing to consider is at what seek time (option -ss) you grab the thumbnail for it to be a meaningful image that represents the video.

    0 讨论(0)
提交回复
热议问题