android - 如何使用 Glide 获取流视频链接的帧

标签 android android-glide

在我的 Android TV 应用程序中,开始时我想显示每个流链接的框架。我当前的解决方案是使用 LoaderManager,但这种技术的问题是速度太慢(应用程序崩溃)。

FFmpegMediaMetadataRetriever to load and set video stream link.
this.retriever = new FFmpegMediaMetadataRetriever();
Bitmap bitmap = null;
retriever.setDataSource(this.mSelectedStream.getStreamUrl());
bitmap = retriever.getFrameAtTime();
drawable = new BitmapDrawable(bitmap);
retriever.release();

我找到了 this thread这说明 glide 可用于从视频链接加载图像。

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);

但是当我使用上面的代码时,我收到 VideoBitmapDecoder 的“无法从包外部访问”错误。

示例链接 = "http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8 "

有什么想法吗? 谢谢

最佳答案

我已使用此代码段从视频帧中删除缩略图。试试吧

 Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(media_url,
                MediaStore.Images.Thumbnails.MINI_KIND);
        BitmapDrawable BD = new BitmapDrawable(thumbnail);
        videoView.setBackgroundDrawable(BD);

关于android - 如何使用 Glide 获取流视频链接的帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44967843/

相关文章:

android - 测试 Android 应用程序的正确方法

Android应用设置连接类型

java - 创建一个页面,在主要 Activity 开始之前询问用户详细信息

android - Glide 库 java.lang.NoClassDefFoundError

java - 如何保存位图的正确旋转

android - 折叠 subview ExpandableListview - nhaarman ListviewAnimations

android - 修改CTE的SQLite查询

java - 使用 Glide 加载 SVG 时图像尺寸太小

android - Glide 在第一次加载时缩小图像

android - 如何使用具有相同 url 的新图像缓存图像?