---
title: "exportClip(to:duration:completionHandler:)"
framework: replaykit
role: symbol
role_heading: Instance Method
path: "replaykit/rpscreenrecorder/exportclip(to:duration:completionhandler:)"
---

# exportClip(to:duration:completionHandler:)

Exports a clip recording to a file.

## Declaration

```swift
func exportClip(to url: URL, duration: TimeInterval, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func exportClip(to url: URL, duration: TimeInterval) async throws
```

## Parameters

- `url`: The URL of the destination file.
- `duration`: The duration for clip recording, in seconds. The system caps the duration at to the elapsed time, or a maximum of 15 seconds, whichever is shorter.
- `completionHandler`: A closure the system calls after it finishes exporting the clip. The system passes an error object to the closure if it encountered a problem writing the clip to disk.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func exportClip(to url: URL, duration: TimeInterval) async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Performing Clip Recording

- [startClipBuffering(completionHandler:)](replaykit/rpscreenrecorder/startclipbuffering(completionhandler:).md)
- [stopClipBuffering(completionHandler:)](replaykit/rpscreenrecorder/stopclipbuffering(completionhandler:).md)
