如何从iOS中的自定义视频播放器屏幕捕获静态图像?

时间:2016-05-03 04:53:52

标签: ios objective-c iphone avfoundation xcode7

我只是使用AVFoundation库的AVPlayer * myPlayer创建自己的自定义视频播放器。现在,我希望通过UIButton点击action上播放视频来捕获视频书签的图像。点击UIButton,它会拍摄播放器屏幕的快照并存储在文档目录中。 请建议我怎么做? 先感谢您。

2 个答案:

答案 0 :(得分:0)

Exception in thread "main" javax.naming.directory.InvalidSearchFilterException: Unbalanced parenthesis; remaining name 'ou=people,dc=example,dc=com'
    at com.sun.jndi.ldap.Filter.findRightParen(Filter.java:694)
    at com.sun.jndi.ldap.Filter.encodeFilterList(Filter.java:733)
    at com.sun.jndi.ldap.Filter.encodeComplexFilter(Filter.java:657)
    at com.sun.jndi.ldap.Filter.encodeFilter(Filter.java:118)
    at com.sun.jndi.ldap.Filter.encodeFilterString(Filter.java:74)
    at com.sun.jndi.ldap.LdapClient.search(LdapClient.java:548)
    at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1985)
    at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1844)
    at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1769)
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:392)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:358)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:341)
    at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:267)
    at jndi_tutorial.Test.getPeopleSnIsKumaran(Test.java:34)
    at jndi_tutorial.Test.main(Test.java:62)

参考链接:

Create a thumbnail or image of an AVPlayer at current time

答案 1 :(得分:0)

AVAsset *asset = [AVAsset assetWithURL:videoURL];
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
imageGenerator.appliesPreferredTrackTransform=TRUE;


CGImageRef imageRef = [imageGenerator copyCGImageAtTime:player.currentTime
                                             actualTime:NULL error:NULL];