【问题标题】:any solution to take snapshot of a video in videovew ?在 videovew 中拍摄视频快照的任何解决方案?
【发布时间】:2013-03-03 07:40:26
【问题描述】:

您好,谁能告诉我如何拍摄正在视频视图中播放的视频的快照。快照给出了空白图像,或者任何方法来抓取当前视频帧,我想选择当前帧,任何人都可以帮助PLZ

【问题讨论】:

标签: android android-layout android-intent android-widget


【解决方案1】:

最有效的解决方案是MediaMetadataRetriever。 首先调用

setDataSource(FileDescriptor fd)

是的,这是一个相当棘手的方法。有时它需要复杂的解决方案。这是一个例子:

public void setVideo(Uri videoPath) {
    videoUri = videoPath;
    File file = new File(videoPath.getPath());
    ParcelFileDescriptor pfd;

    FileDescriptor fd = new FileDescriptor();
    try {
        pfd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);
        fd = pfd.getFileDescriptor();
        metadataRetriever.setDataSource(fd);           
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

设置您要使用的视频。其次使用这种方法:

getFrameAtTime(long timeUs)

提取帧。请记住,您应该使用 微秒 作为参数

【讨论】:

  • 请在此处发布您的所有日志
  • 我在 setDataSource() 中遇到问题。 . .你能举一些例子来帮助我吗? . .
  • 抛出异常:在 FileNotFoundException 中找不到文件,Pllication 停止工作
猜你喜欢
  • 2014-12-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多