Tôi đang làm việc trên một nhiệm vụ mà tôi phải cắt video đã ghi từ điểm bắt đầu cụ thể đến điểm cuối cụ thể như được người dùng nhập hoặc chọn. Tôi phải làm như thế nào. Vì trước đây tôi đã sử dụng UIVideoEditorController
nhưng tôi không muốn sử dụng chế độ xem mặc định và tôi muốn cắt trực tiếp video.cách cắt video nhanh chóng trong một thời điểm cụ thể
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!)
}
})
Tôi đang cố gắng đạt được mục tiêu của mình bằng cách sử dụng nhưng không thành công.
nhắnLỗi:
không bắt buộc (Lỗi miền = NSURLErrorDomain Mã = -1100 "The URL được yêu cầu không được tìm thấy trên máy chủ này." UserInfo = {NSErrorFailingURLStringKey = file: /// var/di động/Vùng chứa/Dữ liệu/Ứng dụng/E68D3BFD-6923-4EA6-9FB3-C020CE4AA9D4/Tài liệu/thời điểm/jGq_9AUFa47s2ZiiPP4x.mp4, NSErrorFailingURLKey = file: /// var/mobile/Vùng chứa/Dữ liệu/Ứng dụng/E68D3BFD-6923-4EA6- 9FB3-C020CE4AA9D4/Tài liệu/thời điểm/jGq_9AUFa47s2ZiiPP4x.mp4, NSLocalizedDescription = URL được yêu cầu không được tìm thấy trên máy chủ này., NSUnderlyingError = 0x1553c220 {Err hoặc tên miền = N
Lỗi xảy ra lần thứ hai:
không bắt buộc (Lỗi miền = NSURLErrorDomain Mã = -3000 "Không thể tạo tập tin" UserInfo = {NSUnderlyingError = 0x14e00000 {Lỗi miền = NSOSStatusErrorDomain Mã = -12.124 "(null)"}, NSLocalizedDescription = không thể tạo tập tin})
làm thế nào nó không thành công? Lỗi là gì? – hola
tôi đang chuyển url đến tham số newURL và luôn đi vào khối lỗi không thành công ... –
Có nhưng * thông báo lỗi * là gì? – Moritz