ビデオのみを記録してサーバーに送信するアプリを作成しました。AVCamプロジェクトを使用しました。そしてMKNetworkKit
、サーバーにビデオをアップロードするために使用します。
しかし、出力URLを変換するNSData
と、無制限のデータが得られNSLog
、xcodeとiPhoneの両方がハングするので、助けてください。
ここで私が試したこと:
@implementation AVCamRecorder (FileOutputDelegate)
- (void) captureOutput:(AVCaptureFileOutput *)captureOutput
didStartRecordingToOutputFileAtURL:(NSURL *)fileURL
fromConnections:(NSArray *)connections
{
//
if ([[self delegate] respondsToSelector:@selector(recorderRecordingDidBegin:)]) {
[[self delegate] recorderRecordingDidBegin:self];
}
}
- (void) captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)anOutputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{
videodata = [NSData dataWithContentsOfURL:outputFileURL]; //video data is my NSData
NSLog(@"output video data is :%@",videodata); //Here i have get non stop output data and hang
NSLog(@"output file url is: %@",anOutputFileURL);
if ([[self delegate] respondsToSelector:@selector(recorder:recordingDidFinishToOutputFileURL:error:)]) {
[[self delegate] recorder:self recordingDidFinishToOutputFileURL:anOutputFileURL error:error];
}
//NSLog(@"captureOutput is: %@",captureOutput);
//videoPath = [NSString stringWithContentsOfURL:anOutputFileURL encoding:NSUTF8StringEncoding error:nil];
//videoPath = [anOutputFileURL absoluteString];
//videoURL = anOutputFileURL;
// videodata = captureOutput;
// NSLog(@"video path is: %@",videodata);
UIAlertView *message = [[UIAlertView alloc] initWithTitle:nil
message:@"Do you want to upload this content to the yes stream network ?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Yes",@"No",nil];
[message show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Yes"])
{
NSLog(@"Yes was selected.");
self.flUploadEngine = [[fileUploadEngine alloc] initWithHostName:@"manektech.net" customHeaderFields:nil];
NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"testApp", @"appID",
nil];
self.flOperation = [self.flUploadEngine postDataToServer:postParams path:@"/dilipvideotest/savefile.php"];
[self.flOperation addData:videodata forKey:@"uploadfile" mimeType:@"video/mov" fileName:@"output.mov" ];
[self.flOperation onCompletion:^(MKNetworkOperation *operation) {
NSLog(@"response string is : %@", [operation responseString]);
/*
This is where you handle a successful 200 response
*/
}
onError:^(NSError *error) {
NSLog(@"error : %@", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
}];
[self.flUploadEngine enqueueOperation:self.flOperation ];
}
else if([title isEqualToString:@"No"])
{
NSLog(@"No was selected.");
}
}
@end
そしてここに私のログファイル:
2012-11-02 11:16:25.585 AVFoundationCam[322:707] output file url is :file://localhost/private/var/mobile/Applications/4B2E02E5-3EE2-493E-8ECF-4B1DA29B9387/tmp/output.mov
2012-11-02 10:38:20.172 AVFoundationCam[157:707] output video data is :<00000014 66747970 71742020 00000000 71742020 00000008 77696465 0048f6a2 6d646174 00cc4007 010299cc 3dbd55cc 24c445ef bf3ae6f8 d24efffc 37c1ae35 2e5820d7 9111eef2 78c4b828 851be773 17f438d7 ed6ff47e afd5f439 cc3f2bed f60e0fb1 f2f6ba5e 81fcfbe2 df2b758e 373963b2 2b84f47e 0757c80a baf7abc8 cb0004a6 52001ff2 b257cbfb df66f0b6 3a325664 76dd35fa 758fa705 c1feeb4d 31376570 c4a967da 4d8d2fc2 d5b7c66b 30bc4477 9f0d0701 3099fe12 35a697bd 270d7556 3b24b833 7198a99a 314dcb28 32505930 9ac1a7a3 484c07a4 22d55921 115aae8f 481d2742 35c71af9 c94bd590 f841bf1d e2b9866b 10ecc5ba 333a9da7 9f1c5cb5 8f1a8686 619954c8 d4437dfb 4caa68bd 1164561c 2e15751a c29b0b41 34b1990e a6454c32 c472e79c 26d31699 95a6e164 e2c159ab 9a065e1f 1eaeec74 4445ddb1 11092ed0 b4f66d1a 68bb5a53 a1ee7eec a612b540 1a912034 07c7bffa 6733ad30 c8c43801 26d520c9 12220486 61153df9 ad6624a6 ab716849 25ca924b 912aab41 c16316eb 21a409d6 4175a0f6 9675e80f fbbe61ba 12cf4f7e af73a9a6 029961d7 0bed268a 97a116a0 e27add77 68de97c4 a476a450 9504cb0d d539f984 9b3af0f2 30c4632b AND STILL showing much more data and hang...............