Get pixel aspect ratio from segment in python

Hi All,

I’m working on some tools and I don’t seem to be able to get access to the ‘pixel aspect ratio’ attribute of the segments/clips from the timeline. Is this data available through the python api? Closest I can find is the PyMediaHubFilesTabOptions.pixel_ratio but I think that’s just a setting for how media is imported rather than an actual per-clip attribute. Any ideas or workarounds would be greatly appreciated!

You may have problem finding it because the source ratio is not an attribute, but a property. The difference is that an attribute can be set/modified and an attribute can’t.

  1. Select the segment in the Timeline
  2. Open the Python Console
  3. Type and execute

import flame
help(flame.timeline.current_segment)

This will get you all the functions and properties for the PySegment

  1. Type and execute

print(flame.timeline.current_segment.source_ratio)

This will return the aspect ratio for the selected segment.

When looking for something, it is always a good idea to look at the attributes via the print function and at the function/properties via the help function

1 Like

I was using that previously, but that seems to be the aspect ratio though, not pixel aspect ratio

to clarify, i might have an image which is 1920x1080, and so source_ratio comes up as 1.777, but the pixel aspect refers to if the image should be interpreted as square pixels (1.0) or anamorphic (e.g. 1.3). Usually this appears in the image metadata as PixelAspectRatio

Hmm did a little more testing, source_ratio seems to be width / height * pixel aspect, so I can do a bit of maths and work out the PAR. Would be good if the docs were a bit more clear on this!

1 Like