Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import xml.etree.ElementTree as ET
- xml_path = os.path.normpath("/path/timeline_300x200.xml")
- tree = ET.parse(xml_path)
- root = tree.getroot()
- sequence_width = int(root.findtext(".//media/video/format/samplecharacteristics/width"))
- sequence_height = int(root.findtext(".//media/video/format/samplecharacteristics/height"))
- for clip in root.iter('clipitem'):
- clip_pathurl = clip.find('file').findtext('pathurl')
- clip_source_frame_in = clip.findtext('in')
- clip_source_frame_out = clip.findtext('out')
- clip_rec_frame_in = clip.findtext('start')
- clip_rec_frame_out = clip.findtext('end')
- clip_source_width = int(clip.find('file').find('media').find('video').find('samplecharacteristics').findtext('width'))
- clip_source_height = int(clip.find('file').find('media').find('video').find('samplecharacteristics').findtext('height'))
- clip_scale = float(clip.findtext(".//parameter[name='Scale']/value")) / 100
- clip_rec_width = clip_source_width * clip_scale
- clip_rec_height = clip_source_height * clip_scale
- # Anchor Point
- clip_x_anchor_horiz_relative = float(clip.findtext(".//parameter[name='Anchor Point']/value/horiz"))
- clip_y_anchor_vert_relative = float(clip.findtext(".//parameter[name='Anchor Point']/value/vert"))
- clip_x_anchor_horiz_absolute = clip_x_anchor_horiz_relative * clip_source_width
- clip_y_anchor_vert_absolute = clip_y_anchor_vert_relative * clip_source_height
- # Anchor Point shown in Premiere Pro GUI
- clip_x_anchor_horiz_absolute_from_left = clip_x_anchor_horiz_absolute + (clip_source_width / 2)
- clip_y_anchor_vert_absolute_from_left = clip_y_anchor_vert_absolute + (clip_source_height / 2)
- # Center
- clip_x_center_horiz_relative = float(clip.findtext(".//parameter[name='Center']/value/horiz"))
- clip_y_center_vert_relative = float(clip.findtext(".//parameter[name='Center']/value/vert"))
- clip_x_center_horiz_absolute_source = clip_x_center_horiz_relative * clip_source_width
- clip_y_center_vert_absolute_source = clip_y_center_vert_relative * clip_source_height
- # Center shown in Premiere Pro GUI
- clip_x_center_from_seq_left = (sequence_width / 2) + clip_x_center_horiz_absolute_source + clip_x_anchor_horiz_absolute
- clip_y_center_from_seq_top = (sequence_height / 2) + clip_y_center_vert_absolute_source + clip_y_anchor_vert_absolute
- break
Add Comment
Please, Sign In to add comment