Tag: avfoundation

在Mac OS X 10.7 Lion上使用Core Animation进行AVFoundation问题

随着Mac OS X 10.7苹果已经推出了AVFoundation,我试图生成一个简单的快速时间电影包含animation形状。 问题是,核心animation不渲染,我最终只有一个空白的“黑”video。 以下是我使用的代码。 我已经尝试了许多变化,但唉,他们都没有工作。 导出状态始终为“已完成”。 奇怪的是,用户界面视图包含另一个图层设置,但添加到AVSynchronizedLayer,它显示得很好,我可以在animation中来回擦洗。 // NOTE: composition is an AVMutableComposition containing a single video // track (30s of black in 1280 x 720). // Create the animated layer CALayer *renderAnimLayer = [CALayer layer]; renderAnimLayer.frame = CGRectMake(0, 0, 1280, 720); // — EDIT: Added animated square (now animates) renderAnimLayer.backgroundColor = CGColorCreateGenericRGB(0.3, […]

使用HTTP NSURL创buildAVAsset

我试图合并两个包含video引用的NSURLs 。 其中一个url指向AWS上的video,另一个指向本地存储的video。 我的导出代码工作,因为我已经试过了两个本地video,但每当我尝试合并HTTP URL和本地URL我得到此错误: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x155d2f20 {NSUnderlyingError=0x155b4f60 "The operation couldn't be completed. No such file or directory", NSLocalizedDescription=The requested URL was not found on this server.} Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x155d2f20 {NSUnderlyingError=0x155b4f60 "The operation couldn't […]

AVPlayerdynamic音量控制

如何dynamic更改AVPlayer的音量? 我的意思是,我想在每次按下button时将音量静音。 给定的代码似乎只能在编译时改变它。 如何在运行时间呢? AVURLAsset *asset = [AVURLAsset URLAssetWithURL:[self myAssetURL] options:nil]; NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio]; NSMutableArray *allAudioParams = [NSMutableArray array]; for (AVAssetTrack *track in audioTracks) { AVMutableAudioMixInputParameters *audioInputParams =[AVMutableAudioMixInputParameters audioMixInputParameters]; [audioInputParams setVolume:0.0 atTime:kCMTimeZero]; [audioInputParams setTrackID:[track trackID]]; [allAudioParams addObject:audioInputParams]; } AVMutableAudioMix *audioZeroMix = [AVMutableAudioMix audioMix]; [audioZeroMix setInputParameters:allAudioParams]; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset]; [playerItem setAudioMix:audioZeroMix]; AVPlayer […]

捕获仍然没有压缩UIImage(从CMSampleBufferRef)?

