Use available Python hooks are there to help you integrate Flame Premium into a shot management system, monitor archives, or just specify how batch setups are named.
All Python hook files are located in /usr/discreet/<application>/python/.
To provide more flexibility in how hook implementations are deployed, Flame Premium loads modules, searching for supported methods until all supported hooks are found. This allows you to separate hook implementations into multiple files, making allowance for better organization. Module specific hooks are part of specific files:
A new hotkey has been added to re-scan hook files while the application is running. This is useful to iteratively test changes during implementation.
By default, this is mapped to Ctrl+Shift+P+H, but can be found in the hotkey editor under the name Scan for python hooks.
Called when a restore operation from an archive successfully completes. A restore operation can be as simple as a partial restore (restoring a single clip) or as long as a full Project restore.
def archiveRestored( archiveName ): print 'This archive was successfully restored: %s' % archiveName
Called when an archive operation successfully completes. This can be archiving individual clips, Archive Project, or Archive Setups. The archive need not be closed (Close Archive from the application UI) for archiveComplete to be called.
def archiveComplete( archiveName ): print 'This archive was successfully created: %s' % archiveName
Called each time an archive segment is successfully written.
def archiveSegmentComplete( segmentPath, archiveName, archivePath, status, statusMessage, archiveComplete ): pass
archiveSelectionUpdated is blocking. The application waits for it to return.
Called when the user updates the information on the currently selected element in an opened archive (either through the U keyboard shortcut, or through the
.) Update selection information tells the user which segments are needed to bring the selection back online.def archiveSelectionUpdated( segmentInfo, numFrames, numClips, dataSize, metadataSize ): pass
batchSetupLoaded.func_dict[ "async" ] = True #Runs in its own interepreter separate from the application batchSetupSaved.func_dict[ "async" ] = False #Uses the same thread as the application
batchSetupLoaded and batchSetupSaved can be run synchronously, or asynchronously in its own interpreter, by setting their respective func_dict["async"] true or false.
Called whenever a batch setup is successfully loaded.
def batchSetupLoaded( setupPath ): pass
Called whenever a batch setup is successfully saved.
def batchSetupSaved( setupPath ): pass
This hook is called before the Write File node starts rendering and writing files to disk. batchExportBegin blocks the export until it returns. This allows it to update the paths to the media even before it is created.
def batchExportBegin( info, userData ): pass
Key | Description | Data Type |
---|---|---|
nodeName | Name of the export node | String |
exportPath | Editable. Export path as entered in the export node from within application. Can be modified by the hook to change the written file's destination. | String |
namePattern | List of optional naming tokens as entered in the application UI. | String |
resolvedPath | Full path to the first frame that will be exported, with all the tokens resolved. | String |
firstFrame | Frame number of the first frame that will be exported. | Integer |
lastFrame | Frame number of the last frame that will be exported. | Integer |
versionNumber | Current version number of this export. Zero there is no version. |
Integer |
openClipNamePattern | List of the tokens used in the UI to name the Open Clip XML that will be created by the export node. Only available if Clip Version (versionning) is enabled in the UI. |
String |
openClipResolvedPath | Full path to the open clip that will be created, with all the tokens resolved. Only available if Clip Version (versionning) is enabled in the UI. |
String |
setupNamePattern | List of the tokens used in the UI to name the batch setup that will be created by the export node. Only available if Clip Version (versionning) is enabled in the UI. |
String |
setupResolvedPath | Full path to the batch setup that will be created, with all the tokens resolved. Only available if Clip Version (versionning) is enabled in the UI. |
String |
This hook is called whenever a Write File node in Batch finished its render. Use it, amongst other things, to publish renders to shot tracking systems, or to perform post-processing on successful renders.
def batchExportEnd( info, userData ): pass
Key | Description | Data Type |
---|---|---|
nodeName | Name of the export node. | String |
exportPath | Export path either entered in the export node from within application, or edited by batchExportBegin. | String |
namePattern | List of the naming tokens as entered in the application UI. | String |
resolvedPath | Full path to the first frame that was exported, with all the tokens resolved. | String |
firstFrame | Frame number of the first frame that was exported. | Integer |
lastFrame | Frame number of the last frame that was exported. | Integer |
versionNumber | Current version number of this export. Zero if there is no version. |
Integer |
versionName | Current version name of this export. Empty if unversionned. | String |
fps | Frame width of the exported frames. | Double |
scanFormat | Scan format of the exported asset. Possible values:
|
String |
depth | Bit depth of the exported asset. Possible values:
|
String |
height | Frame height of the exported asset. | Long |
width | Frame width of the exported asset. | Long |
aspectRatio | Frame aspect ratio of the exported asset. | Double |
openClipNamePattern | List of the tokens used in the UI to name the Open Clip XML that was created by the export node. Only available if Clip Version (versionning) is enabled in the UI. |
String |
openClipResolvedPath | Full path to the open clip that was created, with all the tokens resolved. Only available if Clip Version (versionning) is enabled in the UI. |
String |
setupNamePattern | List of the tokens used in the UI to name the batch setup that was created by the export node. Only available if Clip Version (versionning) is enabled in the UI. |
String |
setupResolvedPath | Full path to the batch setup that was created, with all the tokens resolved. Only available if Clip Version (versionning) is enabled in the UI. |
String |
Called at application startup, and whenever the user switches project. Use it to define the default name given to new Batches created by the user in the Media Panel. Overrides the preferences defined in
. The returned value can use any of the tokens available in the UI such as <user nickname> (note the lack of underscore).def batchDefaultIterationName( project ): return ""
if project == "project_name": return "<batch name>_<iteration###>_project" return "<batch name>_<iteration###>_global"
Called at application startup, and whenever the user switches project. Use it to define the default node name given to new render nodes. Overrides the preferences defined in
. The returned value can use any of the tokens available in the UI such as <user nickname> (note the lack of underscore).def batchDefaultRenderNodeName( project ): return ""
if project == "project_name": return "<batch name>_render_project" return "<batch name>_render_global"
Called at application startup, and whenever the user switches project. Use it to define the default node name given to new write file nodes. Overrides the preferences defined in
. The returned value can use any of the tokens available in the UI such as <user nickname> (note the lack of underscore).def batchDefaultWriteFileNodeName( project ): return ""
if project == "project_name": return "<batch name>_write_file_project" return "<batch name>_write_file_global"
projectChanged.func_dict[ "async" ] = True #Runs in its own interepreter separate from the application appInitialized.func_dict[ "async" ] = False #Uses the same thread as the application
projectChanged, appInitialized, and projectSaved can all be run synchronously or asynchronously in its own interpreter, by setting their respective func_dict["async"] true or false.
Called every time the project is changed in the application. This includes the project selection on launch.
def projectChanged(projectName): pass
Called when the application is done loading (from to the Start screen to the actual tab-based UI).
def appInitialized( projectName ): pass
Called whenever a project save is performed by the application. Can be an auto-save, or a user-initiated one.
def projectSaved( projectName, saveTime, isAutoSave ): pass
Located in the hook.py.
Called when a sequence finishes rendering, even if the render was unsuccessful due to factors such as a manual abort.
def renderEnded(sequenceName, elapsedTimeInSeconds): pass
Called when a sequence finishes playback, successfully or not.
def playbackEnded(sequenceName, fps): pass
Called when the user changes the video preview device. The parameters for previewWindowConfigChanged are actually read from the init.cfg VideoPreviewDevice keyword.
def previewWindowConfigChanged(description,width,height,bitDepth, rateString,syncString): pass
Located in the exportHook.py.
These hooks are used when the user exports from the application.
Export hooks are called in the following order:
The info dictionary contains the information set by the selected preset, be that by the contextual menu defined by getCustomExportProfiles, or by the preset selected by the user in the Export window.
This means that for regular exports, the user either uses one of the presets, or inputs the required information in the Export dialog box. For custom exports, the getCustomExportProfiles get the actual profile use, based on the contextual menu defined within.
def getCustomExportProfiles( profiles ): profiles['Create Stuff']= '/usr/discreet/flamepremium_2015.2.pr45/export/presets/CustomExport.xml'
When performing a regular export through the Export window, use preExport to validate or overwrite settings that the user might have changed. This ensures the exported information is correctly output, to the correct directory.
def postExportAsset( info, userData ): # These processes are performed here because the postExportAsset is called # each time an asset is done being written. # # Make sure that the written asset is something we actually went to process # assetType = info.get( "assetType" ) if ( assetType not in [ "video", "batch", "openClip", "batchOpenClip" ] ): return # If the export is foreground, accumulate the asset and update the asset # management system at the end of the export process to increase performace # if ( not info.get( "isBackground", False ) ): userData[ "assetList" ][ assetType ].append( info ) else: if ( assetType == "video" ): createVersions # Create a new version in the asset management elif ( assetType == "batch" ): createBatchAssets # Create an entry for the Batch setup elif ( assetType == "openClip" ): createOpenClipAsset # Create and insert the Open Clip XML file elif ( assetType == "batchOpenClip" ): createBatchOpenClip # Create the batch Open Clip XML file
Called before a custom export begins, just after the user clicks the Export button. The export is blocked until the function returns.
def preCustomExport( info, userData ): pass
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 |
Called after a custom export ends. The export is blocked until postCustomExport returns.
def postCustomExport( info, userData ): pass
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 |
Called before an export begins
def preExport( info, userData ): pass
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 |
Called before an export begins
def postExport( info, userData ): pass
Key | Description | Data Type |
---|---|---|
destinationHost | Name of the host where the exported files were written to. | String |
destinationPath | Root of the export path. | String |
Called before an sequence export begins. The export is blocked until this function returns.
def preExportSequence( info, userData ): pass
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 |
Called after a sequence export ends. The export is blocked until this function returns.
def postExportSequence( info, userData ): pass
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 |
Called before an asset export begins. The export is blocked until this function returns.
def preExportAsset( info, userData ): pass
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:
|
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:
|
String |
scanFormat | Scan format of the exported asset. Possible values:
|
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 |
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 |
Called after an asset export ends. The export is blocked until this function returns.
def postExportAsset( info, userData ): pass
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:
|
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:
|
String |
scanFormat | Scan format of the exported asset. Possible values:
|
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 |
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 |
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
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