获取iPhone上的流媒体视频截图
我怎样才能得到iPhone上的流媒体视频的截图。 我尝试了几种方法。
UIGetScreenImage() - >这是私人的。 如果我使用它,该应用程序将被拒绝。
UIGraphicsBeginImageContext(CGSizeMake(1024,768)); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
The code above cannot take the screenshot of video layer.
MPMoviePlayerController * movie = [[MPMoviePlayerController alloc] initWithContentURL [NSURL URLWithString:@“myMovie.mp4”]]; UIImage * singleFrameImage = [movie thumbnailImageAtTime:10 timeOption:MPMovieTimeOptionExact];
The code above does not work on a streaming video.
除AVFoundation之外,我还有什么可以尝试。 谢谢。
不知道它是否会工作,但你有没有尝试过使用AVPlayer? 它应该允许你访问你可以传递给AVAssetImageGenerator的AVURLAsset。
AVPlayerItem *item = [AVPlayerItem playerItemWithURL:yourURL];
AVPlayer *player = [AVPlayer playerWithPlayerItem:pItem];
//observe 'status'
[playerItem addObserver:self forKeyPath:@"status" options:0 context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"status"]) {
AVPlayerItem *item = (AVPlayerItem *)object;
if (item.status == AVPlayerItemStatusReadyToPlay) {
AVURLAsset *asset = (AVURLAsset *)item.asset;
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
CGImageRef thumb = [imageGenerator copyCGImageAtTime:CMTimeMakeWithSeconds(10.0, 1.0)
actualTime:NULL
error:NULL];
}
}
}
链接地址: http://www.djcxy.com/p/51521.html
上一篇: Get the screenshot of a streaming video on iphone
下一篇: Delegate conversion breaks equality and unables to disconnect from event