我正在尝试使用UIVideoEditorController来编辑我的视频,但它似乎失去了我的视频分辨率.我的原始视频是720 x 1280
,但使用后UIVideoEditorController
,质量变为360 x 640
.
我试图设置videoQuality
成为UIImagePickerControllerQualityTypeHigh
或甚至UIImagePickerControllerQualityTypeIFrame1280x720
,但这没有帮助.
我在iPad上工作,这是我的代码:
self.editorController = [[[UIVideoEditorController alloc] init] autorelease];
self.editorController.videoPath = self.tempVideoPath;
self.editorController.delegate = self;
self.editorController.videoQuality = UIImagePickerControllerQualityTypeHigh;
CKLog(@"%d", self.editorController.videoQuality);
self.popOverController = [[[UIPopoverController alloc] initWithContentViewController:self.editorController] autorelease];
self.popOverController.delegate = self;
self.popOverController.popoverContentSize = CGSizeMake(700, 700);
[self.popOverController presentPopoverFromRect:CGRectMake(0, 0, 1, 1) inView:self.videoView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Run Code Online (Sandbox Code Playgroud) 目前我正在处理一个处理视频的应用程序.在我的应用程序中,用户可以修剪视频,我有一个自定义控件,用于选择开始时间和结束时间.我需要通过这两个值修剪视频.我尝试过UIVideoEditorController
如下.
UIVideoEditorController* videoEditor = [[[UIVideoEditorController alloc] init] autorelease];
videoEditor.delegate = self;
NSString* videoPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"MOV"];
if ( [UIVideoEditorController canEditVideoAtPath:videoPath] )
{
videoEditor.videoPath = videoPath;
[self presentModalViewController:videoEditor animated:YES];
}
else
{
NSLog( @"can't edit video at %@", videoPath );
}
Run Code Online (Sandbox Code Playgroud)
但问题是上面的代码会显示苹果的视频编辑器控件,用户可以对该视图进行一些操作.我不想显示此视图,因为我已经显示了视频MPMoviePlayer
并接收了用户输入(开始时间和结束时间)以在自定义控件上修剪视频.如何在不显示视频的情况下修剪视频UIVideoEditorController
?
我正在处理一项任务,我必须将录制的视频从特定的起始点修剪为用户输入或选择的特定终点.我该怎么做呢 正如我UIVideoEditorController
之前使用的,但我不想使用默认视图,我想直接修剪视频.
let FinalUrlTosave = NSURL(string: "\(newURL)")
exportSession!.outputURL=FinalUrlTosave
exportSession!.shouldOptimizeForNetworkUse = true
// exportSession.outputFileType = AVFileTypeQuickTimeMovie
exportSession!.outputFileType = AVFileTypeQuickTimeMovie;
let start:CMTime
let duration:CMTime
var st = starttime.doubleValue
var ed = endTime.doubleValue
start = CMTimeMakeWithSeconds(st, 600)
duration = CMTimeMakeWithSeconds(ed, 600)
// let timeRangeForCurrentSlice = CMTimeRangeMake(start, duration)
let range = CMTimeRangeMake(start, duration);
exportSession!.timeRange = range
exportSession!.exportAsynchronouslyWithCompletionHandler({
switch exportSession!.status{
case AVAssetExportSessionStatus.Failed:
print("failed \(exportSession!.error)")
case AVAssetExportSessionStatus.Cancelled:
print("cancelled \(exportSession!.error)")
default:
print("complete....complete")
// self.SaveVideoToPhotoLibrary(destinationURL1!)
}
})
Run Code Online (Sandbox Code Playgroud)
我试图用这个来实现我的目标,但没有成功.
错误信息:
failed可选(错误域= NSURLErrorDomain代码= -1100"在此服务器上找不到请求的URL."UserInfo = {NSErrorFailingURLStringKey = file:/// …
我正在尝试使用UIVideoEditorController修剪视频.修剪或保存后,使用UIVideoEditorController丢失了我的视频分辨率.我曾经UIImagePickerController
以设定的分辨率拍摄视频,UIImagePickerControllerQualityTypeIFrame1280x720
并设置了UIVideoEditorController的url路径,其属性为videoQuality(iPhone 5)UIImagePickerControllerQualityTypeIFrame1280x720
.当我使用AVFoudation框架捕获视频时,同样的效果.为什么我失去了决心?我的代码:
if ([UIVideoEditorController canEditVideoAtPath:self.videoPath]) {
//video quality 1280x720
self.editor = [UIVideoEditorController new];
self.editor.videoPath = self.videoPath;
self.editor.videoMaximumDuration = 180.0;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
self.editor.videoQuality =
UIImagePickerControllerQualityTypeIFrame1280x720;
#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
self.editor.videoQuality =
UIImagePickerControllerQualityType640x480; // VGA quality
#endif
self.editor.delegate = self;
[self.navigationController presentViewController:self.editor
animated:NO
completion:nil];
} else {
DLog(@"can't edit video at %@", self.videoPath);
}
Run Code Online (Sandbox Code Playgroud)
在代表中:
- (void)videoEditorController:(UIVideoEditorController *)editor
didSaveEditedVideoToPath:(NSString *)editedVideoPath {
[self removeImage:editor.videoPath];
[editor dismissViewControllerAnimated:YES
completion:^{
}];
#if DEBUG
AVAssetTrack *videoTrack = nil;
AVURLAsset …
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试使用UIVideoEditorViewController
来修剪之前从“照片”应用程序中选择的视频文件UIImagePickerController
。我确认在选择文件之后和创建文件之前具有原始分辨率。然而,在修剪视频后,尽管将属性UIVideoEditorViewController
设置为 ,但输出始终为 360p 分辨率。对于此属性,所有适用的设置似乎都被忽略,并且视频最终被不必要地压缩。videoQuality
high
我发现很多人报告了类似的问题,但尚未找到解决方法。
let editor = UIVideoEditorController()
editor.delegate = self
editor.videoMaximumDuration = 0 // No limit for now
// TODO: This should really work, however while testing it seems like the imported videos are always scaled down
// to 320p which equivalents the default value of .low.
editor.videoQuality = .typeHigh
editor.videoPath = internalURL.path
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。
avfoundation uiimagepickercontroller ios uivideoeditorcontroller swift
我正在使用UIVideoEditorController,但是成功委托方法为我调用了两次。但是,所有传递的对象的所有指针都告诉它发送完全相同的数据。
let editor = UIVideoEditorController()
editor.videoMaximumDuration = 10.0
editor.videoQuality = .typeIFrame1280x720
editor.delegate = self
editor.videoPath = // some path goes here
self.present(editor, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
然后,以下方法将“ here”打印两次。
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
print("here")
self.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud) 我想修剪视频,所以我正在使用UIVideoEditorController,但是当我检查可以编辑文件时,对于所有文件mp4,mov,m4v,它都返回false。所以任何人都可以指导我什么问题。
ios ×5
swift ×3
avfoundation ×2
iphone ×2
objective-c ×2
cocoa-touch ×1
ios7 ×1
trim ×1
video ×1
xcode ×1