avfoundation

Adjust AVPlayer Frame Rate During Playback

我们两清 提交于 2019-11-30 23:12:51
Is there a way to change the rate at which frames are rendered during playback? I have a couple short 5 second videos that I would like to play at 15, 30, or 60 FPS. This would be an option to the user. I did find a frameDuration property in the AVVideoComposition class. But all this did was adjust how many frames rendered per second. Jean Fabre Similar question here There is a rate property in the AVPlayer. It worked very well from me. Tho the rate values ranges from 0 to 2, 1 being played at normal speed, so to give the option to the suer to play at pre defined framerate would required some

iPhone: NSData representation of Audio file for Editing

╄→гoц情女王★ 提交于 2019-11-30 22:40:57
I have been scratching my head since long now but not getting around to this. I haven't found a single example for Audio editing! I want to insert new Audio file in between somewhere in original Audio file, save it as new converted audio files. For this I have written following code. I got this idea from here . NSString *file1 = [[NSBundle mainBundle] pathForResource:@"file1" ofType:@"caf"]; // Using PCM format NSString *file2 = [[NSBundle mainBundle] pathForResource:@"file2" ofType:@"caf"]; NSData *file1Data = [[NSData alloc] initWithContentsOfFile:file1]; NSData *file2Data = [[NSData alloc]

AVAudioSession setCategory not working

瘦欲@ 提交于 2019-11-30 21:56:27
I have a video capturing app and I want to be able to play background music while recording audio+video. I can accomplish this if I set the AVAudioSession category to PlayAndRecord in didFinishLaunchingWithOptions . However, this causes a glitch in the audio whenever the view with the camera enters or exits the foreground, and its apparently impossible to get rid of: https://forums.developer.apple.com/message/74778#74778 I can live with the glitch if it just happens when I start/stop recording video, but that means I need to change the AVAudioSession category from Ambient to PlayAndRecord when

iOS8 AVAudioEngine how to send microphone data over Multipeer Connectivity?

送分小仙女□ 提交于 2019-11-30 21:10:51
I want to send microphone audio data over Multipeer Connectivity (iOS 8) and play it through the speaker of the receiving peer. I've also setup the AVAudioEngine and I can hear the microphone data from the (upper) speaker output, but I don't know how to send AVAudioPCMBuffer over the network. Here's my code snippet: AVAudioInputNode *inputNode =[self.engine inputNode]; AVAudioMixerNode *mainMixer = [self.engine mainMixerNode]; [self.engine connect:inputNode to:mainMixer format:[inputNode inputFormatForBus:0]]; [mainMixer installTapOnBus:0 bufferSize:4096 format:[mainMixer outputFormatForBus:0]

Video rotated after applying AVVideoComposition

女生的网名这么多〃 提交于 2019-11-30 20:10:41
After applying an AVVideoComposition to my AVPlayerItem , the filter I apply does work, but the video gets rotated in the AVPlayerLayer . I know for a fact that the problem is not with the filtered frame because if I show the frame in a UIImageView , the frame is rendered 100% correctly. The video shows correctly until I apply a videoComposition . Setting the videoGravity on the AVPlayerLayer does not help. The video gets rotated 90º clockwise and gets stretched in the layer. Essentially, the video is displayed perfectly in the AVPlayerLayer before the AVPlayerItem is fed through the

AVAssetWriterInput and readyForMoreMediaData

谁说胖子不能爱 提交于 2019-11-30 20:10:33
Is AVAssetWriterInput's readyForMoreMediaData updated in a background thread? If readyForMoreMediaData is NO, can I block in the main thread and wait until the value changes to YES? I'm using an AVAssetWriterInput by pushing data to it (i.e. without using requestMediaDataWhenReadyOnQueue) and I've set expectsMediaDataInRealTime, and 99.9% of the time I can just call appendSampleBuffer (or appendPixelBuffer) on it as fast as my app can generate frames. This works fine unless you put the device (iPhone 3GS) to sleep for 15 minutes or so in the middle of an AVAssetWriter session. After waking up

Replay items in AVQueuePlayer after last

杀马特。学长 韩版系。学妹 提交于 2019-11-30 19:13:25
I need to create something like an infinite loop in my AVQueuePlayer . Especially, I want to replay the whole NSArray of AVPlayerItem s once the last component finishes playing. I must admit that I actually do not have any idea how to achieve this and hope you can give me some clues. best way to loop a sequence of videos in AVQueuePlayer. observe for each playeritem in AVQueuePlayer. queuePlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; for(AVPlayerItem *item in items) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nextVideo:) name

Help me understand CMTime in AVAssetWriter

不羁的心 提交于 2019-11-30 19:05:23
问题 I'm having a hard time understanding how to convert a stream of motion JPEG at 30fps using the AVAssetWriter to a video file. The part I'm not getting is the [adaptor appendPixelBuffer:buffer withPresentationTimeresentTime] method. How do I calculate the withPresentationTime value if I want to output 30fps mpeg4 video? The video source is a camera that streams 30fps motion JPEG in real time. Appreciate any idea. Thanks 回答1: You will need to generate a CMTime structure using CMTimeMake. You

CMSampleBufferSetDataBufferFromAudioBufferList returning error 12731

烂漫一生 提交于 2019-11-30 18:57:05
问题 I am trying to capture app sound and pass it to AVAssetWriter as input. I am setting callback for audio unit to get AudioBufferList. The problem starts with converting AudioBufferList to CMSampleBufferRef. It always return error -12731 which indicates that required parameter is missing Thanks Karol -(OSStatus) recordingCallbackWithRef:(void*)inRefCon flags:(AudioUnitRenderActionFlags*)flags timeStamp:(const AudioTimeStamp*)timeStamp busNumber:(UInt32)busNumber framesNumber:(UInt32

How to Fix capturing images with front facing camera mirrors image, AVFoundation,Swift

旧城冷巷雨未停 提交于 2019-11-30 18:41:23
问题 How to Fix capturing images with front facing camera mirrors image? SnapChat seems to fix it as well as WhatsApp and Instagram , how can i? i would really love to find a solution for this... its quite of annoying...Thanks ahead I have seen Always seeing Mirror image while capturing from Front Camera iOS 5.0 but it flip the images both for rear camera and frontal which doesnt solve the problem for anyone really . if anyone can help me figure out how to only flip the front camera images or any