LMV Translation
Introduction
The LMVTranslator
class helps you translate files to a file format readable by Flow Production Tracking
3D Viewer. It also offers the possibility to extract a thumbnail from the source file.
Sample Code: Upload file to Flow Production Tracking Version
Here is a simple piece of code to create the zip file which will be uploaded to Flow Production Tracking in order to be read by the 3D Viewer:
# source_path = "/path/to/file.wire"
# here we assume that the version is already created in Flow Production Tracking and we have it ID
version_id = 1234
# create an instance of LMVExtractor, translate the file and package the output files
lmv_extractor = LMVExtractor(source_path)
lmv_extractor.translate()
# use the version id as the svf file name otherwise the 3D Viewer couldn't be able to read
# the media file
package_path, _ = lmv_extractor.package(svf_file_name=version_id)
# finally, upload the file to the Version and change the Translation type to LMV
sg.upload("Version", version_id, path=package_path, field_name="sg_uploaded_movie")
sg.update("Version", version_id, data={"sg_translation_type": "LMV"})
Sample Code: Create a thumbnail from a source file
It’s also possible to extract a thumbnail from the source file using the LMV conversion:
# source_path = "/path/to/file.wire"
# we need to translate the file in order to extract the thumbnail
lmv_extractor = LMVExtractor(source_path)
lmv_extractor.translate()
# we can then extract the thumbnail properly
thumbnail_path = lmv_extractor.extract_thumbnail()
LMVTranslator
- class translator.LMVTranslator(path, tk, context)[source]
A class to translate files to be consumed by the Flow Production Tracking 3D LMV Viewer.
Class constructor.
- Parameters:
path – Path to the source file we want to perform operations on.
- get_translators_by_file_type()[source]
Return a mapping of file types to translator engine.
The translator engine is the name of the engine that has the necessary tools to translate the file type.
- get_translator_relative_paths()[source]
Return a mapping of translator engine to the relative path of the translator executable.
The path return is relative to the engine’s software executable location.
- find_translator_path(context, engine_name, translator_executable_path)[source]
Find the translator executable path relative to the engine’s software location.
- Parameters:
context (sgtk.Context) – The Toolkit context used to create an engine launcher that can determine the engine software location.
engine_name (str) – The name of the engine.
extractor_path (str) – The relative file path from the engine’s software location, to the thumbnail extractor executable.
- Returns:
The thumbnail extractor executable path relative to the engine’s software location.
- Return type:
- property source_path
Path of the file used as source for all the translations.
- Returns:
The file path as a string
- property output_directory
Path to the directory where all the translated files will be stored.
- Returns:
The directory path as a string
- translate(output_directory=None)[source]
Run the translation to convert the source file to a bunch of files needed by the 3D Viewer.
- Parameters:
output_directory – Path to the directory we want to translate the file to. If no path is supplied, a temporary one will be used
use_framework_translator – True will use the translator shipped with the framework, else False (default) will use a translator based on the type of file to translate and the current engine running.
- Returns:
The path to the directory where all the translated files have been written.
- package(svf_file_name=None, thumbnail_path=None)[source]
Package all the translated files into a zip file and extract the LMV thumbnail if needed
- Parameters:
svf_file_name – If supplied, rename the svf file according to the given name
thumbnail_path – If supplied, use this thumbnail as LMV thumbnail. Otherwise, try to extract the thumbnail from the source file
- Returns:
The path to the zip file and the path to the thumbnail shipped with the LMV file