<!--
{
  "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/CMTimeMapDurationFromRangeToRange(_:fromRange:toRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Media"
    ],
    "preciseIdentifier" : "c:@F@CMTimeMapDurationFromRangeToRange"
  },
  "title" : "CMTimeMapDurationFromRangeToRange(_:fromRange:toRange:)"
}
-->

# CMTimeMapDurationFromRangeToRange(_:fromRange:toRange:)

Translates a duration through a mapping from two time ranges.

```
func CMTimeMapDurationFromRangeToRange(_ dur: CMTime, fromRange: CMTimeRange, toRange: CMTimeRange) -> CMTime
```

## Parameters

`dur`

The duration to translate.

`fromRange`

The time range from which the function translates the duration.

`toRange`

The time range to which the function maps the duration.

## Return Value

A time structure that represents the translated duration.

## Discussion

The function scales the duration in proportion to the ratio between the ranges’ durations:

```objc
result = dur*(toRange.duration/fromRange.duration)
```

If `dur` doesn’t have the epoch `0`, the function returns an invalid `CMTime`.

---

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)