Open ghost opened 8 years ago
I use AVCaptureMovieFileOutput to record videos. SDAVAssetExportSession works fine, I use it to compress my recorded videos. An issue appear when I setVideoMirrored to true , SDAVAssetExportSession crop the video.
code setVideoMirrored
AVCaptureMovieFileOutput *movieFileOutput = [[AVCaptureMovieFileOutput alloc] init]; AVCaptureConnection *connection = [movieFileOutput connectionWithMediaType:AVMediaTypeVideo]; [connection setVideoMirrored:true];
code SDAVAssetExportSession
AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:myVideoURL options:nil]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* videoPath = [NSString stringWithFormat:@"%@/video.mov", [paths objectAtIndex:0]]; NSURL * myNewVideoUrl = [NSURL fileURLWithPath:videoPath]; [[NSFileManager defaultManager] removeItemAtURL: myNewVideoUrl error:nil]; exportSession_convertVideo2 = [SDAVAssetExportSession.alloc initWithAsset:avAsset]; exportSession_convertVideo2.outputFileType = AVFileTypeQuickTimeMovie; exportSession_convertVideo2.shouldOptimizeForNetworkUse = YES; exportSession_convertVideo2.outputURL = myNewVideoUrl; exportSession_convertVideo2.videoSettings = @ { AVVideoCodecKey: AVVideoCodecH264, AVVideoWidthKey: [NSNumber numberWithFloat: 540.0], AVVideoHeightKey: [NSNumber numberWithFloat: 960.0], AVVideoCompressionPropertiesKey: @ { AVVideoAverageBitRateKey: @1000000, AVVideoProfileLevelKey: AVVideoProfileLevelH264High40, }, }; exportSession_convertVideo2.audioSettings = @ { AVFormatIDKey: @(kAudioFormatMPEG4AAC), AVNumberOfChannelsKey: @2, AVSampleRateKey: @44100, AVEncoderBitRateKey: @128000, }; [exportSession_convertVideo2 exportAsynchronouslyWithCompletionHandler:^ { if (exportSession_convertVideo2.status == AVAssetExportSessionStatusCompleted) { NSLog(@"Video export succeeded"); } else if (exportSession_convertVideo2.status == AVAssetExportSessionStatusCancelled) { NSLog(@"Video export cancelled"); } else { NSLog(@"Video export failed with error: %@ (%ld)", exportSession_convertVideo2.error.localizedDescription, (long)exportSession_convertVideo2.error.code); } }];
original
after use SDAVAssetExportSession
Yup, this only happens when setVideoMirrored is true.
I'm having the same issue. @titiSbr Did you managed to solve it?
I use AVCaptureMovieFileOutput to record videos. SDAVAssetExportSession works fine, I use it to compress my recorded videos. An issue appear when I setVideoMirrored to true , SDAVAssetExportSession crop the video.
code setVideoMirrored
code SDAVAssetExportSession
original
after use SDAVAssetExportSession