AVExport.ExportSession
----------------------

Creates a new export session.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [AVExport](component_AVExport.md) | [6.1](newinversion61.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "AVExport.ExportSession"; Asset; Preset ) 

**MBS**( **"AVExport.ExportSession";** /\* Creates a new export session. \*/  
**$Asset**; /\* The reference number of the asset. Please use [AVAsset.OpenContainer](AVAssetOpenContainer.md), [AVAsset.OpenFile](AVAssetOpenFile.md) or [AVAsset.OpenURL](AVAssetOpenURL.md) function to get asset reference. \*/   
**$Preset**) /\* The preset name to use.   
Can be one of the presets returned by [AVExport.AllExportPresets](AVExportAllExportPresets.md) or one of the predefined ones:e.g. "640x480" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Asset | The reference number of the asset. Please use [AVAsset.OpenContainer](AVAssetOpenContainer.md), [AVAsset.OpenFile](AVAssetOpenFile.md) or [AVAsset.OpenURL](AVAssetOpenURL.md) function to get asset reference. | $asset |
| Preset | The preset name to use.    Can be one of the presets returned by [AVExport.AllExportPresets](AVExportAllExportPresets.md) or one of the predefined ones: | "640x480" |

### Result

Returns reference number or error.

### Description

Creates a new export session.  
Returns a reference number for the new AVAsset export session for the specified source asset and preset.  
  
Presets:  
These export options can be used to produce movie files with video size appropriate to the device. The export will not scale the video up from a smaller size. The video will be compressed using H.264 and the audio will be compressed using AAC.  
  
| LowQuality | Low Quality | OS X 10.11 and newer |
|---|---|---|
| MediumQuality | Medium Quality | OS X 10.11 and newer |
| HighestQuality | High Quality | OS X 10.11 and newer |

  
These export options can be used to produce movie files with the specified video size.  
The export will not scale the video up from a smaller size. The video will be compressed using H.264 and the audio will be compressed using AAC. Some devices cannot support some sizes.  
  
| 640x480 | VGA Resolution, 640 x 480 Pixel | OS X 10.7 and newer |
|---|---|---|
| 960x540 | Half HD Resolution, 960 x 540 Pixel | OS X 10.7 and newer |
| 1280x720 | 720p Resolution, 1280 x 720 Pixel | OS X 10.7 and newer |
| 1920x1080 | Full HD Resolution, 1920 x 1080 Pixel, | OS X 10.7 and newer |
| 3840x2160 | 4K Resolution, 3840 x 2160 | OS X 10.10 and newer |

  
These export options are used to produce files that can be played on the specified Apple devices. These presets are available for Desktop export only. The files should have .m4v extensions (or .m4a for exports with audio only sources).  
  
| AppleM4VCellular | Celluar | OS X 10.7 and newer |
|---|---|---|
| AppleM4ViPod | iPod | OS X 10.7 and newer |
| AppleM4V480pSD | 480p SD | OS X 10.7 and newer |
| AppleM4VAppleTV | AppleTV | OS X 10.7 and newer |
| AppleM4VWiFi | Wifi | OS X 10.7 and newer |
| AppleM4V720pHD | 720p HD | OS X 10.7 and newer |
| AppleM4V1080pHD | 1080p HD | OS X 10.8 and newer |

  
Passthrough export option will cause the media of all tracks to be passed through to the output exactly as stored in the source asset, except for tracks for which passthrough is not possible, usually because of constraints of the container format as indicated by the specified outputFileType. This option is not included in the arrays returned by [AVExport.AllExportPresets](AVExportAllExportPresets.md).  
  
| Passthrough | Pass through data if possible. | OS X 10.7 and newer |
|---|---|---|
| AppleM4A | Audio-only .m4a file with appropriate iTunes gapless playback data | OS X 10.7 and newer |
| AppleProRes422LPCM | QuickTime movie with Apple ProRes 422 video and LPCM audio. | OS X 10.7 and newer |

  
You can use AVExport.ExportSession to export to a new file. With [AVExport.SetTimeRange](AVExportSetTimeRange.md) you can only export a clip and with [AVExport.ExportSessionMerge](AVExportExportSessionMerge.md) you can merge multiple videos to one.  
### Examples

Create export session:

 If \[not IsEmpty($$AVExport )\]  
 Show Custom Dialog \["We have a session already!?"\]  
 Exit Script \[\]  
End If  
Set Variable \[$Asset ; Value:MBS ( "[AVAsset.OpenFile](AVAssetOpenFile.md)"; AVAsset Export Session::Input File Path )\]  
Set Variable \[$$AVExport ; Value:MBS ( "AVExport.ExportSession"; $Asset ; AVAsset Export Session::PresetName )\]  
If \[MBS ("IsError")\]  
 Set Variable \[$r ; Value:MBS ( "[AVAsset.Release](AVAssetRelease.md)"; $Asset )\]  
 Show Custom Dialog \["Failed to create export sessio…"; MBS ("[Text.RemovePrefix](TextRemovePrefix.md)"; $$AVExport ; "\[MBS \] ")\]  
 Exit Script \[\]  
End If  
Set Variable \[$r ; Value:MBS ( "[AVAsset.Release](AVAssetRelease.md)"; $Asset )\]  
Set Field \[AVAsset Export Session::Duration ; MBS ( "[AVExport.Duration](AVExportDuration.md)"; $$AVExport )\]  
Set Field \[AVAsset Export Session::SupportedFileTypes ; MBS ( "[AVExport.SupportedFileTypes](AVExportSupportedFileTypes.md)"; $$AVExport )\]  
### See also

- [AVAsset.OpenContainer](AVAssetOpenContainer.md)
- [AVAsset.OpenFile](AVAssetOpenFile.md)
- [AVAsset.OpenURL](AVAssetOpenURL.md)
- [AVAsset.Release](AVAssetRelease.md)
- [AVExport.AllExportPresets](AVExportAllExportPresets.md)
- [AVExport.Duration](AVExportDuration.md)
- [AVExport.ExportSessionMerge](AVExportExportSessionMerge.md)
- [AVExport.SetTimeRange](AVExportSetTimeRange.md)
- [AVExport.SupportedFileTypes](AVExportSupportedFileTypes.md)
- [Text.RemovePrefix](TextRemovePrefix.md)

### Release notes

- **Version 8.0**
    - Fixed problem with [AVExport.ExportSessionMerge](http://www.mbsplugins.eu/AVExportExportSessionMerge.shtml) and new example to work.

### Example Databases

- [Mac only/Movies/AVAsset Export Session](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/Movies/AVAsset%20Export%20Session.shtml#2ScriptAnchor_)

This function checks for a license.

Created 29th February 2016 , last changed 2nd February 2022

  
[AVExport.ExportAsynchronously](AVExportExportAsynchronously.md) - [AVExport.ExportSessionMerge](AVExportExportSessionMerge.md)

[HTML Version](AVExportExportSession.shtml)