Tag: avfoundation

捕获的照片用AVCaptureSession sessionPreset = AVCaptureSessionPresetPhoto拉伸

重要提示:如果我使用: session.sessionPreset = AVCaptureSessionPresetHigh; 我的预览图像没有拉伸! 如果我将照片保存到设备UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); 图像是正常的,只有在预览它被拉伸。 我正在使用AVFoundation捕捉照片。 session = [[AVCaptureSession alloc] init]; session.sessionPreset = AVCaptureSessionPresetHigh; CALayer *viewLayer = vImagePreview.layer; NSLog(@"viewLayer = %@", viewLayer); AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; captureVideoPreviewLayer.frame = vImagePreview.bounds; [vImagePreview.layer addSublayer:captureVideoPreviewLayer]; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) […]

使用iOS 5 AV Foundation和core-image实时确定一张纸的边angular

我目前正在build立一个相机应用程序原型,应该能够识别桌子上的纸张。 关于这个的线索是它应该实时地进行识别,所以我捕捉了相机的videostream,这在iOS 5中可以很容易地用AV基础来完成。 我看着这里和这里 他们正在那里做一些基本的对象识别。 我发现在这个实时环境中使用OpenCV库不能以高性能的方式工作。 所以我需要的是一个algorithm来确定没有OpenCV的图像的边缘。 有没有人有一些示例代码片段展示了如何做到这一点,或指出我在正确的方向。 任何帮助,将不胜感激。

录制video时更换相机捕捉设备

我正在开发一个iPhone应用程序。 在此,要求暂停和恢复摄像机。 所以我使用AVFoundation而不是使用UIImagePickerController 。 我的代码是: – (void) startup :(BOOL)isFrontCamera { if (_session == nil) { NSLog(@"Starting up server"); self.isCapturing = NO; self.isPaused = NO; _currentFile = 0; _discont = NO; // create capture device with video input _session = [[AVCaptureSession alloc] init]; AVCaptureDevice *cameraDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if(isFrontCamera) { NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; AVCaptureDevice […]

使用AVFoundation逐帧录制audio和video

如何在iOS4中使用AVFoundation逐帧录制audio和video?

确定核心audioAudioBuffer中的帧数

我正在尝试访问iPhone / iPad上的audio文件的原始数据。 我有下面的代码,这是我需要的path基本开始。 但是,我有一个AudioBuffer后,我很难做什么。 AVAssetReader *assetReader = [AVAssetReader assetReaderWithAsset:urlAsset error:nil]; AVAssetReaderTrackOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[[urlAsset tracks] objectAtIndex:0] outputSettings:nil]; [assetReader addOutput:assetReaderOutput]; [assetReader startReading]; CMSampleBufferRef ref; NSArray *outputs = assetReader.outputs; AVAssetReaderOutput *output = [outputs objectAtIndex:0]; int y = 0; while (ref = [output copyNextSampleBuffer]) { AudioBufferList audioBufferList; CMBlockBufferRef blockBuffer; CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, […]

AVAudioEngine播放多声道audio

简单的问题。 如何使用AVAudioEngine播放多声道audio文件(> 2声道),以便在默认的双声道输出(耳机/扬声器)上听到所有声道。 以下代码(删除错误检查提交)播放文件的第一个两个渠道,但我只能听到耳机插入时听到。 AVAudioFile *file = [[AVAudioFile alloc] initForReading:[[NSBundle mainBundle] URLForResource:@"nums6ch" withExtension:@"wav"] error:nil]; AVAudioEngine *engine = [[AVAudioEngine alloc] init]; AVAudioPlayerNode *player = [[AVAudioPlayerNode alloc] init]; AVAudioMixerNode *mixer = [[AVAudioMixerNode alloc] init]; [engine attachNode:player]; [engine attachNode:mixer]; AVAudioFormat *processingFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:file.processingFormat.streamDescription->mSampleRate channels:2 interleaved:false]; [engine connect:player to:mixer format:processingFormat]; [engine connect:mixer to:engine.outputNode format:processingFormat]; [engine startAndReturnError:nil]; […]

在iOS 4.0中使用AVPlayer进行HTTP实时stream式传输?

是否可以在iOS 4.0上使用AVPlayer的HTTP Live Streaming? 这显然是4.0的loggingfunction。 但是,如果我在运行iOS 4.0.1的3GS上运行Apple的SitchedStreamPlayer示例代码 ,则单击“加载电影”不会播放stream,但会出现错误: 2011-06-21 13:14:49.428 StitchedStreamPlayer [680:307]资产的曲目由于错误而未被加载:无法打开 MPMediaPlayer能够在相同的设备上播放相同的stream 。 但是,我需要AVPlayer的解决scheme。 有谁知道如何让苹果的StichedStreamPlayer代码工作在4.0? 运行时需求说它应该在“iOS 4.0或更高版本”上工作。 谢谢!

添加AVMutableVideoComposition的文本覆盖到特定的时间范围

我发现了一些示例,展示了如何在video上添加文字叠加层。 Ray的教程 – http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos 这就是答案 – 如何在iOS上捕获的video中添加水印 还有一些我也提到了。 我的代码看起来几乎与该答案相同,我一直在试图调整它以使文本覆盖在video的开头只显示一两秒钟。 任何帮助,我怎么能做到这一点? 这是我的代码。 这是工作原理导出video覆盖显示整个持续时间。 if(vA) { videoCompositionTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; [videoCompositionTrack insertTimeRange:videoTimerange ofTrack:[[vA tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:&error]; [videoCompositionTrack setPreferredTransform:[[[vA tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] preferredTransform]]; if(error) NSLog(@"%@", error); } if(aA) { audioCompositionTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; [audioCompositionTrack insertTimeRange:audioTimerange ofTrack:[[aA tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] atTime:kCMTimeZero error:&error]; if(error) NSLog(@"%@", error); } CGSize videoSize […]

获取相机预览AVCaptureVideoPreviewLayer

我试图让相机input显示在预览图层视图上。 self.cameraPreviewView绑定到IB中的UIView 这是我从AV Foundation编程指南中整理出来的最新代码。 但预览从不显示 AVCaptureSession *session = [[AVCaptureSession alloc] init]; session.sessionPreset = AVCaptureSessionPresetHigh; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) { NSLog(@"Couldn't create video capture device"); } [session addInput:input]; // Create video preview layer and add it to the UI AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer […]

AVSpeechSynthesizer在后台模式下

我的iOS应用程序处于后台模式时无法使iOS 7 AVSpeechSynthesizer工作。 我已经添加了“ 应用程序播放audio ”键的应用程序的支持的背景模式,但我仍然无法得到它的工作。 我也调查了用AVMutableCompositionTrack话语创build一个AVMutableCompositionTrack的可能性,然后用一个能够在后台运行的玩家以某种方式玩它,但没有运气。 在后台使用AVSpeechSynthesizer有没有人比我有更好的运气?