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

iOS:在视频中裁剪视频奇怪的绿线左侧和底侧,第1张

概述– 如何删除视频中的绿线. 当播放视频2或3次时,在视频中显示绿色或混合绿 – 红闪烁线,左视图或底视图或视频中的左下侧. 视频裁剪方法. -(void)cropButton{ CGRect cropFrame = self.cropView.croppedImageFrame; //load our movie Asset AVAsset *a @H_419_1@ – 如何删除视频中的绿线.
当播放视频2或3次时,在视频中显示绿色或混合绿 – 红闪烁线,左视图或底视图或视频中的左下侧.

视频裁剪方法.

-(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 vIDeo instruction        AVMutableVIDeoCompositionInstruction *instruction = [AVMutableVIDeoCompositionInstruction vIDeoCompositionInstruction];        instruction.timeRange = CMTimeRangeMake(kCMTimeZero,asset.duration);        AVMutableVIDeoCompositionLayerInstruction* transformer = [AVMutableVIDeoCompositionLayerInstruction vIDeoCompositionLayerInstructionWithAssetTrack:clipVIDeoTrack];        UIImageOrIEntation vIDeoOrIEntation = [self getVIDeoOrIEntationFromAsset:asset];        CGAffinetransform t1 = CGAffinetransformIDentity;        CGAffinetransform t2 = CGAffinetransformIDentity;        switch (vIDeoOrIEntation)        {            case UIImageOrIEntationUp:                t1 = CGAffinetransformMakeTranslation(clipVIDeoTrack.naturalSize.height - cropFrame.origin.x,0 - cropFrame.origin.y);                t2 = CGAffinetransformRotate(t1,M_PI_2);                break;            case UIImageOrIEntationDown:                t1 = CGAffinetransformMakeTranslation(0 - cropFrame.origin.x,clipVIDeoTrack.naturalSize.wIDth - cropFrame.origin.y ); // not fixed wIDth is the real height in upsIDe down                t2 = CGAffinetransformRotate(t1,- M_PI_2);                break;            case UIImageOrIEntationRight:                t1 = CGAffinetransformMakeTranslation(0 - cropFrame.origin.x,0 );                break;            case UIImageOrIEntationleft:                t1 = CGAffinetransformMakeTranslation(clipVIDeoTrack.naturalSize.wIDth - cropFrame.origin.x,clipVIDeoTrack.naturalSize.height -  cropFrame.origin.y );                t2 = CGAffinetransformRotate(t1,M_PI);                break;            default:                NSLog(@"no supported orIEntation has been found in this vIDeo");                break;        }        CGAffinetransform finaltransform = t2;        vIDeoComposition.renderSize = CGSizeMake(cropFrame.size.wIDth,cropFrame.size.height);        [transformer settransform:finaltransform atTime:kCMTimeZero];        //add the transformer layer instructions,then add to vIDeo composition        instruction.layerInstructions = [NSArray arrayWithObject:transformer];        vIDeoComposition.instructions = [NSArray arrayWithObject: instruction];        //Create an Export Path to store the cropped vIDeo        Nsstring * documentsPath = [NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];        __block Nsstring *exportPath = [documentsPath stringByAppendingFormat:@"/CroppedVIDeo.mp4"];        NSURL *exportUrl = [NSURL fileURLWithPath:exportPath];        //Remove any prevouis vIDeos at that path        [[NSfileManager defaultManager]  removeItemAtURL:exportUrl error:nil];        AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:asset presetname:AVAssetExportPresetHighestQuality] ;        exporter.vIDeoComposition = vIDeoComposition;        exporter.outputURL = exportUrl;        NSLog(@"exported url : %@",exportUrl);        exporter.outputfileType = AVfileTypeQuickTimeMovIE;        [exporter exportAsynchronouslyWithCompletionHandler:^         {             dispatch_async(dispatch_get_main_queue(),^{                 switch ([exporter status]) {                     case  AVAssetExportSessionStatusCompleted:                     {                         self.navigationController.toolbarHIDden = YES;                         NSError *error = nil;                         Nsstring *targetPath;                             targetPath = [self.vIDeoDataArr objectAtIndex:self.selectedindex-1];                         [fileMANAGER removeItemAtPath:targetPath error:&error];                         if(error)                         {                             NSLog(@"Error is : %@",error);                         }                         error = nil;                         [fileMANAGER moveItemAtPath:exportPath topath:targetPath error:&error];                         if(error)                         {                             NSLog(@"Error is : %@",error);                         }                         self.mySAVIDeoRangeSlIDer.vIDeoUrl = self.vIDeourl;                         [self.mySAVIDeoRangeSlIDer getMovIEFrame];                     }                         break;                  }                     case AVAssetExportSessionStatusFailed:                         NSLog(@"Export Failed: %@",[[exporter error] localizedDescription]);                         break;                     case AVAssetExportSessionStatusCancelled:                         NSLog(@"Export canceled");                         break;                     default:                         NSLog(@"NONE");                         dispatch_async(dispatch_get_main_queue(),^{                         });                         break;                 }             });         }];    }

视频裁剪后看到视频裁剪绿线,如何解决它.

解决方法 您的视频渲染宽度应均匀或可被4整除.

检查这个discussion link

Be aware. If you choose a resolution which is not divisible by 16,8 or 4,you might end up with a 1px green border at either bottom or right sIDe of your frame. I have seen this problem with

“If the horizontal or vertical size is not divisible by 16,then the encoder pads the image with a suitable number of black “overhang” samples at the right edge or bottom edge. These samples are discarded upon deCoding. For example when Coding HDTV at 1920×1080,an encoder appends 8 rows of black pixels to ht eimage array,to make the row count 1088.”

总结

以上是内存溢出为你收集整理的iOS:在视频中裁剪视频奇怪的绿线左侧和底侧全部内容,希望文章能够帮你解决iOS:在视频中裁剪视频奇怪的绿线左侧和底侧所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1000346.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存