简体   繁体   English

Android是否支持将视频作为canvas drawImage()方法的源?

[英]Video as a source for the canvas drawImage() method is supported on Android?

do you know if the video as a source for the canvas drawImage() method is supported on Android? 您是否知道Android是否支持将视频作为canvas drawImage()方法的源?

The goal is to display the video and to select one moment to take a picture of this moment in a frame (drawImage (video,0,0), return canvas)). 目的是显示视频并选择一个时刻以一帧的形式对此时刻进行拍照(drawImage(video,0,0),返回画布)。 Do you think it is doable? 您认为这可行吗?

Thanks! 谢谢!

There is an approach in Android that will return you a bitmap for a given point in a video, which may give you want you need (or needed as this is an old question!): Android中有一种方法可以为您返回视频中给定点的位图,这可能会给您您所需要的(或需要,因为这是一个老问题!):

MediaMetadataRetriever ( https://developer.android.com/reference/android/media/MediaMetadataRetriever.html#getFrameAtTime%28long,%20int%29 ) MediaMetadataRetriever( https://developer.android.com/reference/android/media/MediaMetadataRetriever.html#getFrameAtTime%28long,%20int%29

getFrameAtTime getFrameAtTime

Added in API level 10 在API级别10中添加

Bitmap getFrameAtTime (long timeUs, int option) 位图getFrameAtTime(longUs,int选项)

Call this method after setDataSource(). 在setDataSource()之后调用此方法。 This method finds a representative frame close to the given time position by considering the given option if possible, and returns it as a bitmap. 如果可能,此方法通过考虑给定的选项来找到靠近给定时间位置的代表性帧,并将其作为位图返回。 This is useful for generating a thumbnail for an input data source or just obtain and display a frame at the given time position. 这对于生成输入数据源的缩略图或仅获取并显示给定时间位置的帧很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM