Using didOutputSampleBuffer to record to a video file results in 13 hour file with just the first frame
===

Does anybody know what could be wrong with the rest of my code if 
- (void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection{

            [writerInput appendSampleBuffer:sampleBuffer];                   

}

is resulting in a 13 hour video file with just the first frame and nothing else? (Or at least that's what it looks like when I read the thing I wrote into a MPMoviePlayer.)

This is how I set up my input and writer

    NSError *error = nil;
    videoWriter = [[AVAssetWriter alloc] initWithURL:
                                  url fileType:AVFileTypeQuickTimeMovie
                                                              error:&error];
    NSParameterAssert(videoWriter);
    
    NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                   AVVideoCodecH264, AVVideoCodecKey,
                                   [NSNumber numberWithInt:640], AVVideoWidthKey,
                                   [NSNumber numberWithInt:480], AVVideoHeightKey,
                                   nil];
    
    writerInput = [AVAssetWriterInput
                                        assetWriterInputWithMediaType:AVMediaTypeVideo
                                        outputSettings:videoSettings];
    
    NSParameterAssert(writerInput);
    NSParameterAssert([videoWriter canAddInput:writerInput]);
    [videoWriter addInput:writerInput];
    [videoWriter startWriting];
    [videoWriter startSessionAtSourceTime:kCMTimeZero];
    writerReady = YES;