avfoundation

AVPlayer Reverse Playback

邮差的信 提交于 2019-11-29 09:37:40
问题 How would one go about getting an AVPlayer object to play its video content in reverse? The AVPlayerItem class has a property called "reversePlaybackEndTime," which makes me think that reverse playback is thus possible, but I can't seem to find anything in the docs about actually doing it. 回答1: You can reverse play like this as queuePlayer is AVPlayer : Firstly get to end of video CMTime durTime = self.queuePlayer.currentItem.asset.duration; durationTime = CMTimeGetSeconds(durTime); //NSLog(@

Video Recording using AVFoundation

强颜欢笑 提交于 2019-11-29 09:23:18
问题 I am trying to record video using AVFoundation. When I add video input only to the session, everything works fine but when I add an audio input to it, it stops recording the video.(Delegate method is called immediately after recording starts). Here is my code: -(void) recordVideo { self.session = [[AVCaptureSession alloc] init]; if([session canSetSessionPreset:AVCaptureSessionPresetMedium]) session.sessionPreset = AVCaptureSessionPresetMedium; CALayer *viewLayer = [self.cameraView layer];

Play multiple Audio Files with AVPlayer

家住魔仙堡 提交于 2019-11-29 09:15:45
I'm trying to play multiple sounds at the same time. The approach initially I've taken was to create several players , but it seems wrong one. What's the best way to play several audio files at the same time. Is it through making them AVAssets, but in this case how would I stop and play them whenever I want. Really appreciate your help. The reason I need AVPlayer is to fetch sounds from the iPod Library. I finally got an answer from TechSupport of Apple Dev Team and it seems I'm on the right track when I decided to use several AVPlayer. For every sound you want to make make a new AVPlayer.

convert CMSampleBufferRef to UIImage

点点圈 提交于 2019-11-29 08:16:14
I'm captuting video with AVCaptureSession. But I would like to convert the captured image to an UIImage. I found some code on Internet: - (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer { NSLog(@"imageFromSampleBuffer: called"); // Get a CMSampleBuffer's Core Video image buffer for the media data CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); // Lock the base address of the pixel buffer CVPixelBufferLockBaseAddress(imageBuffer, 0); // Get the number of bytes per row for the pixel buffer void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer);

Issue playing slow-mo AVAsset in AVPlayer

和自甴很熟 提交于 2019-11-29 08:13:40
I'm trying to play an slow motion video (filmed by the user's iPhone) in an AVPlayer . I am retrieving the AVAsset with a request on a PHAsset from a picker: [manager requestAVAssetForVideo:PHAsset options:videoRequestOptions resultHandler:^(AVAsset * avasset, AVAudioMix * audioMix, NSDictionary * info) {}]; The problem is once it plays, I get this error: -[AVComposition URL]: unrecognized selector sent to instance 0x138d17f40 However, if I set this option on the manager request, it will play as normal speed video at 120/240fps and no crashes: videoRequestOptions.version =

How to convert AudioBufferList to CMSampleBuffer?

六眼飞鱼酱① 提交于 2019-11-29 08:13:25
I have an AudioTapProcessor attached to AVPlayerItem. which will call static void tap_ProcessCallback(MTAudioProcessingTapRef tap, CMItemCount numberFrames, MTAudioProcessingTapFlags flags, AudioBufferList *bufferListInOut, CMItemCount *numberFramesOut, MTAudioProcessingTapFlags *flagsOut) when processing. I need to convert the AudioBufferList to CMSampleBuffer so I could use AVAssetWriterAudioInput.appendSampleBuffer to write it into a movie file. So how to convert AudioBufferList to CMSampleBuffer ? I tried this but got -12731 error:Error cCMSampleBufferSetDataBufferFromAudioBufferList

Create an application that creates a video from iphone screen and add audio from headphones / audio input

我的梦境 提交于 2019-11-29 07:57:20
I m trying to create a tutorial video from ipad screen as done in this application (ShowME) Using AVAssetWriter I am able to capture a video of the screen. I tried using AVCaptureDevice, but Its not working. I dont know what is going wrong. I learned capturing video from iphone screen from this link - A very nice turorial. But it does not captures any audio along with screen video. So I gave a try like this: -(void)setUpMike{ NSError* error = nil; // Setup the audio input AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeAudio]; AVCaptureDeviceInput

How to Programmatically Take Photos While Recording Video

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 07:52:17
The iPhone 5S is capable of taking pictures while recording video and I am trying to figure out how I would do this programatically. I know I would be utilizing AVFoundation, however, I couldn't find anything in the programming guide regarding this. I have also checked the sample projects (AVFoundation-related) and it doesn't look like there is anything there that does what I am looking for. if you could help point me in the right direction that would be great. Actually you can do it with any device that can record video: Create and configure a AVCaptureVideoDataOutput . Add it to your

Trying to stream audio from microphone to another phone via multipeer connectivity

假装没事ソ 提交于 2019-11-29 07:01:48
I am trying to stream audio from the microphone to another iPhone via Apples Multipeer Connectivity framework. To do the audio capturing and playback I am using AVAudioEngine (much thanks to Rhythmic Fistman' s answer here ). I receive data from the microphone by installing a tap on the input, from this I am getting a AVAudioPCMBuffer which I then convert to an array of UInt8 which I then stream to the other phone. But when I am converting the array back to an AVAudioPCMBuffer I get an EXC_BAD_ACCESS exception with the compiler pointing to the method where I am converting the byte array to

Changing AVCaptureDeviceInput leads to AVAssetWriterStatusFailed

北城余情 提交于 2019-11-29 07:00:39
I am trying to change the Camera View Front and Back .it is working well.if video is recorded without flipping with Pause/Record Option it is working fine.But if we Flip Camera View once then, further recording video is not saving which leads to AVAssetWriterStatusFailed - The operation could not be completed . Can anybody help me to find where i have gone wrong ? Below is my code. Camera.m - (void)flipCamera{ NSArray * inputs = _session.inputs; for ( AVCaptureDeviceInput * INPUT in inputs ) { AVCaptureDevice * Device = INPUT.device ; if ( [ Device hasMediaType : AVMediaTypeVideo ] ) {