avassetexportsession

Square cropping and fixing the video orientation in iOS

不羁岁月 提交于 2019-11-30 06:23:36
问题 I am capturing the video using UIImagePickerController, i can crop the video using the following code, AVAsset *asset = [AVAsset assetWithURL:url]; //create an avassetrack with our asset AVAssetTrack *clipVideoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; //create a video composition and preset some settings AVMutableVideoComposition* videoComposition = [AVMutableVideoComposition videoComposition]; videoComposition.frameDuration = CMTimeMake(1, 30); //here we are

Cropping AVAsset video with AVFoundation

不问归期 提交于 2019-11-30 06:16:13
问题 I am using AVCaptureMovieFileOutput to record some video. I have the preview layer displayed using AVLayerVideoGravityResizeAspectFill which zooms in slightly. The problem I have is that the final video is larger, containing extra image that didn't fit on the screen during preview. This is the preview and resulting video Is there a way I can specify a CGRect that I want to cut from the video using AVAssetExportSession ? EDIT ---- When I apply a CGAffineTransformScale to the AVAssetTrack it

Unable to trim a video using AVAssetExportSession

我的未来我决定 提交于 2019-11-30 05:44:40
I want to trim a video: -(void)trimVideo:(NSURL*)outputURL { //[[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:outputURL options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality]; NSString * outputFilePath = NSHomeDirectory(); outputFilePath = [outputFilePath stringByAppendingPathComponent:@"Library"]; outputFilePath = [outputFilePath stringByAppendingPathComponent:@"temp.mov"]; NSURL * outputFileUrl = [NSURL fileURLWithPath:outputFilePath]

How to merge video and audio files?

£可爱£侵袭症+ 提交于 2019-11-29 23:06:26
问题 My question is: How to merge video and audio files that has almost the same duration? I searched and got some answers to this question. However when I try the code they gave, it just does not produce a "non-zero byte" movie. Could you take a look at it and see where it went wrong? -(void)putTogether { NSLog(@"Starting to put together all the files!"); AVMutableComposition *mixComposition = [AVMutableComposition composition]; NSString *audioPath = @"/Users/admin/Documents/Sound.caf"; NSURL

AVAssetExportSession in ios 10 not working for iPhone 7

风格不统一 提交于 2019-11-29 16:58:46
When I am blending two videos with AVAssetExportSession in ios 9 its working perfectly. but when i blend with AVAssetExportSession in iOS 10, it in not working. Please help me if any know the reason, Thank you. actualy code is working for iphone 6s and earlier, but not for working for iPhone 7 for example -(void) blendVideoOverVideo:(NSURL*)mainVideoUrl andBlendVideoUrl:(NSURL*)liveEffectUrl { AVURLAsset *mainVideoUrlAsset =[AVURLAsset URLAssetWithURL:mainVideoUrl options:nil]; // AVPlayerItem* mainVideoPlayerItem =[[AVPlayerItem alloc]initWithAsset:mainVideoUrlAsset]; AVAssetTrack*

Setting multiple Volumes to each Video tracks using AudioMixInputParameters AVFoundation is not working in Swift iOS

核能气质少年 提交于 2019-11-29 16:21:58
I am working on Video based Application in Swift . As per the requirement I have to select multiple Videos from Device Gallery , setting up different different CIFilter effects and Volume for each Video Asset and then merge all the Videos and have to Save the Final Video . As an output, when I will play the Final Video then Video sound volume should change accordingly. I have already merged all the selected Video Assets into one with different different CIFilter effects but my problem is when I am trying to set Volume for each Video Clips then it's not working. I am getting the default Volume

AVMutableComposition - Blank/Black frame between videos assets

…衆ロ難τιáo~ 提交于 2019-11-29 15:18:03
问题 I'm currently trying to put 5 videos back to back using AVMutableComposition like so: [mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset1.duration) ofAsset:asset1 atTime:[mixComposition duration] error:nil]; [mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset2.duration) ofAsset:asset2 atTime:[mixComposition duration] error:nil]; [mixComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset3.duration) ofAsset:asset3 atTime:[mixComposition duration] error:nil

Setting AVMutableComposition's frameDuration

泄露秘密 提交于 2019-11-29 15:01:55
问题 I'm playing with the AVEditDemo project, from Apple's WWDC 2010 sample pack, and I'm trying to change the frame rate of the exported video. The video is exported using an AVMutableComposition on which the frameDuration is set like that: videoComposition.frameDuration = CMTimeMake(1, 30); // 30 fps For some reason, changing the 30 to 25 does not change the framerate of the video exported with the AVAssetExportSession . Does anyone have an idea why? 回答1: It seems that the AVAssetExportSession

Swift 3: How to add watermark on video ? AVVideoCompositionCoreAnimationTool iOS 10 issue

时光总嘲笑我的痴心妄想 提交于 2019-11-28 23:45:37
This code used to work on iOS9 to add a watermark and text to a video but since iOS10 it's not working anymore. There is a iOS 10 bug that has been filed but no answer from Apple. I have not been able to implement any workaround to add watermark and text on video. With this code some times the video will be exported successfully but most of time it won't be exported. How should I use AVVideoCompositionCoreAnimationTool so that it works as it did on iOS9. let videoComposition: AVMutableVideoComposition = AVMutableVideoComposition() videoComposition.frameDuration = CMTimeMake(1, 60)

AVAssetExportSession export fails non-deterministically with error: “Operation Stopped, NSLocalizedFailureReason=The video could not be composed.”

安稳与你 提交于 2019-11-28 23:18:22
We add subtitles to a video recorded by the user, but the export by our AVAssetExportSession object fails non-deterministically: sometimes it works, and sometimes it doesn't. It's unclear even how to reproduce the error. We noticed the asset tracks seem to get lost during export. Before exporting, there are two tracks (one for audio, one for video) as expected. But checking the number of tracks for the same file URL in exportDidFinish shows 0 tracks. So something seems wrong with the export process. Update: Commenting out exporter.videoComposition = mutableComposition fixes the error, but of