Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

What:

From current sequence containing ARI files, will output each sequences of ari to a file per shot, to be used with Ari ARC_CMD. The script also builds the batch file.

#################################
# File name: hiero_to_ARC #
# Author: Mel Massadian #
# Submission: 05/11/17 #
#################################
from hiero.core import *
import os.path
import re
from itertools import chain
# gather current infos
thisProject = projects()[-1]
view = hiero.ui.activeView()
sequence = seq = hiero.ui.activeSequence()
tracks = sequence.items()
all_shots = []
output_path = "/Volumes/LaCie/ACES_Conversions/"
for t in tracks:
if isinstance(t,VideoTrack):
for trackItem in t.items():
clip = trackItem.source()
path = clip.mediaSource().firstpath()
shot = []
shot_base = path.replace(path.split(".")[-2],"*")
inp, outp = int(clip.sourceIn()) + int(trackItem.sourceIn()), int(clip.sourceIn()) + int(trackItem.sourceOut())+1
shot.append(inp)
for s in range(inp,outp+1):
shot.append(shot_base.replace("*",'{:07d}'.format(s)))
# ignore if non .ari shot
if shot[1].endswith("ari"):
all_shots.append(shot)
for i,sh in enumerate(all_shots):
sh_file = os.path.join(output_path, "shots/shot_{:02d}.txt".format(i))
with open(sh_file,"w") as f:
f.write("\n".join(sh[1:])) # minus the first element (which stores the in point)
with open(os.path.join("convert.sh"),"a+") as co:
cmd = "ARC_CMD -f {} --output.startnumber {} -c mel.xml\n".format(sh_file,sh[0])
co.write(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment