public class AVAssetWriter extends NSObject
AVAssetWriter provides services for writing media data to a new file,
Instances of AVAssetWriter can write media to new files in formats such as the QuickTime movie file format or the MPEG-4 file format. AVAssetWriter has support for automatic interleaving of media data for multiple concurrent tracks. Source media data can be obtained from instances of AVAssetReader for one or more assets or from other sources outside of AVFoundation.
Instances of AVAssetWriter can re-encode media samples as they are written. Instances of AVAssetWriter can also optionally write metadata collections to the output file.
A single instance of AVAssetWriter can be used once to write to a single file. Clients that wish to write to files multiple times must use a new instance of AVAssetWriter each time.
| Modifier and Type | Class and Description |
|---|---|
static interface |
AVAssetWriter.Block_finishWritingWithCompletionHandler |
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
AVAssetWriter(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
accessInstanceVariablesDirectly() |
void |
addInput(AVAssetWriterInput input)
addInput:
|
void |
addInputGroup(AVAssetWriterInputGroup inputGroup)
addInputGroup:
|
static AVAssetWriter |
alloc() |
static AVAssetWriter |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static AVAssetWriter |
assetWriterWithURLFileTypeError(NSURL outputURL,
java.lang.String outputFileType,
org.moe.natj.general.ptr.Ptr<NSError> outError)
assetWriterWithURL:fileType:error:
|
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
NSArray<java.lang.String> |
availableMediaTypes()
[@property] availableMediaTypes
|
boolean |
canAddInput(AVAssetWriterInput input)
canAddInput:
|
boolean |
canAddInputGroup(AVAssetWriterInputGroup inputGroup)
canAddInputGroup:
|
boolean |
canApplyOutputSettingsForMediaType(NSDictionary<java.lang.String,?> outputSettings,
java.lang.String mediaType)
canApplyOutputSettings:forMediaType:
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
void |
cancelWriting()
cancelWriting
|
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
static java.lang.String |
debugDescription_static() |
AVAssetWriterDelegate |
delegate()
[@property] delegate
|
static java.lang.String |
description_static() |
NSURL |
directoryForTemporaryFiles()
[@property] directoryForTemporaryFiles
|
void |
endSessionAtSourceTime(CMTime endTime)
endSessionAtSourceTime:
|
NSError |
error()
[@property] error
|
boolean |
finishWriting()
Deprecated.
|
void |
finishWritingWithCompletionHandler(AVAssetWriter.Block_finishWritingWithCompletionHandler handler)
finishWritingWithCompletionHandler:
|
void |
flushSegment()
flushSegment
|
static long |
hash_static() |
AVAssetWriter |
init() |
long |
initialMovieFragmentSequenceNumber()
[@property] initialMovieFragmentSequenceNumber
|
CMTime |
initialSegmentStartTime()
[@property] initialSegmentStartTime
|
AVAssetWriter |
initWithContentType(UTType outputContentType)
initWithContentType:
|
AVAssetWriter |
initWithURLFileTypeError(NSURL outputURL,
java.lang.String outputFileType,
org.moe.natj.general.ptr.Ptr<NSError> outError)
initWithURL:fileType:error:
|
NSArray<? extends AVAssetWriterInputGroup> |
inputGroups()
[@property] inputGroups
|
NSArray<? extends AVAssetWriterInput> |
inputs()
[@property] inputs
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
NSArray<? extends AVMetadataItem> |
metadata()
[@property] metadata
|
CMTime |
movieFragmentInterval()
[@property] movieFragmentInterval
|
int |
movieTimeScale()
[@property] movieTimeScale
|
static AVAssetWriter |
new_objc() |
java.lang.String |
outputFileType()
[@property] outputFileType
|
java.lang.String |
outputFileTypeProfile()
[@property] outputFileTypeProfile
|
NSURL |
outputURL()
[@property] outputURL
|
CMTime |
overallDurationHint()
[@property] overallDurationHint
|
CMTime |
preferredOutputSegmentInterval()
[@property] preferredOutputSegmentInterval
|
boolean |
producesCombinableFragments()
[@property] producesCombinableFragments
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
void |
setDelegate_unsafe(AVAssetWriterDelegate value)
[@property] delegate
|
void |
setDelegate(AVAssetWriterDelegate value)
[@property] delegate
|
void |
setDirectoryForTemporaryFiles(NSURL value)
[@property] directoryForTemporaryFiles
|
void |
setInitialMovieFragmentSequenceNumber(long value)
[@property] initialMovieFragmentSequenceNumber
|
void |
setInitialSegmentStartTime(CMTime value)
[@property] initialSegmentStartTime
|
void |
setMetadata(NSArray<? extends AVMetadataItem> value)
[@property] metadata
|
void |
setMovieFragmentInterval(CMTime value)
[@property] movieFragmentInterval
|
void |
setMovieTimeScale(int value)
[@property] movieTimeScale
|
void |
setOutputFileTypeProfile(java.lang.String value)
[@property] outputFileTypeProfile
|
void |
setOverallDurationHint(CMTime value)
[@property] overallDurationHint
|
void |
setPreferredOutputSegmentInterval(CMTime value)
[@property] preferredOutputSegmentInterval
|
void |
setProducesCombinableFragments(boolean value)
[@property] producesCombinableFragments
|
void |
setShouldOptimizeForNetworkUse(boolean value)
[@property] shouldOptimizeForNetworkUse
|
static void |
setVersion_static(long aVersion) |
boolean |
shouldOptimizeForNetworkUse()
[@property] shouldOptimizeForNetworkUse
|
void |
startSessionAtSourceTime(CMTime startTime)
startSessionAtSourceTime:
|
boolean |
startWriting()
startWriting
|
long |
status()
[@property] status
|
static org.moe.natj.objc.Class |
superclass_static() |
static long |
version_static() |
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public static AVAssetWriter alloc()
public static AVAssetWriter allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static AVAssetWriter assetWriterWithURLFileTypeError(NSURL outputURL, java.lang.String outputFileType, org.moe.natj.general.ptr.Ptr<NSError> outError)
Returns an instance of AVAssetWriter configured to write to a file in a specified container format.
Writing will fail if a file already exists at the specified URL.
UTIs for container formats that can be written are declared in AVMediaFormat.h.
URL - The location of the file to be written. The URL must be a file URL.fileType - A UTI indicating the format of the file to be written.outError - On return, if initialization of the AVAssetWriter fails, points to an NSError describing the nature of the failure.public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static AVAssetWriter new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public void addInput(AVAssetWriterInput input)
Adds an input to the receiver.
Inputs are created with a media type and output settings. These both must be compatible with the receiver.
Inputs cannot be added after writing has started.
input - The AVAssetWriterInput object to be added.public void addInputGroup(AVAssetWriterInputGroup inputGroup)
Adds an instance of AVAssetWriterInputGroup to the AVAssetWriter. The AVAssetWriter will mark the tracks associated with grouped inputs as mutually exclusive to each other for playback or other processing, if the output container format supports mutually exlusive relationships among tracks.
When an input group is added to an AVAssetWriter, the value of marksOutputTrackAsEnabled will automatically be set to YES for the default input and set to NO for all of the other inputs in the group.
Input groups cannot be added after writing has started.
inputGroup - The collection of AVAssetWriterInputs to be grouped together.public NSArray<java.lang.String> availableMediaTypes()
The media types for which inputs can be added to the receiver.
Some media types may not be accepted within the file format with which an AVAssetWriter was initialized.
public boolean canAddInput(AVAssetWriterInput input)
Tests whether an input can be added to the receiver.
An input that accepts media data of a type that is not compatible with the receiver, or with output settings that are not compatible with the receiver, cannot be added.
input - The AVAssetWriterInput object to be tested.public boolean canAddInputGroup(AVAssetWriterInputGroup inputGroup)
Tests whether an input group can be added to the receiver.
If outputFileType specifies a container format that does not support mutually exclusive relationships among tracks, or if the specified instance of AVAssetWriterInputGroup contains inputs with media types that cannot be related, the group cannot be added to the AVAssetWriter.
inputGroup - The AVAssetWriterInputGroup object to be tested.public boolean canApplyOutputSettingsForMediaType(NSDictionary<java.lang.String,?> outputSettings, java.lang.String mediaType)
Tests whether output settings for a specific media type are supported by the receiver's file format.
This method determines whether the output settings for the specified media type can be used with the receiver's file format. For example, video compression settings that specify H.264 compression are not compatible with file formats that cannot contain H.264-compressed video.
Attempting to add an input with output settings and a media type for which this method returns NO will cause an exception to be thrown.
outputSettings - The output settings that are to be tested.mediaType - The media type for which the output settings are to be tested. Media types are defined in AVMediaFormat.h.public void cancelWriting()
Cancels the creation of the output file.
If the status of the receiver is "failed" or "completed," -cancelWriting is a no-op. Otherwise, this method will block until writing is canceled.
If an output file was created by the receiver during the writing process, -cancelWriting will delete the file.
This method should not be called concurrently with -[AVAssetWriterInput appendSampleBuffer:] or -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:].
public NSURL directoryForTemporaryFiles()
Specifies a directory that is suitable for containing temporary files generated during the process of writing an asset.
AVAssetWriter may need to write temporary files when configured in certain ways, such as when performsMultiPassEncodingIfSupported is set to YES on one or more of its inputs. This property can be used to control where in the filesystem those temporary files are created. All temporary files will be deleted when asset writing is completed, is canceled, or fails.
When the value of this property is nil, the asset writer will choose a suitable location when writing temporary files. The default value is nil.
This property cannot be set after writing has started. The asset writer will fail if a file cannot be created in this directory (for example, due to insufficient permissions).
public void endSessionAtSourceTime(CMTime endTime)
Concludes a sample-writing session.
Call this method to complete a session started with -startSessionAtSourceTime:.
The endTime defines the moment on the timeline of source samples at which the session ends. In the case of the QuickTime movie file format, each sample-writing session's startTime...endTime pair corresponds to a period of movie time into which the session's samples are inserted. Samples with timestamps that are later than the session end time will still be added to the written file but will be edited out (i.e. not presented during playback). So if the first session has duration D1 = endTime - startTime, it will be inserted into the written file at time 0 through D1; the second session would be inserted into the written file at time D1 through D1+D2, etc. It is legal to have a session with no samples; this will cause creation of an empty edit of the prescribed duration.
It is not mandatory to call -endSessionAtSourceTime:; if -finishWritingWithCompletionHandler: is called without first invoking -endSessionAtSourceTime:, the session's effective end time will be the latest end timestamp of the session's appended samples (i.e. no samples will be edited out at the end).
It is an error to append samples outside of a sample-writing session. To append more samples after invoking -endSessionAtSourceTime:, you must first start a new session using -startSessionAtSourceTime:.
NOTE: Multiple sample-writing sessions are currently not supported. It is an error to call -startSessionAtSourceTime: a second time after calling -endSessionAtSourceTime:.
endTime - The ending asset time for the sample-writing session, in the timeline of the source samples.public NSError error()
If the receiver's status is AVAssetWriterStatusFailed, this describes the error that caused the failure.
The value of this property is an NSError that describes what caused the receiver to no longer be able to write to its output file. If the receiver's status is not AVAssetWriterStatusFailed, the value of this property is nil. This property is thread safe.
@Deprecated public boolean finishWriting()
Completes the writing of the output file.
This method is deprecated. Use finishWritingWithCompletionHandler: instead.
This method will block until writing is finished. When this method returns successfully, the file being written by the receiver is complete and ready to use.
Because this method is blocking and can take a long time to execute (especially with shouldOptimizeForNetworkUse set to YES), it should not be called from the main thread. Doing so can cause the finishWriting operation to fail.
If writing cannot be finished, this method returns NO. Clients can check the values of the status and error properties for more information on why writing could not be finished.
This method should not be called concurrently with -[AVAssetWriterInput appendSampleBuffer:] or -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:].
public void finishWritingWithCompletionHandler(AVAssetWriter.Block_finishWritingWithCompletionHandler handler)
Marks all unfinished inputs as finished and completes the writing of the output file.
This method returns immediately and causes its work to be performed asynchronously.
When the writing of the output file is finished, or if a failure or a cancellation occurs in the meantime, the specified handler will be invoked to indicate completion of the operation. To determine whether the operation succeeded, your handler can check the value of AVAssetWriter.status. If the status is AVAssetWriterStatusFailed, AVAsset.error will contain an instance of NSError that describes the failure.
To guarantee that all sample buffers are successfully written, ensure all calls to -[AVAssetWriterInput appendSampleBuffer:] or -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] have returned before invoking this method.
public AVAssetWriter init()
public AVAssetWriter initWithURLFileTypeError(NSURL outputURL, java.lang.String outputFileType, org.moe.natj.general.ptr.Ptr<NSError> outError)
Creates an instance of AVAssetWriter configured to write to a file in a specified container format.
Writing will fail if a file already exists at the specified URL.
UTIs for container formats that can be written are declared in AVMediaFormat.h.
URL - The location of the file to be written. The URL must be a file URL.fileType - A UTI indicating the format of the file to be written.outError - On return, if initialization of the AVAssetWriter fails, points to an NSError describing the nature of the failure.public NSArray<? extends AVAssetWriterInputGroup> inputGroups()
The instances of AVAssetWriterInputGroup that have been added to the AVAssetWriter.
The value of this property is an NSArray containing concrete instances of AVAssetWriterInputGroup. Input groups can be added to the receiver using the addInputGroup: method.
public NSArray<? extends AVAssetWriterInput> inputs()
The inputs from which the asset writer receives media data.
The value of this property is an NSArray containing concrete instances of AVAssetWriterInput. Inputs can be added to the receiver using the addInput: method.
public NSArray<? extends AVMetadataItem> metadata()
A collection of metadata to be written to the receiver's output file.
The value of this property is an array of AVMetadataItem objects representing the collection of top-level metadata to be written in the output file.
This property cannot be set after writing has started.
public CMTime movieFragmentInterval()
For file types that support movie fragments, specifies the frequency at which movie fragments should be written.
When movie fragments are used, a partially written asset whose writing is unexpectedly interrupted can be successfully opened and played up to multiples of the specified time interval. The default value of this property is kCMTimeInvalid, which indicates that movie fragments should not be used.
This property cannot be set after writing has started.
public int movieTimeScale()
For file types that contain a 'moov' atom, such as QuickTime Movie files, specifies the asset-level time scale to be used.
The default value is 0, which indicates that the receiver should choose a convenient value, if applicable.
This property cannot be set after writing has started.
public java.lang.String outputFileType()
The UTI of the file format of the file for which the instance of AVAssetWriter was initialized for writing.
public NSURL outputURL()
The location of the file for which the instance of AVAssetWriter was initialized for writing.
You may use UTTypeCopyPreferredTagWithClass(outputFileType, kUTTagClassFilenameExtension) to obtain an appropriate path extension for the outputFileType you have specified. For more information about UTTypeCopyPreferredTagWithClass and kUTTagClassFilenameExtension, on iOS see
public CMTime overallDurationHint()
For file types that support movie fragments, provides a hint of the final duration of the file to be written
The value of this property must be a nonnegative, numeric CMTime. Alternatively, if the value of this property is an invalid CMTime (e.g. kCMTimeInvalid), no overall duration hint will be written to the file. The default value is kCMTimeInvalid.
This property is currently ignored if movie fragments are not being written. Use the movieFragmentInterval property to enable movie fragments.
This property cannot be set after writing has started.
public void setDirectoryForTemporaryFiles(NSURL value)
Specifies a directory that is suitable for containing temporary files generated during the process of writing an asset.
AVAssetWriter may need to write temporary files when configured in certain ways, such as when performsMultiPassEncodingIfSupported is set to YES on one or more of its inputs. This property can be used to control where in the filesystem those temporary files are created. All temporary files will be deleted when asset writing is completed, is canceled, or fails.
When the value of this property is nil, the asset writer will choose a suitable location when writing temporary files. The default value is nil.
This property cannot be set after writing has started. The asset writer will fail if a file cannot be created in this directory (for example, due to insufficient permissions).
public void setMetadata(NSArray<? extends AVMetadataItem> value)
A collection of metadata to be written to the receiver's output file.
The value of this property is an array of AVMetadataItem objects representing the collection of top-level metadata to be written in the output file.
This property cannot be set after writing has started.
public void setMovieFragmentInterval(CMTime value)
For file types that support movie fragments, specifies the frequency at which movie fragments should be written.
When movie fragments are used, a partially written asset whose writing is unexpectedly interrupted can be successfully opened and played up to multiples of the specified time interval. The default value of this property is kCMTimeInvalid, which indicates that movie fragments should not be used.
This property cannot be set after writing has started.
public void setMovieTimeScale(int value)
For file types that contain a 'moov' atom, such as QuickTime Movie files, specifies the asset-level time scale to be used.
The default value is 0, which indicates that the receiver should choose a convenient value, if applicable.
This property cannot be set after writing has started.
public void setOverallDurationHint(CMTime value)
For file types that support movie fragments, provides a hint of the final duration of the file to be written
The value of this property must be a nonnegative, numeric CMTime. Alternatively, if the value of this property is an invalid CMTime (e.g. kCMTimeInvalid), no overall duration hint will be written to the file. The default value is kCMTimeInvalid.
This property is currently ignored if movie fragments are not being written. Use the movieFragmentInterval property to enable movie fragments.
This property cannot be set after writing has started.
public void setShouldOptimizeForNetworkUse(boolean value)
Specifies whether the output file should be written in way that makes it more suitable for playback over a network
When the value of this property is YES, the output file will be written in such a way that playback can start after only a small amount of the file is downloaded.
This property cannot be set after writing has started.
public boolean shouldOptimizeForNetworkUse()
Specifies whether the output file should be written in way that makes it more suitable for playback over a network
When the value of this property is YES, the output file will be written in such a way that playback can start after only a small amount of the file is downloaded.
This property cannot be set after writing has started.
public void startSessionAtSourceTime(CMTime startTime)
Initiates a sample-writing session for the receiver.
Sequences of sample data appended to the asset writer inputs are considered to fall within "sample-writing sessions", initiated with this method. Accordingly, this method must be called after writing has started (using -startWriting) but before any sample data is appended to the receiver's inputs.
Each writing session has a start time which, where allowed by the file format being written, defines the mapping from the timeline of source samples to the timeline of the written file. In the case of the QuickTime movie file format, the first session begins at movie time 0, so a sample appended with timestamp T will be played at movie time (T-startTime). Samples with timestamps earlier than startTime will still be added to the output file but will be edited out (i.e. not presented during playback). If the earliest appended sample for an input has a timestamp later than than startTime, an empty edit will be inserted to preserve synchronization between tracks of the output asset.
To end the session started by use of this method, use -endSessionAtSourceTime: or -finishWritingWithCompletionHandler:. It is an error to invoke -startSessionAtSourceTime: twice in a row without invoking -endSessionAtSourceTime: in between.
NOTE: Multiple sample-writing sessions are currently not supported. It is an error to call -startSessionAtSourceTime: a second time after calling -endSessionAtSourceTime:.
startTime - The starting asset time for the sample-writing session, in the timeline of the source samples.public boolean startWriting()
Prepares the receiver for accepting input and for writing its output to its output file.
This method must be called after all inputs have been added and other configuration properties have been set in order to tell the receiver to prepare for writing. After this method is called, clients can start writing sessions using startSessionAtSourceTime: and can write media samples using the methods provided by each of the receiver's inputs.
If writing cannot be started, this method returns NO. Clients can check the values of the status and error properties for more information on why writing could not be started.
On iOS, if the status of an AVAssetWriter is AVAssetWriterStatusWriting when the client app goes into the background, its status will change to AVAssetWriterStatusFailed and appending to any of its inputs will fail. You may want to use -[UIApplication beginBackgroundTaskWithExpirationHandler:] to avoid being interrupted in the middle of a writing session and to finish writing the data that has already been appended. For more information about executing code in the background, see the iOS Application Programming Guide.
public long status()
The status of writing samples to the receiver's output file.
The value of this property is an AVAssetWriterStatus that indicates whether writing is in progress, has completed successfully, has been canceled, or has failed. Clients of AVAssetWriterInput objects should check the value of this property after appending samples fails to determine why no more samples could be written. This property is thread safe.
public AVAssetWriterDelegate delegate()
An object that implements one or more of the methods in the AVAssetWriterDelegate protocol.
This property cannot be set after writing has started.
public void flushSegment()
Closes the current segment and outputs it to the -assetWriter:didOutputSegmentData:segmentType:segmentReport: or -assetWriter:didOutputSegmentData:segmentType: delegate method.
Use this method only when the value of preferredOutputSegmentInterval property is set to kCMTimeIndefinite.
public AVAssetWriter initWithContentType(UTType outputContentType)
Creates an instance of AVAssetWriter configured to output segment data in a specified container format.
Clients that want to receive segment data through the -assetWriter:didOutputSegmentData:segmentType:segmentReport: or -assetWriter:didOutputSegmentData:segmentType: delegate method should use this initializer instead of -initWithURL:fileType:error:.
Clients may use +typeWithIdentifier: with a UTI to create an instance of UTType. See
UTIs for container formats that can be output are declared in AVMediaFormat.h.
outputContentType - A UTType indicating the format of the segment data to be output.public long initialMovieFragmentSequenceNumber()
For file types that support movie fragments, specifies the initial movie fragment sequence number.
The value must be equal to or greater than 1.
The default value is 1.
Note that if you combine movie fragments produced by an instance of AVAssetWriter with additional movie fragments, produced either by a different instance of AVAssetWriter or by some other means, it is necessary to ensure that movie fragment sequence numbers increase monotonically across the entire combined collection, in temporal order.
This property cannot be set after writing has started.
public CMTime initialSegmentStartTime()
Specifies start time of initial segment.
A numeric time must be set if the value of preferredOutputSegmentInterval property is positive numeric. If not, this property is irrelevant.
This property cannot be set after writing has started.
public java.lang.String outputFileTypeProfile()
Specifies a file type profile for the specified file type.
The default value is nil, which means that the receiver will choose an appropriate default profile based on the specified file type.
Clients that want to receive segment data that is suitable for streaming through the -assetWriter:didOutputSegmentData:segmentType:segmentReport: or -assetWriter:didOutputSegmentData:segmentType: delegate method should set AVFileTypeProfileMPEG4AppleHLS, or AVFileTypeProfileMPEG4CMAFCompliant to require output that is specifically compliant with CMAF format, with AVFileTypeMPEG4 file type.
File type profiles are declared in AVMediaFormat.h.
This property cannot be set after writing has started.
public CMTime preferredOutputSegmentInterval()
Specifies preferred segment interval.
The default value is kCMTimeInvalid, which means that the receiver will choose an appropriate default value. The value can be set to positive numeric or kCMTimeIndefinite. If the value is kCMTimeIndefinite, every time a client calls -flushSegment the receiver outputs a segment data.
This property cannot be set after writing has started.
public boolean producesCombinableFragments()
For file types that support fragmented MPEG-4, specifies whether the movie fragments should be produced in way that makes them suitable for combining with movie fragments produced by one or more other instances of AVAssetWriter into a single fragment stream of uniform encoding.
The default value is NO.
When multiple instances of AVAssetWriter are used to produce distinct streams that complement each other, for example to create HLS encoding or bitrate variants, it’s not necessary to set this property to YES.
This property cannot be set after writing has started.
public void setDelegate_unsafe(AVAssetWriterDelegate value)
An object that implements one or more of the methods in the AVAssetWriterDelegate protocol.
This property cannot be set after writing has started.
public void setDelegate(AVAssetWriterDelegate value)
An object that implements one or more of the methods in the AVAssetWriterDelegate protocol.
This property cannot be set after writing has started.
public void setInitialMovieFragmentSequenceNumber(long value)
For file types that support movie fragments, specifies the initial movie fragment sequence number.
The value must be equal to or greater than 1.
The default value is 1.
Note that if you combine movie fragments produced by an instance of AVAssetWriter with additional movie fragments, produced either by a different instance of AVAssetWriter or by some other means, it is necessary to ensure that movie fragment sequence numbers increase monotonically across the entire combined collection, in temporal order.
This property cannot be set after writing has started.
public void setInitialSegmentStartTime(CMTime value)
Specifies start time of initial segment.
A numeric time must be set if the value of preferredOutputSegmentInterval property is positive numeric. If not, this property is irrelevant.
This property cannot be set after writing has started.
public void setOutputFileTypeProfile(java.lang.String value)
Specifies a file type profile for the specified file type.
The default value is nil, which means that the receiver will choose an appropriate default profile based on the specified file type.
Clients that want to receive segment data that is suitable for streaming through the -assetWriter:didOutputSegmentData:segmentType:segmentReport: or -assetWriter:didOutputSegmentData:segmentType: delegate method should set AVFileTypeProfileMPEG4AppleHLS, or AVFileTypeProfileMPEG4CMAFCompliant to require output that is specifically compliant with CMAF format, with AVFileTypeMPEG4 file type.
File type profiles are declared in AVMediaFormat.h.
This property cannot be set after writing has started.
public void setPreferredOutputSegmentInterval(CMTime value)
Specifies preferred segment interval.
The default value is kCMTimeInvalid, which means that the receiver will choose an appropriate default value. The value can be set to positive numeric or kCMTimeIndefinite. If the value is kCMTimeIndefinite, every time a client calls -flushSegment the receiver outputs a segment data.
This property cannot be set after writing has started.
public void setProducesCombinableFragments(boolean value)
For file types that support fragmented MPEG-4, specifies whether the movie fragments should be produced in way that makes them suitable for combining with movie fragments produced by one or more other instances of AVAssetWriter into a single fragment stream of uniform encoding.
The default value is NO.
When multiple instances of AVAssetWriter are used to produce distinct streams that complement each other, for example to create HLS encoding or bitrate variants, it’s not necessary to set this property to YES.
This property cannot be set after writing has started.