<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVMutableMovieTrack/insertTimeRange(_:of:at:copySampleData:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVMutableMovieTrack(im)insertTimeRange:ofTrack:atTime:copySampleData:error:"
  },
  "title" : "insertTimeRange(_:of:at:copySampleData:)"
}
-->

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

Inserts a portion of an asset track into the target movie.

```
func insertTimeRange(_ timeRange: CMTimeRange, of track: AVAssetTrack, at startTime: CMTime, copySampleData: Bool) throws
```

## Parameters

`timeRange`

The time range of the track to insert.

`track`

An [`AVAssetTrack`](/documentation/AVFoundation/AVAssetTrack) object indicating the source of the inserted media. This value can’t be `nil`.

`startTime`

The time in the target track 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. If `YES`, the sample data is written to the location specified by the track property `mediaDataStorage` if non-nil, or else by the movie property `defaultMediaDataStorage` if non-nil; if both are nil, the method fails and returns `NO`. If `NO`, sample data isn’t written and sample references to the samples in their original container are added as necessary.

## Discussion

---

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)