Share

Python Improvements (What's New in 2022)

Flame Family products now use Python 3.7, you can now encode exports with FFmpeg, access the new Python console. Plus Python API updates.

Indicates a feature suggested and voted up by users on the Flame Feedback portal.

Moving to Python 3.7

Flame, Flare and Flame Assist now use Python 3.7. This means that you need to convert your Python scripts to Python 3.

The process for converting your scripts to from Python 2 to Python 3 is outside the scope of this documentation. But here a few pointers for doing just that.

  • Read the Python Software Foundation Porting Python 2 Code to Python 3 documentation. Get familiar with the process of porting your scripts to Python 3, and with Python 3 differences from Python 2.
  • Update your scripts to Python 3 using Futurize or Modernize.

Futurize and Modernize cannot fix everything automatically: you still need to verify your script compiles correctly.

To test to see if your script compiles and will run in Python 3:

  1. From the command line, run:

    python3 -m compileall <your_script>
  2. In the shell, look at the compilation feedback:

    • If there are no compilation errors, chances are your script is fine. Try running it in Flame.
    • If the compiler complains, you'll need to go in and fix your script.

Python Console Update

The Python console, Flame menu Python Python Console, now benefits from the following improvements:

  • Modify the indentation of multiple lines: select the lines and then press Tab (increase indent) or Shift-Tab (decrease indent).
  • You can now comment and uncomment multiple lines with Control+/ (CentOS) or Command+/ on (macOS).
  • New lines start at the same indentation level as the previous one.
  • New lines after a : character start with a 4-space indentation.
  • Indentation made with Tab are converted to spaces.
  • Saved scripts now default to the .py extension.
  • The new colour scheme improves legibility.

FFmpeg Media Encoding with Python API

This release includes new Python API script examples showing how to encode Flame Family content using FFmpeg on CentOS and macOS

Important: You must install FFmpeg on your workstation if you want to run the example scripts. For more information, see the FFmpeg site.

The Python example file is located in /opt/Autodesk/flame_2022/python_examples/export_selection.py.

export_selection.py contains examples to:

  • Export selection using FFmpeg, in foreground: Encodes selected content as QuickTime (1920x1080, RLE video codec and IMA audio codec) to /var/tmp/export.
  • Export selection using FFmpeg, in background: Encodes selected content as QuickTime (1920x1080, RLE video codec and IMA audio codec) to /var/tmp/export, but as a Backburner managed job.

The Python API encoding also uses some of the Wiretap tools already installed in /opt/Autodesk/io/bin. The Wiretap tools used are:

  • read_audio
  • read_frame with the following metadata:
    • Reel Name
    • Timecode
    • Frame rate
    • Colour Space, with one of the following colours spaces for parameter:
      • Rec.601 video
      • Rec.601 video (PAL)
      • Rec.709 video
      • Rec.2020 video
      • DCDM X'Y'Z' (DCI white)
      • DCDM X'Y'Z' (D60 white)
      • DCDM X'Y'Z' (D65 white)
      • DCI-P3 (DCI white)
      • DCI-P3 (D60 white)
      • DCI-P3 (D65 white)
      • sRGB display
      • ST-2084 (PQ), Rec.709 primaries
      • ST-2084 (PQ), Rec.2020 primaries
      • ST-2084 (PQ), DCI-P3 (DCI white)
      • ST-2084 (PQ), DCI-P3 (D65 white)
      • Rec.2100 HLG (Lw=1000 nits, Lb=0)

Since Timeline FX have to be rendered prior exporting with Python API, we have added in the example a way to pre-render content before exporting. If you create your own Python script, make sure to pre-render any Timeline FX to avoid black frames in your resulting files. Also, Audio mix down might be required if your content has more than two audio tracks.

The above script also shows how to export clips located in a Reel or a Folder, and displays a file browser to select a destination.

Python API limitations:

  • Content must first be imported (or generated) in Flame Family products to be exported through Python API and Wiretap Tools. You cannot transcode directly from MediaHub.
  • You cannot export an alpha channel.
  • Wiretap tools are paused to avoid interfering with foreground operations like playback.

Python API Updates

Expanded PyActionNode Reach

Every functions, attributes and properties available in the PyActionNode object are now available in GMask Tracer and Image.

New Sample Script

The script path_of_selected_clips.py shows how to get the path and file name of a media file in MediaHub.

Support for //

The // operator is now supported in the Python API. Python 3 does the distinction between / (float division) and // (integer division).

New in Action

CommandTypeDescription
<PyActionNode>.object_dual_modeattribute

Set the Object menu display mode to Single or Dual.

One of the following must be passed as an argument:

  • True
  • False

Set the Object menu to Dual display mode.

<PyActionNode>.object_dual_mode = True
<PyActionNode>.left_tabs

<PyActionNode>.right_tabs

<PyActionNode>.all_tabs

read-only property

Get a list of tabs currently displayed in the Object menu.

  • left_tabs and right_tabs must be used in the Dual display mode.
  • all_tabs must be used in the Single display mode.

Get the list of tabs currently displayed in the Left panel of the Object menu set in Dual mode.

print <PyActionNode>.left_tabs
<PyActionNode>.current_left_tab

<PyActionNode>.current_right_tab

<PyActionNode>.current_tab

attribute

Set a tab as current in the Object menu.

  • current_left_tab and current_right_tab must be used in the Dual display mode.
  • current_tab must be used in the Single display mode.
  • The name of a tab must be passed as an argument.

Select the Default Camera tab in the Object menu's single panel mode

<PyActionNode>.current_tab = "Default"

New in Action/Image/Gmask Tracer

CommandTypeDescription
flame.duplicate(<PyObject>)functionThe standard flame.duplicate() function can now be used to duplicate an object inside a PyActionNode, PyImageNode, and PyGMaskTracerNode.

New in Media Panel

CommandTypeDescription
<PyDesktop>.children

<PyReelGroup>.children

<PyReel>.children

<PyLibrary>.children

<PyFolder>.children

read-only propertyGet a list of children <PyObjects> located under the specified <PyObject> in the Media Panel Hierarchy.

Get a list of children located under the Desktop:

 print flame.projects.current_project.current_workspace.desktop.children
<PyMediaPanel>.copy()

<PyMediaPanel>.move()

function

The Duplicate Name Check dialog is now bypassed when the copy and move functions are used.

The duplicate_action argument can be set to either add or replace to dictate the desired behaviour.

The Add option will be executed if the argument is not set.

Replace a clip while moving another clip with the same name to that Reel

clip = flame.projects.current_project.current_workspace.desktop.reel_groups[0].reels[3].clips[0]
reel = flame.projects.current_project.current_workspace.desktop.reel_groups[0].reels[2]

flame.media_panel.move(source_entries = clip, destination = reel, duplicate_action = 'replace')

<PyReel>.typeread-only property

Used to get a Reel's type. The possible type are:

  • Reel

  • Schematic

  • Sequences

  • Shelf

Print a Reel's type

 print(<PyReel>.type)

New in Timeline

CommandTypeDescription
<PySegment>.create_connection()function

Used to create a connected segment connection on a segment.

Only works for segments inside a Reel Group.

<PySegment>.remove_connection()function

Used to remove a connected segment connection on a segment.

Only works for segments inside a Reel Group.

<PySegment>.sync_connected_segments()function

Used to sync the connected segments.

Only works for segments inside the same Reel Group.

<PySegment>.connected_segments()function

Returns a list of connected segments.

Only works for segments inside the same Reel Group.

<PySegment>.duplicate_source()functionUsed to duplicate the source media of a segment.
<PySegment>.shared_source_segments()functionReturns a list of segments sharing the same source media.

New in Timeline FX

CommandTypeDescription
<PyTimelineFx>.sync_connected_segments()function

Used to sync a specific Timeline FX on connected segments inside the same Reel Group.

This cannot be called on a Timewarp.

Was this information helpful?