avfoundation

iPhone (SDK 2.2): adusting playback volume while NOT actively playing music w/ AVFoundation?

折月煮酒 提交于 2019-12-03 10:14:13
问题 So I have an app which plays many short sound clips. I need to know when the sounds are finished playing, and I need to use mp3s, so I'm using AVFoundation for the sound playback. When a sound is actively playing, and the user uses the hardware volume buttons, the playback volume changes. Problem is, the app is NOT constantly playing sounds, and when it's not, and the hardware buttons are used, the RINGER volume gets adjusted instead. How do I set it up so, as long as the app is running, the

How to compress video using AVFoundation in iOS [closed]

末鹿安然 提交于 2019-12-03 10:13:32
Is there are any compression technique in iPhone to compress video using AVfoundation. or any open source. Regards, Jeeva KPM Try this :) + (void)convertVideoToLowQualityWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL successHandler:(void (^)())successHandler failureHandler:(void (^)(NSError *))failureHandler { if([[NSFileManager defaultManager] fileExistsAtURL:outputURL]) [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]

AVAssetWriter multiple sessions and the status property

帅比萌擦擦* 提交于 2019-12-03 09:55:54
问题 I am attempting to create multiple, serial writing sessions with AVAssetWriter. Once I've completed one successfully (after calling finishWriting) the status is set to 2 (AVAssetWriterStatusCompleted). Trying to create another session, I call startWriting, but I get the error: [AVAssetWriter startWriting] cannot call method when status is 2 Seems I cannot create a writing session unless I configure something. Do I have to recreate the AVAssetWriter again? I must be missing something, and the

What's the SIMPLEST way to play a sound clip in an iPhone app?

只愿长相守 提交于 2019-12-03 09:48:52
I want to be able to play a sound clip in an iPhone OS app. I've seen info on both NSSound as well as AVFoundation as being means for getting sound clips played on an iPhone OS device, but I'm still not clear on the subject and could use some help. No need to spell it out for me step-by-step in actual code, but if someone could give me a hint as to the general direction (i.e. which classes I should be focusing on) in which I should start moving I'll fill in the blanks myself. So, what's the SIMPLEST way to play a sound clip in an iPhone app? Apple has an article on this subject, see: this link

Creating a movie file of a animation with avassetwriter

自作多情 提交于 2019-12-03 09:29:32
I have a animation created using normal core animation methods. If there any way to create a movie file using avassetwriter? Ive seen other questions which show the how to use avassetwriter to create a movie using images, but i would like to create a movie using a animation created with core animation. Thank in advance invalidname Run a timer (or whatever) to periodically convert the animation's CALayer to a UIImage (see here ), then write that image to the AVAssetWriter as seen in the other examples you cite. You'll also need to keep track of elapsed time, because ultimately what you're

streaming images over bonjour between two iOS device

為{幸葍}努か 提交于 2019-12-03 09:12:58
My goal is to stream images captured by AVCpatureInput from one iOS device to another via bonjour. Here is my current method: 1) Capture frame from video input - (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) Send over TCP connection (from http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/ ) // Send raw image over network - (void

Mixing two Audio Files using AVComposition on IOS

给你一囗甜甜゛ 提交于 2019-12-03 09:09:58
I'm trying to mix two audio files (lay one audio file on top of the other - not stitched together) but I'm struggling with learning AVFoundation on IOS. I've followed this answer here: How to merge Audio and video using AVMutableCompositionTrack And this is what I have : //NSURL *audioFilePath = [NSURL fileURLWithPath:@"var/mobile/Applications/822732B6-67B9-485F-BA44-FAACAB34C4FD/Documents/Coisir Cheoil10_09_2014_1429.m4a"]; NSURL *audioUrl = [NSURL fileURLWithPath:@"var/mobile/Applications/822732B6-67B9-485F-BA44-FAACAB34C4FD/Documents/Robot R-3-311_09_2014_2252.m4a"]; // need to fix link to

Is it possible to make AVURLAsset work without a file extension?

此生再无相见时 提交于 2019-12-03 09:06:18
问题 I’m trying to create thumbnails for video files: - (UIImage*) thumbnailForVideoAtURL: (NSURL*) videoURL { AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil]; AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; CGImageRef imageHandle = [generator copyCGImageAtTime:kCMTimeZero actualTime:NULL error:NULL]; if (imageHandle) { UIImage *frameImage = [UIImage imageWithCGImage:imageHandle]; CFRelease(imageHandle); return frameImage; } else {

Modify AVCaptureSession before saving with AVCaptureMovieFileOutput

╄→尐↘猪︶ㄣ 提交于 2019-12-03 08:49:06
Use Case: I want to capture input from the camera, draw on top of the captured frames (and sound) and save the result as a .mov file. I see that I can capture input for the camera using AVCaptureSession. I can save this to a .mov file using AVCaptureMovieFileOutput. AVVideoComposition can be used to add Core Animation for playback. I assume for recording somehow too? Problem: I can't see how to modify the input before it is saved to file. The RosyWriter was almost doing what I wanted. Adding the following code to captureOutput:didOutputSampleBuffer:fromConnection: enabled me to draw onto the

iOS rotate every frame of video

▼魔方 西西 提交于 2019-12-03 08:37:52
I need to rotate a video because of iPhone back camera is recording as if it were always on landscape left. I need to physically rotate video because settings orientation don't work on all browser (ex. Chrome). So I setup some code to read recorded video and saving it after rotation. I used AVAssetExportSession which seems to work quite well apart two problems: - the exported video have some black frames at the beginning - some videos won't be exported. Is it possible to have some insight about the problem? Thanks! Code: AVAsset* asset = [AVURLAsset URLAssetWithURL: videoUrl options:nil];