---
title: "insertTimeRange(_:of:at:copySampleData:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avmutablemovie/inserttimerange(_:of:at:copysampledata:)"
---

# insertTimeRange(_:of:at:copySampleData:)

Inserts all of the tracks in a specified time range of an asset into a movie.

## Declaration

```swift
func insertTimeRange(_ timeRange: CMTimeRange, of asset: AVAsset, at startTime: CMTime, copySampleData: Bool) throws
```

## Parameters

- `timeRange`: The time range of the asset to be inserted.
- `asset`: An doc://com.apple.avfoundation/documentation/AVFoundation/AVAsset object indicating the source of the inserted media. This value can’t be nil.
- `startTime`: The time in the target movie at which the media is to be inserted.
- `copySampleData`: A Boolean value that indicates whether sample data is to be copied from the source to the destination during edits.

## Discussion

Discussion This method may add new tracks to the target movie to ensure that all tracks of the asset are represented in the inserted time range.

## See Also

### Managing time ranges

- [insertEmptyTimeRange(_:)](avfoundation/avmutablemovie/insertemptytimerange(_:).md)
- [scale(_:toDuration:)](avfoundation/avmutablemovie/scale(_:toduration:).md)
- [removeTimeRange(_:)](avfoundation/avmutablemovie/removetimerange(_:).md)
