渲染不适用于 MediaElement windows RT [英] Rendering not working with MediaElement windows RT

查看:48
本文介绍了渲染不适用于 MediaElement windows RT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从使用 MediaElement 播放的视频中获取缩略图

I need to take thumbnail from Video playing with MediaElement

为此,我了解到有 RenderTargetBitmap

RenderTargetBitmap a = new RenderTargetBitmap();
await a.RenderAsync(myMedia);
thumb.Source = a;

我在 WinRTXamlToolkit.Composition 工具包的帮助下获得的第二种方法,它使用 WriteableBitmapRenderExtensions 类进行渲染

and second way i got with help of WinRTXamlToolkit.Composition toolkit which do rendring with WriteableBitmapRenderExtensions class

WriteableBitmap w = await WriteableBitmapRenderExtensions.Render(myMedia);
thumb.Source = w;

这两种方法都适用于所有 UIElement,但不适用于 MediaElement

Both these methods are working with all UIElement but not with MediaElement

当将此源到 Image 对象时,只有黑屏可见.

only black screen is visible when source this to Image object.

谁能告诉我为什么?以及如何从视频中获取缩略图?

Can any one tell me why? and how can i take thumbnail from video?

推荐答案

看来您提到的方法在这方面可能受到限制.我仍然会尝试 RenderTargetBitmap,但在 MediaElement 之上覆盖了一些东西.我相信如果你在 MediaElement 上放置任何东西,比如 0.01 不透明度、1x1 大小的黑色矩形 - 它会切换到以某种不同的渲染模式运行,在这种模式下 RenderTargetBitmap 可能能够渲染它.否则我认为有人在这里讨论了从视频流中捕获帧的问题.不过,IIRC 是一个相当复杂的过程,涉及使用 DirectX 或 Media Foundation 以及相当多的本机代码.

It seems like the methods you mentioned might be limited in that regard. I'd still try RenderTargetBitmap but with something overlaid on top of the MediaElement. I believe if you place anything on top of a MediaElement, like a 0.01 opacity, 1x1 sized, black rectangle - it will switch to run in some different rendering mode where it is possible RenderTargetBitmap would be able to render it. Otherwise I think someone discussed here a while back a question of capturing a frame from a video stream. IIRC it is a pretty involved process though, involving using DirectX or Media Foundation and quite a bit of native code.

这篇关于渲染不适用于 MediaElement windows RT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