<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMedia",
  "identifier" : "/documentation/CoreMedia/CMTimeMapTimeFromRangeToRange(_:fromRange:toRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMTimeMapTimeFromRangeToRange"
  },
  "title" : "CMTimeMapTimeFromRangeToRange(_:fromRange:toRange:)"
}
-->

# CMTimeMapTimeFromRangeToRange(_:fromRange:toRange:)

Translates a time through a mapping from two time ranges.

```
func CMTimeMapTimeFromRangeToRange(_ t: CMTime, fromRange: CMTimeRange, toRange: CMTimeRange) -> CMTime
```

## Parameters

`t`

The time value to translate.

`fromRange`

The time range from which the function translates the time range.

`toRange`

The time range to which the function maps the time value.

## Return Value

A time structure that represents the translated time.

## Discussion

The start and end time of `fromRange` maps to the start and end time of `toRange` respectively. The function maps other times linearly using the formula:

```objc
result = (t-fromRange.start)*(toRange.duration/fromRange.duration)+toRange.start
```

If either `CMTimeRange` argument is empty, the function returns an invalid `CMTime`. If `t` doesn’t have the same epoch as `fromRange.start`, the function returns an invalid `CMTime`. If both `fromRange` and `toRange` have duration `kCMTimePositiveInfinity`, the function offsets `t` relative to the differences between their starts, but not scaled.

---

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)