从我所读到的苹果不暴露api允许开发人员使用当前的sdk获取电影的缩略图.
任何人都可以分享一些关于他们如何处理这个问题的代码吗?我听说你可以访问相机选择器视图,并在ui图像选择器关闭之前找到图像视图.这看起来有点难看.
我还考虑过使用ffmpeg从电影中抓取一个帧但是不知道如何将其编译为iphone的库.任何指针都将非常感激
我正在编写一个应用程序来显示iphone相机所看到的光线条件的统计数据.我每秒拍摄一张图像,并对其进行计算.
要捕获图像,我使用以下方法:
-(void) captureNow
{
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in captureManager.stillImageOutput.connections)
{
for (AVCaptureInputPort *port in [connection inputPorts])
{
if ([[port mediaType] isEqual:AVMediaTypeVideo] )
{
videoConnection = connection;
break;
}
}
if (videoConnection) { break; }
}
[captureManager.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
latestImage = [[UIImage alloc] initWithData:imageData];
}];
}
Run Code Online (Sandbox Code Playgroud)
然而,该captureStillImageAsynhronously....方法导致手机播放"快门"声音,这对我的应用程序没有好处,因为它将不断捕获图像.
我已经读过,无法禁用此声音效果.相反,我想从手机的视频输入中捕获帧:
AVCaptureDeviceInput *newVideoInput = [[AVCaptureDeviceInput alloc] initWithDevice:[self backFacingCamera] error:nil];
Run Code Online (Sandbox Code Playgroud)
并希望将这些变成UIImage对象.
我怎么做到这一点?我不太了解AVFoundation的工作原理 - 我下载了一些示例代码并为我的目的修改了它.