exportHook.py

exportHook.py contains all the hooks related to exporting clips.

These hooks are used when the user exports from the application.

Export hooks are called in the following order:

  1. preCustomExport Optional. Called if required by getCustomExportProfiles. Called when the contextual menu item defined by getCustomExportProfiles is selected by the user.
  2. preExport Always called. In a regular export, preExport is called as the Export window is displayed to the user. In a custom export, called after preCustomExport.
  3. preExportSequence Always called. Called before writing the sequence.
  4. preExportAsset Always called. When it is called depends on the export option. With Foreground Export, all preExportAsset are called for each assets immediately in one go. With Background Export, each preExportAsset is called as each asset job is submitted to Backburner.
  5. postExportAsset Always called. Called after an asset is written. Can be done in backburner as determined by use BackburnerPostExportAsset.
  6. postExportSequence Always called. Called after postExportAsset.
  7. postExport Always called. Called after postExportSequence.
  8. postCustomExport Optional: called if required by getCustomExportProfiles. Called after postExport.
Note: In the following descriptions, some dictionary keys have the [Modifiable] keyword. This indicates that assigning a value to this key will overwrite the key's original value. Keys without the [Modifiable] keyword have read-only values.

Export Hook Example

Every method in the export hooks has access to two dictionaries, userData and info. userData allows you to pass custom information between methods, with a scope covering the whole export session. info stores system information used by the application's export processes, but with a scope limited to the current method.

#The keys for 'profiles' are the items that appear in the 
# contextual menu in the application

def getCustomExportProfiles( profiles ):
  profiles['Post for review']= {'exportType':'forReview'} #Adds an entry to the 'userData' dictionary
  profiles['Package']    = {'exportType':'packageInternal'}           #Adds an entry to the 'userData' dictionary

Once the user selects a custom export option, the next hook that is fired is preCustomExport(), where the information about the export is set, based on the entry the user has selected.

def preCustomExport( info, userData ):
  #Test what 'exportType' was select in the UI, by the user
  if userData['exportType'] == 'forReview':
    #Set the proper 'presetPath' in the info dictionary
    #This defines which preset is used for the custom encode job
    info['presetPath'] = '/path/to/export/presets/uncompressed_qt.xml'

    #Set the 'destinationPath' in the info dictionary
    info['destinationPath'] = '/path/to/Flame/exports/' + CURRENT_PROJECT + '/'
  if userData['exportType'] == 'Package':
    #do something else...
Note: To create an export profile such as the one in the example above (/path/to/export/presets/uncompressed_qt.xml), you need to access the Export dialog, and save a new Format Preset. In this case, the Format Preset would be named uncompressed_qt.xml, and saved in /path/to/export/presets/.

In the above example, the option the user selects from the contextual menu defines the what is performed in the preCustomExport().

preCustomExport

Called before a custom export begins. This can be used to fill information that would have normally been extracted from the export window.

def preCustomExport( info, userData ):
   pass
info
Dictionary. Information about the export. Some of this information can be modified by the script as it executes and is marked as Editable.
Key Description Data Type
destinationHost Editable. Name of the host where the exported files will be written. Defaults to localhost. String
destinationPath Editable. Export path root. This path will probably be added to by the actual Preset path. Defaults to /tmp. String
presetPath Editable. Path to the preset used for the Export. String
useTopVideoTrack Editable. Use only the top video track and ignore the other ones. False if not defined. Boolean
exportBetweenMarks Editable. Export between the In and Out marks, excluding the marked frames. Without In, export from start of sequence to Out; without Out, export from the In to the end of the sequence. False if not defined. Boolean
isBackground Editable. Perform the export in background. True if not defined. Boolean
abort Editable. Set abort to True to abort the export process. Boolean
abortMessage Editable. The error message to be displayed to the user when the export process has been aborted. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

postCustomExport

Called after a custom export ends.

