<!--
{
  "availability" : [
    "iOS: 4.1.0 -",
    "iPadOS: 4.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetWriterInput/init(mediaType:outputSettings:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetWriterInput(im)initWithMediaType:outputSettings:"
  },
  "title" : "init(mediaType:outputSettings:)"
}
-->

# init(mediaType:outputSettings:)

Creates an input to append sample buffers of the specified type to the output file.

```
convenience init(mediaType: AVMediaType, outputSettings: [String : Any]?)
```

## Parameters

`mediaType`

The media type of the samples the input accepts.

`outputSettings`

The settings to use for encoding the media you append to the output. Create an output settings dictionary manually, or use [`AVOutputSettingsAssistant`](/documentation/AVFoundation/AVOutputSettingsAssistant) to create preset-based settings.

## Discussion

If you’re appending samples that are already in an acceptable compressed format, pass a value of `nil` for the output settings to pass the buffers to the output unaltered. However, if you’re not writing to a QuickTime movie file, an asset writer only supports passing through a restricted set of media types and subtypes. To pass through media data to files with a type other than [`mov`](/documentation/AVFoundation/AVFileType/mov), pass a nonnull format hint using the [`init(mediaType:outputSettings:sourceFormatHint:)`](/documentation/AVFoundation/AVAssetWriterInput/init(mediaType:outputSettings:sourceFormatHint:)) instead.

### Configuring audio settings

You must fully specify the audio settings dictionary when using this initializer, which means you must provide values for the following keys:

- <doc://com.apple.documentation/documentation/AVFAudio/AVFormatIDKey>. The identifier of the audio format. For <doc://com.apple.documentation/documentation/CoreAudioTypes/kAudioFormatLinearPCM> format, you must include values for all relevant keys with a `AVLinearPCM` prefix, and for <doc://com.apple.documentation/documentation/CoreAudioTypes/kAudioFormatAppleLossless>, you must specify a value for <doc://com.apple.documentation/documentation/AVFAudio/AVEncoderBitDepthHintKey>.
- <doc://com.apple.documentation/documentation/AVFAudio/AVSampleRateKey>. The sample rate of the audio. Common values are `44100` and `48000`.
- <doc://com.apple.documentation/documentation/AVFAudio/AVNumberOfChannelsKey>. If no other channel layout information is available, specifying a value of `1` results in mono output and a value of `2` results in stereo output. If <doc://com.apple.documentation/documentation/AVFAudio/AVNumberOfChannelsKey> specifies a channel count greater than `2`, the dictionary must also specify a value for <doc://com.apple.documentation/documentation/AVFAudio/AVChannelLayoutKey>.

> Note:
> The system doesn’t support specifying a value for <doc://com.apple.documentation/documentation/AVFAudio/AVSampleRateConverterAudioQualityKey> in audio output settings.

### Configuring video settings

A video output settings dictionary must request a compressed video format, which means that the value you specify must follow the rules for compressed video output.

You must fully specify the video settings dictionary when using this initializer, which means you must provide values for the following keys [`AVVideoCodecKey`](/documentation/AVFoundation/AVVideoCodecKey), [`AVVideoWidthKey`](/documentation/AVFoundation/AVVideoWidthKey), [`AVVideoHeightKey`](/documentation/AVFoundation/AVVideoHeightKey).

> Note:
> Specifying a ``doc://com.apple.avfoundation/documentation/AVFoundation/AVVideoScalingModeKey`` value of ``doc://com.apple.avfoundation/documentation/AVFoundation/AVVideoScalingModeFit`` results in an error.

---

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)