Tag: avassetexportsession

AVAssetExportSession每次都失败(错误-12780)

我试图合并一些audio文件(通过MPMediaPickerController选取),但导出总是失败,错误代码-12780。 当我尝试使用AVPlayer对象播放我的作品时,它会正确播放。 只是导出失败。 我究竟做错了什么? 这是我的代码: AVAssetExportSession *exportSession; AVPlayer *player; – (void)mergeAudiofiles { // self.mediaItems is an NSArray of MPMediaItems if (self.mediaItems.count == 0) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No Tracks selected." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; return; } // Configure audio session NSError *sessionError; AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryAudioProcessing error:nil]; [session […]

AVAssetExportSession给我一个输出video的右侧和底部的绿色边框

代码如下: AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetHighestQuality]; exporter.outputURL = outputUrl; exporter.outputFileType = AVFileTypeQuickTimeMovie; exporter.videoComposition = mainComposition; exporter.shouldOptimizeForNetworkUse = YES; [exporter exportAsynchronouslyWithCompletionHandler:^{ //completion }]; 我尝试了不同的质量设置。 无论我尝试渲染什么video,我都会在video的右侧沿着底部获取一个1-2像素的边框。 什么可能导致这个,我该如何解决? 编辑:我没有在任何地方使用任何种类的绿色,所以这必须以某种方式来自框架。

iOS:在video中裁剪video奇怪的绿线左侧和底侧

– 如何删除video上的绿线 当在此时裁剪2或3次video时,在video中显示绿色或混合绿色 – 红色闪烁线,在video中左边或底部或左右两侧。 video裁剪方法。 -(void)cropButton { CGRect cropFrame = self.cropView.croppedImageFrame; //load our movie Asset AVAsset *asset; asset = [AVAsset assetWithURL:[NSURL fileURLWithPath:[self.videoDataArr objectAtIndex:self.selectedIndex-1]]]; //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); //create a […]

iOS – AVAssestExportSession只能在播放AVPlayer后导出最多8首曲目

我试图循环录制的video的一些片段,并将它们合并成一个video。 我已经成功合并和导出了一个多达16首曲目的作品。 但是当我在合并之前尝试使用AVPlayer播放这个作品时,我最多只能导出8首曲目。 首先,我创buildAVComposition和AVVideoComposition +(void)previewUserClipDanceWithAudio:(NSURL*)videoURL audioURL:(NSURL*)audioFile loop:(NSArray*)loopTime slowMotion:(NSArray*)slowFactor showInViewController:(UIViewController*)viewController completion:(void(^)(BOOL success, AVVideoComposition* videoComposition, AVComposition* composition))completion{ AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init]; NSMutableArray *arrayInstruction = [[NSMutableArray alloc] init]; AVMutableVideoCompositionInstruction *videoCompositionInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; AVURLAsset *audioAsset = [[AVURLAsset alloc]initWithURL:audioFile options:nil]; //NSLog(@"audio File %@",audioFile); CMTime duration = kCMTimeZero; AVAsset *currentAsset = [AVAsset assetWithURL:videoURL]; BOOL isCurrentAssetPortrait = YES; for(NSInteger […]

AVAssetExportSession输出文件

AVAssetExportSession输出文件应该如何? 我试图从一个ALAsset项目压缩video,它不起作用。 我猜输出文件与它有关。 这里是我使用的代码: NSString *destinationPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie"]; [self convertVideoToLowQualityWithInputURL:asset.defaultRepresentation.url outputURL:[NSURL URLWithString:destinationPath]]; – (void)convertVideoToLowQualityWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL { if([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithContentsOfURL:outputURL encoding: 0 error:Nil]]) [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *assetAV = [AVURLAsset URLAssetWithURL:inputURL options:nil]; NSLog(@"url string from asset: %@", assetAV.URL); NSLog(@"output url: %@", [outputURL absoluteString]); [[NSFileManager defaultManager] createFileAtPath:[outputURL path] contents:nil attributes:nil]; NSLog(@"duration: %lld", assetAV.duration.value); //it […]

Swift 3:如何在video上添加水印? AVVideoCompositionCoreAnimationTool iOS 10问题

此代码用于在iOS9上工作,为video添加水印和文本,但自iOS10以后,它不再工作。 有一个iOS 10的错误已经提交,但没有答复从苹果。 我还没有能够实施任何解决方法来添加水印和文字的video。 有了这段代码,video将被成功导出,但大部分时间将不会被导出。 我应该如何使用AVVideoCompositionCoreAnimationTool ,使其像iOS9一样工作。 let videoComposition: AVMutableVideoComposition = AVMutableVideoComposition() videoComposition.frameDuration = CMTimeMake(1, 60) videoComposition.renderSize = CGSize(width: clipVideoTrack.naturalSize.height, height: clipVideoTrack.naturalSize.height) let instruction: AVMutableVideoCompositionInstruction = AVMutableVideoCompositionInstruction() instruction.timeRange = CMTimeRangeMake(kCMTimeZero, CMTimeMakeWithSeconds(60, 30)) // transformer is applied to set the video in portrait otherwise it is rotated by 90 degrees let transformer: AVMutableVideoCompositionLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: clipVideoTrack) […]

iOS 5:将3个video与AVAssetExportSession合并时出错

我试图合并(附加)使用AVAssetExportSession 3video,但我不断收到此错误。 奇怪的是1或2个video的工作。 Error Domain=AVFoundationErrorDomain Code=-11820 "Cannot Complete Export" UserInfo=0x458120 {NSLocalizedRecoverySuggestion=Try exporting again., NSLocalizedDescription=Cannot Complete Export} 我什至试图重做function的情况下,但我得到的只是无限的错误信息。 这是我的代码片段。 AVMutableComposition *mixComposition = [AVMutableComposition composition]; AVMutableCompositionTrack *compositionTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; NSError * error = nil; NSMutableArray * timeRanges = [NSMutableArray arrayWithCapacity:arrayMovieUrl.count]; NSMutableArray * tracks = [NSMutableArray arrayWithCapacity:arrayMovieUrl.count]; for (int i=0; i<[arrayMovieUrl count]; i++) { AVURLAsset *assetClip […]

在iOS中裁剪和修复video方向

我使用UIImagePickerController捕捉video,我可以使用下面的代码裁剪video, 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 setting its render size to its height x height (Square) videoComposition.renderSize = CGSizeMake(clipVideoTrack.naturalSize.height, clipVideoTrack.naturalSize.height); //create a video […]

AVVideoCompositionCoreAnimationTool和CALayer在肖像模式?

我正在尝试在iOS 4.3上使用AVMutableComposition,AVMutableVideoComposition和AVVideoCompositionCoreAnimationTool将CALayer烧制成纵向模式video(导出时)。 这一切都在风景。 如果我以纵向捕捉video,AVVideoCompositionCoreAnimationTool将忽略video轨道上的变换。 也就是说,对于纵向模式的video,我将AVMutableCompositionTrack.preferredTransform设置为来自原始资产video轨道的preferredTransform值。 只要我不使用一个AVVideoCompositionCoreAnimationTool,这个工作,和video出来的人像模式。 只要我添加一个AVVideoCompositionCoreAnimationTool和CALayer,然而,文件出现在横向。 (CALayer显示正确,但后面的video位于其旁边,并且文件的宽高比为closures)。 我已经尝试将转换应用于CALayer,并在ACVideoComposition中设置转换。 这些都不会改变生成的文件的方向(它仍然是480×369,而不是360×480)。 有没有办法用AVVideoCompositionCoreAnimationTool渲染肖像模式的video? 首先我build立一个AVMutableComposition和AVMutableVideoComposition AVMutableComposition *composition = [AVMutableComposition composition]; AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:url options:nil]; CMTimeRange timeRange = CMTimeRangeMake(kCMTimeZero, [videoAsset duration]); AVAssetTrack *clipVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; CGSize videoSize = CGSizeApplyAffineTransform(clipVideoTrack.naturalSize, clipVideoTrack.preferredTransform); videoSize.width = fabs(videoSize.width); videoSize.height = fabs(videoSize.height); CMTime titleDuration = […]

使用AVFoundation裁剪AVAssetvideo

我正在使用AVCaptureMovieFileOutput来录制一些video。 我使用AVLayerVideoGravityResizeAspectFill稍微放大显示预览图层。 我的问题是,最终的video更大,包含额外的图像,不适合在预览屏幕上。 这是预览和结果video 有没有一种方法可以使用CGRect来指定我想从video剪切的AVAssetExportSession ? 编辑—- 当我将一个CGAffineTransformScale应用到AVAssetTrack它将放大video,并将AVMutableVideoComposition renderSize设置为view.bounds 。 太棒了,还剩下一个问题。 video的宽度不会伸展到正确的宽度,只会填充黑色。 编辑2 —-build议的问题/答案是不完整的.. 我的一些代码: 在我的- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error方法我有这种裁剪和调整video。 – (void)flipAndSave:(NSURL *)videoURL withCompletionBlock:(void(^)(NSURL *returnURL))completionBlock { AVURLAsset *firstAsset = [AVURLAsset assetWithURL:videoURL]; // 1 – Create AVMutableComposition object. This object will hold your AVMutableCompositionTrack instances. AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init]; // […]