assetWriterInputWithMediaType:outputSettings:
Returns a new input to append sample buffers of the specified type to the output file.
Declaration
+ (instancetype) assetWriterInputWithMediaType:(AVMediaType) mediaType outputSettings:(NSDictionary<NSString *,id> *) outputSettings;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 to create preset-based settings.
Return Value
A new asset writer input.
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, pass a nonnull format hint using the 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:
AVFormatIDKey. The identifier of the audio format. For kAudioFormatLinearPCM format, you must include values for all relevant keys with a
AVLinearPCMprefix, and for kAudioFormatAppleLossless, you must specify a value for AVEncoderBitDepthHintKey.AVSampleRateKey. The sample rate of the audio. Common values are
44100and48000.AVNumberOfChannelsKey. If no other channel layout information is available, specifying a value of
1results in mono output and a value of2results in stereo output. If AVNumberOfChannelsKey specifies a channel count greater than2, the dictionary must also specify a value for AVChannelLayoutKey.
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, AVVideoWidthKey, AVVideoHeightKey.