0
錄製到視頻並將其發送到服務器。無論何時服務器與我錄製的視頻,它都會返回內部服務器錯誤。但是,當我上傳一些除錄製的視頻外的其他視頻,則會成功上傳。添加下面的代碼。無法使用AVFoundation將錄製的視頻上傳到服務器 - 使用AVFoundation將Swift 3
let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])
let logsPath = documentsPath.appendingPathComponent(GlobalVar.interVCode)
if !FileManager.default.fileExists(atPath: (logsPath?.absoluteString)!){
do {
try FileManager.default.createDirectory(at: logsPath!, withIntermediateDirectories: true, attributes: nil)
} catch let error as NSError {
NSLog("Unable to create directory \(error.debugDescription)")
}
}
let outputURL: URL = (self.applicationDocumentsDirectory().appendingPathComponent(GlobalVar.interVCode)?.appendingPathComponent("\(questionId)").appendingPathExtension("mp4"))!
self.camera.startRecording(withOutputUrl: outputURL, didRecord:
{(camera, outputURL, error) in
})
使用定製照相機控制器LLSimpleCamera開始recording.Below是開始記錄的代碼。
- (void)startRecordingWithOutputUrl:(NSURL *)url didRecord:(void (^)(LLSimpleCamera *camera, NSURL *outputFileUrl, NSError *error))completionBlock
{
// check if video is enabled
if(!self.videoEnabled) {
NSError *error = [NSError errorWithDomain:LLSimpleCameraErrorDomain
code:LLSimpleCameraErrorCodeVideoNotEnabled
userInfo:nil];
[self passError:error];
return;
}
if(self.flash == LLCameraFlashOn) {
[self enableTorch:YES];
}
// set video orientation
for(AVCaptureConnection *connection in [self.movieFileOutput connections]) {
for (AVCaptureInputPort *port in [connection inputPorts]) {
// get only the video media types
if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
if ([connection isVideoOrientationSupported]) {
[connection setVideoOrientation:[self orientationForConnection]];
}
}
}
}
self.didRecordCompletionBlock = completionBlock;
[self.movieFileOutput startRecordingToOutputFileURL:url recordingDelegate:self];
}
幫助非常感謝。
雖然轉換爲NSData的00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00 000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00>打印這個..用虛擬視頻它顯示一些其他值。 –