<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureFileOutputRecordingDelegate/fileOutput(_:didFinishRecordingTo:from:error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(pl)AVCaptureFileOutputRecordingDelegate(im)captureOutput:didFinishRecordingToOutputFileAtURL:fromConnections:error:"
  },
  "title" : "fileOutput(_:didFinishRecordingTo:from:error:)"
}
-->

# fileOutput(_:didFinishRecordingTo:from:error:)

Informs the delegate when all pending data has been written to an output file.

```
func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: (any Error)?)
```

## Parameters

`output`

The capture file output that has finished writing the file.

`outputFileURL`

The file URL of the file that is being written.

`connections`

An array of [`AVCaptureConnection`](/documentation/AVFoundation/AVCaptureConnection) objects attached to the file output that provided the data that is being written to the file.

`error`

If the file was not written successfully, an error object that describes the problem; otherwise `nil`.

## Discussion

This method is called whenever a file is finished. If the file was forced to be finished due to an error, the error is described in the error parameter—otherwise, the error parameter is `nil`.

This method is called when the file output has finished writing all data to a file whose recording was stopped, either because [`startRecording(to:recordingDelegate:)`](/documentation/AVFoundation/AVCaptureFileOutput/startRecording(to:recordingDelegate:)) or [`stopRecording()`](/documentation/AVFoundation/AVCaptureFileOutput/stopRecording()) were called, or because an error (described by the error parameter) occurred (if no error occurred, the error parameter is `nil`).

This method is always called for each recording request, even if no data is successfully written to the file.

You should not assume that this method will be called on a specific thread.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)