Android - Display a video thumbnail from a URL

前端 未结 7 896
野性不改
野性不改 2020-12-15 05:53

I need to display a video thumbnail based to a URL into an ImageView view child of my ListView items, i have found this post but n

相关标签:
7条回答
  • 2020-12-15 06:27

    @CommonsWare,

    This is not the case that for every video store individual thumbnail in server. but we have some library

    fmmr.jar with using jniLibs

    which directly provide the thumbnail from server url with in 10 second.

    The sample code for Thumbnail.

    FFmpegMediaMetadataRetriever fmmr = new FFmpegMediaMetadataRetriever();
            try {
                fmmr.setDataSource(videoPath);
    
                Bitmap b = fmmr.getFrameAtTime();
    
                if (b != null) {
                    Bitmap b2 = fmmr.getFrameAtTime(4000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC);
                    if (b2 != null) {
                        b = b2;
                    }
                }
    
                if (b != null) {
                    Log.i("Thumbnail", "Extracted frame");
                    return b;
                } else {
                    Log.e("Thumbnail", "Failed to extract frame");
                }
            } catch (IllegalArgumentException ex) {
                ex.printStackTrace();
            } finally {
                fmmr.release();
            }
    
    0 讨论(0)
提交回复
热议问题