def postCustomExport( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files were written to. String
destinationPath Root of the export path. String
presetPath Path to the preset used for the Export. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

preExport

Called before an export begins

def preExport( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files will be written to. String
destinationPath Root of the export path. String
abort Editable. Set abort to True to abort the export process. Boolean
abortMessage Editable. The error message to be displayed to the user when the export process has been aborted. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

postExport

Called after an export ends.

def postExport( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files were written to. String
destinationPath Root of the export path. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

preExportSequence

Called before an sequence export begins.

def preExportSequence( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files were written to. String
destinationPath Root of the export path. String
sequenceName Name of the exported sequence. String
shotNames Tuple of every shot name in the exported sequence. Note that multiple segments can use the same shot name: segments sharing shot names are part of the same shot. String
abort Editable. Set abort to True to abort the export process. Boolean
abortMessage Editable. The error message to be displayed to the user when the export process has been aborted. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

postExportSequence

Called after a sequence export ends.

def postExportSequence( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files were written to. String
destinationPath Root of the export path. String
sequenceName Name of the exported sequence. String
shotNames Tuple of every shot name in the exported sequence. Note that multiple segments can use the same shot name: segments sharing shot names are part of the same shot. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

preExportAsset

Called before an asset export begins.

def preExportAsset( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files were written to. String
destinationPath Root of the export path. String
namePattern List of optional naming tokens as entered in the application UI. String
resolvedPath Editable.Path (relative to destinationPath) with the tokens resolved. String
name Name of the exported asset. String
sequenceName Name of the sequence to which this asset belongs. String
shotNames Name of the shot to which this asset belongs. String
assetType Type of the exported asset. Possible values:
  • video
  • audio
  • batch
  • openClip
  • batchOpenClip
String
width Frame width of the exported asset. Long
height Frame height of the exported asset. Long
aspectRatio Frame aspect ratio of the exported asset. Double
depth Bit depth of the exported asset. Possible values:
  • 8-bits
  • 10-bits
  • 12-bits
  • 16 fp
String
scanFormat Scan format of the exported asset. Possible values:
  • FIELD_1
  • FIELD_2
  • PROGRESSIVE
String
fps Frame rate of the exported asset. Double
sequenceFps Frame rate of the sequence to which this asset belongs. Double
sourceIn The source In point as a frame, using the asset frame rate (the fps key). Integer
sourceOut The source Out point as a frame, using the asset frame rate (the fps key). Integer
recordIn The record In point as frame, using the sequence frame rate (the sequenceFps key). Integer
recordOut The record Out point as a frame, using the sequence frame rate (the sequenceFps key). Integer
handleIn Head as a frame, using the asset frame rate (fps key). Integer
handleOut Tail as a frame, using the asset frame rate (fps key). Integer
track ID of the sequence's track that contains the asset. String
trackName Name of the sequence's track that contains the asset. String
segmentIndex Asset index (1 based) in the track. Integer
versionName Current version name of this export. Empty if unversionned. String
versionNumber Current version number of this export. Zero if unversionned. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

postExportAsset

Called after an asset export ends.

def postExportAsset( info, userData ):
   pass
info
Dictionary. Information about the export.
Key Description Data Type
destinationHost Name of the host where the exported files were written to. String
destinationPath Root of the export path. String
namePattern List of optional naming tokens as entered in the application UI. String
resolvedPath Editable.Path (relative to destinationPath) with the tokens resolved. String
name Name of the exported asset. String
sequenceName Name of the sequence to which this asset belongs. String
shotNames Name of the shot to which this asset belongs. String
assetType Type of the exported asset. Possible values:
  • video
  • audio
  • batch
  • openClip
  • batchOpenClip
String
width Frame width of the exported asset. Long
height Frame height of the exported asset. Long
aspectRatio Frame aspect ratio of the exported asset. Double
depth Bit depth of the exported asset. Possible values:
  • 8-bits
  • 10-bits
  • 12-bits
  • 16 fp
String
scanFormat Scan format of the exported asset. Possible values:
  • FIELD_1
  • FIELD_2
  • PROGRESSIVE
String
fps Frame rate of the exported asset. Double
sequenceFps Frame rate of the sequence to which this asset belongs. Double
sourceIn The source In point as a frame, using the asset frame rate (the fps key). Integer
sourceOut The source Out point as a frame, using the asset frame rate (the fps key). Integer
recordIn The record In point as frame, using the sequence frame rate (the sequenceFps key). Integer
recordOut The record Out point as a frame, using the sequence frame rate (the sequenceFps key). Integer
handleIn Head as a frame, using the asset frame rate (fps key). Integer
handleOut Tail as a frame, using the asset frame rate (fps key). Integer
track ID of the sequence's track that contains the asset. String
trackName Name of the sequence's track that contains the asset. String
segmentIndex Asset index (1 based) in the track. Integer
versionName Current version name of this export. Empty if unversionned. String
versionNumber Current version number of this export. Zero if unversionned. String
userData
Dictionary. User-defined. Dictionary that could have been populated by previous export hooks and that will be carried over into the subsequent export hooks. This can be used by the hook to pass black box data around.

useBackburnerPostExportAsset

Indicates whether postExportAsset should be called from a backburner job or directly from the application.

Not generating a postExportAsset backburner job for exports that are using backburner could result in postExportAsset being called before the export job is complete.

def useBackburnerPostExportAsset():
   return True

getCustomExportProfiles

Returns the custom export profiles to show to the user in the contextual menu that is displayed when right-clicking a clip in the application. These custome export profiles are displayed after the Export... menu item, and are expected to trigger an export.

def getCustomExportProfiles( profiles ):
   pass
profiles
Dictionary. User-Defined. A dictionary of userData dictionaries where the keys are also used as the name of the profiles displayed in the contextual menu.