avassetwriter

How to create a anAudioSampleBuffer for CMSampleBufferGetFormatDescription in iOS Swift

心已入冬 提交于 2020-05-15 08:39:11
问题 I have been working on video compression in iOS Swift, and following this SO's answer. It is working fine until I change this piece of code's file format to .mp4 let videoWriter = try! AVAssetWriter(outputURL: outputURL as URL, fileType: AVFileType.mov) There are reasons that I need the output in .mp4 file format. So when I do that it crashes the app. And gives me this error, 2020-04-27 18:20:52.573614+0500 BrightCaster[7847:1513728] *** Terminating app due to uncaught exception

Corrupt video capturing audio and video using AVAssetWriter

南楼画角 提交于 2020-01-24 21:30:07
问题 I am using an AVCaptureSession to use video and audio input and encode an H.264 video with AVAssetWriter . If I don't write the audio, the video is encoded as expected. But if I write the audio, I am getting a corrupt video. If I inspect the audio CMSampleBuffer being supplied to the AVAssetWriter it shows this information: invalid = NO dataReady = YES makeDataReadyCallback = 0x0 makeDataReadyRefcon = 0x0 formatDescription = <CMAudioFormatDescription 0x17410ba30 [0x1b3a70bb8]> { mediaType:

Swift Video Resizer AVAsset

匆匆过客 提交于 2020-01-21 05:21:07
问题 I have this code that resizes a video from 1280 x 720 to 640 x 360 But i want a resize with no crop. Is there a way to do a full resize the don't crop ? Here's the code class func resizer(inputURL : NSURL , completion: (outPutURL : NSURL?) -> Void ){ let videoAsset = AVAsset(URL: inputURL) as AVAsset let clipVideoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo).first! as AVAssetTrack let composition = AVMutableComposition() composition.addMutableTrackWithMediaType(AVMediaTypeVideo,

Changing AVCaptureDeviceInput leads to AVAssetWriterStatusFailed

风格不统一 提交于 2020-01-20 04:55:09
问题 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 )

Generating thumbnails from videos created using AVAssetWriter

血红的双手。 提交于 2020-01-14 10:13:29
问题 I'm recording video+audio using AVAssetWriter and the captureOutput callback. The problem is that in about 5% of the cases I cannot generate a thumbnail from second zero(If I try to go further in the video, then there is no problem). The error I'm getting is: Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo=0x4b31b0 {NSLocalizedFailureReason=This media cannot be used., NSUnderlyingError=0x4effb0 "The operation couldn’t be completed. (OSStatus error -12431.)",

Generating thumbnails from videos created using AVAssetWriter

隐身守侯 提交于 2020-01-14 10:13:07
问题 I'm recording video+audio using AVAssetWriter and the captureOutput callback. The problem is that in about 5% of the cases I cannot generate a thumbnail from second zero(If I try to go further in the video, then there is no problem). The error I'm getting is: Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo=0x4b31b0 {NSLocalizedFailureReason=This media cannot be used., NSUnderlyingError=0x4effb0 "The operation couldn’t be completed. (OSStatus error -12431.)",

How to use AVAssetReader and AVAssetWriter for multiple tracks (audio and video) simultaneously?

二次信任 提交于 2020-01-11 17:22:25
问题 I know how to use AVAssetReader and AVAssetWriter, and have successfully used them to grab a video track from one movie and transcode it into another. However, I'd like to do this with audio as well. Do I have to create and AVAssetExportSession after I've done with the initial transcode, or is there some way to switch between tracks while in the midst of a writing session? I'd hate to have to deal with the overhead of an AVAssetExportSession. I ask because, using the pull style method -

Performance issues when using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput

旧时模样 提交于 2020-01-10 09:14:04
问题 I'm having lag issues when I'm recording audio+video by using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput. Sometimes the video blocks for a few milliseconds, sometimes the audio is not in sync with the video. I inserted some logs and observed that first I get a lot of video buffers in captureOutput callback, and after some time I get the audio buffers(sometimes I don't receive the audio buffers at all, and the resulting video is without sound). If I comment the code that handles the

Performance issues when using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput

孤人 提交于 2020-01-10 09:13:49
问题 I'm having lag issues when I'm recording audio+video by using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput. Sometimes the video blocks for a few milliseconds, sometimes the audio is not in sync with the video. I inserted some logs and observed that first I get a lot of video buffers in captureOutput callback, and after some time I get the audio buffers(sometimes I don't receive the audio buffers at all, and the resulting video is without sound). If I comment the code that handles the

Performance issues when using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput

一曲冷凌霜 提交于 2020-01-10 09:13:10
问题 I'm having lag issues when I'm recording audio+video by using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput. Sometimes the video blocks for a few milliseconds, sometimes the audio is not in sync with the video. I inserted some logs and observed that first I get a lot of video buffers in captureOutput callback, and after some time I get the audio buffers(sometimes I don't receive the audio buffers at all, and the resulting video is without sound). If I comment the code that handles the