avassetexportsession

AVAssetExportSession video not saving as portrait orientation

跟風遠走 提交于 2019-12-11 10:09:50
问题 I want to record on video in custom view so I'm using AVFoundation as per below code. if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:outputFileURL]) { /** Below code works fine (save in portrait orientation) [library writeVideoAtPathToSavedPhotosAlbum:outputFileURL completionBlock:^(NSURL *assetURL, NSError *error) { if (!error) { self.doneButton.userInteractionEnabled = YES; [videoAddr addObject:assetURL]; videoURL = outputFileURL; } }];*/ AVMutableComposition *mixComposition = [

Unable to export AVPlayerItem

为君一笑 提交于 2019-12-11 08:15:41
问题 I'm using AVQueuePlayer to do playback of a list of videos in our app. I'm trying to cache the videos that are played by AVQueuePlayer so that the video doesn't have to be downloaded each time. So, after the video finishes playing, I attempt to save the AVPlayerItem into disk so next time it's initialized with a local URL. I've tried to achieve this through two approaches: Use AVAssetExportSession Use AVAssetReader and AVAssetWriter. 1) AVAssetExportSession approach This approach works like

AVAssetExportSession is greatly reducing video quality

ぐ巨炮叔叔 提交于 2019-12-11 06:35:48
问题 I have a local video url that I am trying to put an overlay on. It all works properly, but the quality of the video is being drastically reduced upon export. I have narrowed it down to find that it happens when I set the AVAssetExportSession.videoComposition (which I need to do for the overlay). If I set the export preset quality to Passthrough, then the video doesn't lose quality but the overlays don't appear. func merge3(url: URL) { activityMonitor.startAnimating() let firstAsset = AVAsset

AVAssetExportSession with and without break points

给你一囗甜甜゛ 提交于 2019-12-11 05:27:16
问题 I have simple video compression code in low quality conversion.I am testing my code in iphone 4 with IOS-4.2.1.The problem is when I test my code on device without break points the code failed to create video(it just a zero kb file or empty file created) but when I use breakpoint checking line by line this code slowly it will make a perfect compressed video which also runs on quicktime player in mac.After compression I make zip of this video file. NSURL *videoURL=[[self.videourlarray

Modifying Metadata from PHAsset with mediaType Video fails

≡放荡痞女 提交于 2019-12-11 05:21:56
问题 I try adding/modifying the Metadata from an PHAsset with mediaType == .video I found some Questions refering to a similar problem: How to change video metadata using AVAssetWriter? Add custom metadata to video using AVFoundation Regarding to the Answers in these Questions I build the following snippet which is a extension of a PHAsset: let options = PHVideoRequestOptions() options.version = .original PHImageManager.default().requestAVAsset(forVideo: self, options: options, resultHandler: {

AVAssetExportSession missing audio track when exporting on device

白昼怎懂夜的黑 提交于 2019-12-10 23:14:10
问题 I run the export on the simulator and everything works great. I run it on the device and the video gets exported but there's no audio. This leads me to believe that I must be using an audio format that the device doesn't support but OS X does, as the simulator uses what OS X uses. I've tried m4a, aiff, and aifc and have had no luck! Any ideas?? 回答1: I have a very similar problem. It does not seem to do with codecs, as I made a separate test case that runs fine with the same video. There’s a

Pausing and serializing an AVAssetExportSession

三世轮回 提交于 2019-12-10 20:27:01
问题 I'm trying to export several minutes of video in an AVAssetExportSession and it's taking a long time. My ideal way of doing this is pausing the AVAssetExportSession when the app closes and resuming it when the app reopens. Is there any way to pause an AVAssetExportSession, save its state, and reload it later? 来源: https://stackoverflow.com/questions/44812343/pausing-and-serializing-an-avassetexportsession

How to get and save the mixed of multiple audios in to single audio in swift

折月煮酒 提交于 2019-12-10 11:48:08
问题 I have multiple audios files(more than 3). By using the AVAudioEngine and AVAudioMixerNode I am playing the all audio tracks into a single track. I want to save the mixed audio in the document directory. Give suggestions to mix the multiple audios files and save in a document directory. Thank you 回答1: Try this: func mergeAudioFiles(files: [URL], completion: @escaping (_ succeeded: Bool)->()) { let composition = AVMutableComposition() guard let compositionAudioTrack:AVMutableCompositionTrack =

iOS 5: Error merging 3 videos with AVAssetExportSession

孤人 提交于 2019-12-09 10:51:24
问题 I'm trying to merge (append) 3 videos using AVAssetExportSession, but I keep getting this error. Weirdly for 1 or 2 videos it worked. Error Domain=AVFoundationErrorDomain Code=-11820 "Cannot Complete Export" UserInfo=0x458120 {NSLocalizedRecoverySuggestion=Try exporting again., NSLocalizedDescription=Cannot Complete Export} I even tried to redo the function in case of error but what I got is only infinite error message. This is the snippet of my code. AVMutableComposition *mixComposition =

AVAssetExportSession fails every time (error -12780)

一曲冷凌霜 提交于 2019-12-09 09:28:48
问题 I'm trying to merge some audio files (picked via MPMediaPickerController), but the export always fails with error code -12780. When I try to play my composition with an AVPlayer object, it plays correctly. Just the export fails. What am I doing wrong? This is my code: AVAssetExportSession *exportSession; AVPlayer *player; - (void)mergeAudiofiles { // self.mediaItems is an NSArray of MPMediaItems if (self.mediaItems.count == 0) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"