---
title: "segment(forTrackTime:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avcompositiontrack/segment(fortracktime:)"
---

# segment(forTrackTime:)

Returns a segment whose target time range contains, or is closest to, the specified track time.

## Declaration

```swift
func segment(forTrackTime trackTime: CMTime) -> AVCompositionTrackSegment?
```

## Parameters

- `trackTime`: The track time of the segment to return.

## Return Value

Return Value The AVCompositionTrackSegment associated with the track time.

## See Also

### Accessing track segments

- [segments](avfoundation/avcompositiontrack/segments.md)