我需要从CMSampleBufferRef的未压缩的图像数据获取UIImage 。 我正在使用的代码: captureStillImageOutput captureStillImageAsynchronouslyFromConnection:connection completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) { // that famous function from Apple docs found on a lot of websites // does NOT work for still images UIImage *capturedImage = [self imageFromSampleBuffer:imageSampleBuffer]; } http://developer.apple.com/library/ios/#qa/qa1702/_index.html是imageFromSampleBuffer函数的链接。 但它不能正常工作。 🙁 有一个jpegStillImageNSDataRepresentation:imageSampleBuffer方法,但它提供了压缩的数据(以及因为JPEG)。 捕获静止图像后,如何使用最原始的非压缩数据创buildUIImage ? 也许,我应该指定一些设置video输出? 我目前正在使用这些: captureStillImageOutput = [[AVCaptureStillImageOutput alloc] init]; captureStillImageOutput.outputSettings = @{ (id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA) […]

将NSDatavideo文件合并到一个video文件

我有一堆video文件,我想合并成一个video文件,我正在使用NSMutableData来实现任务 NSMutableData *concatenatedData = [[NSMutableData alloc] init]; for (int i=0; i <[videoArray count]; i ++) { [concatenatedData appendData: [videoArray objectAtIndex:i]]; } [concatenatedData writeToFile:[[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(), @"outputConct.mov"] atomically:YES]; UISaveVideoAtPathToSavedPhotosAlbum([[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(),@"outputConct.mov"], nil, nil, nil); 在video保存在我的相机胶卷后,我尝试播放,但只有第一个NSDatavideo。 我不知道为什么。 编辑 我试过AVMutableComposition,即使那样我也有同样的问题 AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init]; AVURLAsset* firstAsset; AVMutableCompositionTrack *firstTrack; CMTime time = kCMTimeZero; for (int […]

在两台iOS设备之间通过bonjourstream式传输图像

我的目标是通过bonjour将AVCpatureInput捕获的图像从一台iOS设备stream式传输到另一台iOS设备。 这是我目前的方法: 1)从videoinput捕捉帧 – (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { /*code to convert sampleBuffer into UIImage */ NSData * imageData = UIImageJPEGRepresentation(image,1.0); [connection sendImage:image]; } 2)通过TCP连接发送(来自http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/ ) // Send raw image over network – (void)sendRawImagePacket:(UIImage *)image { // Encode packet NSData * imageData = UIImageJPEGRepresentation(image, 1.0); NSData * rawPacket = [NSKeyedArchiver archivedDataWithRootObject:imageData]; // Write header: […]

以与预览图层相匹配的大小导出AVCaptureSessionvideo

我使用AVCaptureSession录制video,会话预设为AVCaptureSessionPreset640x480 。 我正在使用非标准尺寸(300 x 300)的AVCaptureVideoPreviewLayer ,并在录制时将重力设置为方向填充。 它的设置是这样的: self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession]; _previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; _previewLayer.frame = _previewView.bounds; // 300 x 300 [_previewView.layer addSublayer:_previewLayer]; 录制video后,我想以快速格式将其写入文件。 在播放过程中,我再次以300 x 300的非标准尺寸图层播放video。 由于这些video最终将通过networking连接进行传输,因此保留完整的640x480video看起来很浪费。 导出video以匹配我的300 x 300预览图层的最佳方式是什么? 我是一个AVFoundation noob,所以如果我正在做这个错误的方式,请让我知道。 我只想在logging期间预览层中显示的录制video与磁盘上导出的video相匹配。

在locking屏幕上设置和访问iOS查找栏

我正在使用AVQueuePlayer / AVFoundation在iOS应用程序中播放audio文件。 我已经设置了MPNowPlayingInfoCenter现在正在播放像专辑标题,艺术家,艺术品这样的信息 NSMutableDictionary *albumInfo = [[NSMutableDictionary alloc] init]; MPMediaItemArtwork *artworkP; UIImage *artWork = [UIImage imageNamed:album.imageUrl]; [albumInfo setObject:album.title forKey:MPMediaItemPropertyTitle]; [albumInfo setObject:album.auther forKey:MPMediaItemPropertyArtist]; [albumInfo setObject:album.title forKey:MPMediaItemPropertyAlbumTitle]; [albumInfo setObject:artworkP forKey:MPMediaItemPropertyArtwork]; [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:albumInfo] 并在应用程序委托中访问远程事件进行播放,暂停,接下来,从locking屏幕上一个事件。 但是search栏不可访问,即使我没有find任何设置search属性的选项。 我想设置seek属性,并希望访问我的应用程序中的查找滑块更改事件。

重新打开AVCaptureSession

我有一个应用程序,需要一些照片。 我的整个应用程序是基于WWDC 2010的AVCam示例代码。我已经搞砸了很多,但到目前为止,我无法弄清楚如何正确释放相机视图,从而释放相机会话… 我想要做的是以下几点: 打开相机视图控制器 拍一些照片 closures相机视图控制器 再次打开它 第二次我推视图控制器会话丢失,预览不可用,捕获也不可用。 我已经在github上发布了完整的示例代码 。 我的问题的解决方法是不释放相机,所以相机视图控制器作为一个单身人士,我认为这是不正确的方式。 此外,有了这种行为,我不能找出一种方法来支持相机,当应用程序进入后台(例如电话)。 请指教 。 如何破坏相机会话? 这么做很重要吗?

在AVPlayer中播放与糟糕的互联网stream

AVPlayer播放来自networkingstream的资源时,会在下载内容到达时暂停。 所以,我的问题是,如何知道,它因为networking不好而停止? 如何在下载之后播放它,比如说,下一个10秒的资产?