How to save AVCaptureMovieFileOutput object into NSSavePanel

512 views Asked by At

Hi i have to implement save movie file into custom folder, for this i am using NSSavepanel. I am new in NSSavepanel so i am not getting idea that how i add AVCaptureMovieFileOutput object to NSSavePanel

My code is

-(void)doSaveDocument
{

    NSSavePanel *savePanel = [NSSavePanel savePanel];

    [savePanel setTitle:@"Save image"];
    [savePanel setNameFieldStringValue:@"AnnotatedImage.mov"];
    if([savePanel runModal] == NSFileHandlingPanelOKButton)
    {
        [self takeScreenRecording:rect saveAtPath:[savePanel URL]];
        [[NSWorkspace sharedWorkspace] openURL:[savePanel URL]];

        [mMovieFileOutput startRecordingToOutputFileURL:[savePanel URL] recordingDelegate:self];
    }


}
1

There are 1 answers

0
Senthilkumar On BEST ANSWER
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory1 = [paths1 objectAtIndex:0]; // Get documents folder
        NSString *dataPath = [documentsDirectory1 stringByAppendingPathComponent:@"MyVideo"];
        NSError *error;
        if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
            [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];

    NSString *stryourfilename=@"Video1";

    dataPath=[NSString stringWithFormat:@"%@/%@.mp4",dataPath,stryourfilename];
    NSData *dat=[NSData dataWithContentsOfURL:videoURL];

    BOOL ok = [[NSFileManager defaultManager] createFileAtPath:dataPath
                                                      contents:nil attributes:nil];

    if (!ok) {

    } else {
        NSFileHandle* myFileHandle = [NSFileHandle fileHandleForWritingAtPath:dataPath];

        [myFileHandle writeData:dat];

        [myFileHandle closeFile];


    }