Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

AVAssetExportSessionMBS.cancelExport
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: Cancels the execution of an export session.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.Constructor(asset as AVAssetMBS, presetName as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: Initializes an asset export session with a specified asset and preset.
Notes:
asset: The asset you want to export.
presetName: A string constant specifying the name of the preset template for the export.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.determineCompatibleFileTypes(tag as Variant = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 14.0 Yes No No Yes, macOS only No
Function: Reports the compatible file types for the current export session to the event.
Notes:
calls later AVFoundationMBS.determineCompatibleFileTypesCompleted event.

This method operates on the asset object and preset information that was used to initialize the export session. It uses this information to determine the file types that the export session can write.

This method performs its checks asynchronously on a secondary thread and returns immediately. The results are similarly reported to the specified block on a secondary thread. Because this method actually inspects the asset's tracks, the tracks are loaded if they have not been already.
Available in OS X v10.9 and later.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.exportAsynchronously(tag as Variant = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: Starts the asynchronous execution of an export session.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.m4v")
dim a as AVAssetMBS = AVAssetMBS.assetWithFile(f)
dim p as string = AVAssetExportSessionMBS.AVAssetExportPresetAppleM4VCellular
dim e as new AVAssetExportSessionMBS(a, p)

dim FileTypes() as string = e.supportedFileTypes
e.outputFileType = FileTypes(0)
e.OutputFile = SpecialFolder.Desktop.Child("small.m4v")
e.exportAsynchronously

// instead of waiting for event, we simply wait for it to finish
do
app.YieldToNextThread
loop until e.status <> e.AVAssetExportSessionStatusExporting
Notes:
This method starts an asynchronous export operation and returns immediately. status signals the terminal state of the export session, and if a failure occurs, error describes the problem.

This method calls AVFoundationMBS.exportAsynchronouslyCompleted event later. Tag is passed so you can pass information needed to finish work.

If internal preparation for export fails, event is invoked synchronously. The event may also be called asynchronously, after the method returns, in the following cases:

  • If a failure occurs during the export, including failures of loading, re-encoding, or writing media data to the output.
  • If cancelExport is invoked.
  • After the export session succeeds, having completely written its output to the outputURL.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.exportMT
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 18.2 Yes No No Yes, macOS only No
Function: Starts the synchronous execution of an export session.
Notes:
Same as exportAsynchronously, but run synchronous, so the plugin waits.
If called in a Xojo thread yields time to other threads.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.metadata as AVMetadataItemMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: Returns the metadata to be written to the output file by the export session.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.outputFileExtension as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: Convenience method to query the preferred file extension for current output file type.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.m4v")
dim a as AVAssetMBS = AVAssetMBS.assetWithFile(f)
dim p as string = AVAssetExportSessionMBS.AVAssetExportPresetAppleM4VCellular
dim e as new AVAssetExportSessionMBS(a, p)
dim filetypes() as string = e.supportedFileTypes
e.outputFileType = FileTypes(0)

// shows the output file extension
MsgBox "outputFileExtension: "+e.outputFileExtension

Feedback, Comments & Corrections

AVAssetExportSessionMBS.setMetadata(items() as AVMetadataItemMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: Sets the metadata to be written to the output file by the export session.
Example:
dim e as AVAssetExportSessionMBS // your export session
dim asset as AVAssetMBS // your asset

// query metadata
dim a() as AVMetadataItemMBS = asset.metadata

// make new
dim m as new AVMutableMetadataItemMBS

// add common key with author
m.keySpace = AVFoundationMBS.AVMetadataKeySpaceCommon
m.key = AVFoundationMBS.AVMetadataCommonKeyAuthor
m.Value = "Hello World"

// append to array and use as metadata:
a.Append m
e.setMetadata a
Notes: If the array is empty, any existing metadata in the exported asset will be translated as accurately as possible into the appropriate metadata key space for the output file and written to the output.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.supportedFileTypes as string()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: The types of files the session can write. (read-only)
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.m4v")
dim a as AVAssetMBS = AVAssetMBS.assetWithFile(f)
dim p as string = AVAssetExportSessionMBS.AVAssetExportPresetAppleM4VCellular
dim e as new AVAssetExportSessionMBS(a, p)
// shows supported file types
MsgBox join(e.supportedFileTypes, EndOfLine)
Notes: The types of files the session can write are determined by the asset and and export preset with which the session was initialized. If you need to determine the compatible file formats before initiating the export operation, use the determineCompatibleFileTypesWithCompletionHandler: method.

Feedback, Comments & Corrections

AVAssetExportSessionMBS.timeRange as CMTimeRangeMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: The time range to be exported from the source.
Example:
dim a as AVAssetMBS // your asset to export
dim preset as string = AVAssetExportSessionMBS.AVAssetExportPresetPassthrough // your settings
dim e as new AVAssetExportSessionMBS(a, preset)

dim t as CMTimeMBS = CMTimeMBS.MakeWithSeconds(5) // start at 5
dim d as CMTimeMBS = CMTimeMBS.MakeWithSeconds(10) // duration 10
dim r as CMTimeRangeMBS = CMTimeRangeMBS.Make(t,d)

e.timeRange = r // or your time range!
e.shouldOptimizeForNetworkUse = true

dim filetypes() as string = e.supportedFileTypes
e.outputFileType = FileTypes(0)
e.OutputFile = SpecialFolder.Desktop.Child("test."+e.outputFileExtension)

e.exportAsynchronously(nil)

// keep e and check for events

// or instead of waiting for event, we simply wait for it to finish
do
app.YieldToNextThread
loop until e.status <> e.AVAssetExportSessionStatusExporting
Notes:
The default time range of an export session is kCMTimeZero to kCMTimePositiveInfinity, meaning that (modulo a possible limit on file length) the full duration of the asset will be exported.
(Read and Write computed property)

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS AVFoundation Plugin.




Links
MBS Xojo Plugins