Publish components for review¶
Local review¶
Playing content in local players, such as HieroPlayer, requires published versions in ftrack. Versions can be published from the API like this:
# Query a shot and a task
shot = # Get a shot
task = # Get a task
# Create/query an asset
asset = shot.createAsset(name='forest', assetType='geo')
# Create a new version
version = asset.createVersion(comment='added more leafs', taskid=task.getId())
# main component
quicktimePath = "/var/dev/mytest.mov"
quicktimeComponent = version.createComponent(name='movie', file=quicktimePath)
# 3D model
modelPath = "/projects/dvs/assets/X/mymodel.obj"
modelComponent = version.createComponent(name='model', file=modelPath)
# Publish
version.publish()
To specify which component should play when loading a version you need to set the “Playable component name” for each asset type. This is done from
. By default the playable component name will be “main”.
Note
In the code example above the “Playable component name” for the asset type “geo” needs to be “movie”. After you have published some versions and specified the “Playable component name” you’re good to go.
Review in web interface¶
It is also possible to review files in the web interface using the built-in review tools in ftrack.
To publish components compatible for reviewing in browser, you can either let ftrack manage the storage and hosting or setup your own hosting.
See also
Using ftrack legacy API¶
To create components using the ftrack legacy python API you can use the
helper method ftrack.Review.makeReviewable()
:
filepath = '/path/to/local/file.mov'
# Create/query an asset
asset = shot.createAsset(name='forest', assetType='geo')
# Create a new version
version = asset.createVersion(
comment='Web reviewable version', taskid=task.getId()
)
# Use utility method to upload file, transcode it to appropriate formats
# and create new components.
ftrack.Review.makeReviewable(version, filepath=filepath)
# Publish the version to make it visible in ftrack.
version.publish()
Note
The encoding of the files will occur asynchronous and the components
might not be available when ftrack.Review.makeReviewable()
is done.
If you already have a file encoded in the correct format and want to bypass the built-in encoding in ftrack, you can create the component manually and add it to the ftrack.server location.
version = # Retrieve or create a version you want to use
filepath = '/path/to/local/file.mp4'
component = version.createComponent(
'ftrackreview-mp4', path=filepath,
location=ftrack.Location('ftrack.server')
)
# Meta data needs to contain *frameIn*, *frameOut* and *frameRate*.
meta_data = json.dumps({
'frameIn': 0,
'frameOut': 150,
'frameRate': 25
})
component.setMeta(key='ftr_meta', value=meta_data)
Note
For the component to play in the web browser, meta data with key ftr_meta need to exist on the component.
This will transfer the file to the ftrack.server location and enable it for review in ftrack.
Note
Make sure to use the pre-defined component names ftrackreview-mp4, ftrackreview-webm and ftrackreview-image. They are used to identify playable components in ftrack.
To publish an image for review the steps are similar:
version = # Retrieve or create a version you want to use
filepath = '/path/to/image.jpg'
component = version.createComponent(
'ftrackreview-image', path=filepath,
location=ftrack.Location('ftrack.server')
)
# Meta data needs to contain *format*.
meta_data = json.dumps({
'format': 'image'
})
component.setMeta(key='ftr_meta', value=meta_data)
Using ftrack python API¶
Note
The Python API currently does not support triggering encoding by ftrack. If encoding by ftrack is needed use the legacy api
To add a playable component on a version we simply need to create a new component, add it to the server location and set some additional meta data used by the player.
version = # Retrieve or create version.
server_location = session.query('Location where name is "ftrack.server"').one()
filepath = '/path/to/local/file.mp4'
component = version.create_component(
path=filepath,
data={
'name': 'ftrackreview-mp4'
},
location=server_location
)
# Meta data needs to contain *frameIn*, *frameOut* and *frameRate*.
component['metadata']['ftr_meta'] = json.dumps({
'frameIn': 0,
'frameOut': 150,
'frameRate': 25
})
component.session.commit()
Note
For the component to play in the web browser, meta data with key ftr_meta need to exist on the component.
To publish an image for review the steps are similar:
version = # Retrieve or create a version you want to use
server_location = session.query('Location where name is "ftrack.server"').one()
filepath = '/path/to/image.jpg'
component = version.create_component(
path=filepath,
data={
'name': 'ftrackreview-image'
},
location=server_location
)
# Meta data needs to contain *format*.
component['metadata']['ftr_meta'] = json.dumps({
'format': 'image'
})
component.session.commit()
Note
Make sure to use the pre-defined component names ftrackreview-mp4, ftrackreview-webm and ftrackreview-image. They are used to identify playable components in ftrack.