---
title: "mergeSegments(_:andAudio:toFile:)"
framework: Professional Video Applications
role: symbol
role_heading: Instance Method
platforms: [provideo encoder extensions 1.0+]
path: "professional_video_applications/compressorextensionencoder/mergesegments(_:andaudio:tofile:)"
---

# mergeSegments(_:andAudio:toFile:)

Merges multiple encoded video segments with an encoded audio segment.

## Declaration

```swift
func mergeSegments(_ videoSegments: [Any]!, andAudio audioSegment: URL!, toFile file: URL!)
```

## Parameters

- `videoSegments`: An array of encoded video segment URLs.
- `audioSegment`: An encoded audio segment URL.
- `file`: The destination file URL at which to place the merged segments.

## Discussion

Discussion During a distributed encoding process, the encoder extension processes audio and video segments separately on the available encoder instances. Once the encoding job completes, the Compressor app invokes mergeSegments(_:andAudio:toFile:): on one of the encoder instances with an audio segment URL, a list of video segment URLs, and the desired output file URL. Implement this method to merge multiple encoded video segments in order, with a complete audio segment, into a single output file. Install an encoder extension on each node of the cluster that is participating in the encoding process.

## See Also

### Encoding and Merging Segments

- [runTranscode(for:start:duration:toFile:startTimeCode:)](professional_video_applications/compressorextensionencoder/runtranscode(for:start:duration:tofile:starttimecode:).md)
- [CompressorExtensionEncoderPtr](professional_video_applications/compressorextensionencoderptr.md)
