---
title: "CMTimeMapDurationFromRangeToRange(_:fromRange:toRange:)"
framework: Core Media
role: symbol
role_heading: Function
platforms: [iOS 4.0+, iPadOS 4.0+, Mac Catalyst 13.1+, macOS 10.7+, tvOS 9.0+, visionOS 1.0+, watchOS 6.0+]
path: "coremedia/cmtimemapdurationfromrangetorange(_:fromrange:torange:)"
---

# CMTimeMapDurationFromRangeToRange(_:fromRange:toRange:)

Translates a duration through a mapping from two time ranges.

## Declaration

```swift
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

Return Value A time structure that represents the translated duration.

## Discussion

Discussion The function scales the duration in proportion to the ratio between the ranges’ durations: result = dur*(toRange.duration/fromRange.duration) If dur doesn’t have the epoch 0, the function returns an invalid CMTime.

## See Also

### Utility Functions

- [CMTimeClampToRange(_:range:)](coremedia/cmtimeclamptorange(_:range:).md)
- [CMTimeMapTimeFromRangeToRange(_:fromRange:toRange:)](coremedia/cmtimemaptimefromrangetorange(_:fromrange:torange:).md)
- [CMTimeRangeCopyAsDictionary(_:allocator:)](coremedia/cmtimerangecopyasdictionary(_:allocator:).md)
- [CMTimeRangeCopyDescription(allocator:range:)](coremedia/cmtimerangecopydescription(allocator:range:).md)
- [CMTimeRangeShow(_:)](coremedia/cmtimerangeshow(_:).md)
