在我的 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/