Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to create and add a marker to a timeline clip? #19

Open
communque opened this issue Jul 28, 2023 · 4 comments
Open

Is it possible to create and add a marker to a timeline clip? #19

communque opened this issue Jul 28, 2023 · 4 comments

Comments

@communque
Copy link

It looks like it should be possible to do if not obvious how to an experienced pythoner, based on this bit of code, but I'm relatively new to python.

@communque
Copy link
Author

UPDATE:

Looks like creating a marker is straightforward enough: myMarker = avb.misc.Marker( myMobRef )

which in turn requires the creation of a MobRef, myMobRef = avb.misc.MobRef()

But for now, how to properly configure that MobRef and then add it to a timeline clip remains a mystery.

@markreidvfx
Copy link
Owner

Have you looked at the dump_marker.py example?
Markers are stored on a _TMP_CRM attribute on a component in a sequence.
I think the CRM might stand for crumb, like a bread crumb, but I really have no idea why its called this.

The correct way to create any AVBObject in pyavb is to use the file object's create factory

with avb.open() as f:
    marker = f.create.Marker()

@communque
Copy link
Author

Thanks Mark

Have you looked at the dump_marker.py example?

I did, and it was very helpful in getting a sense of what the attributes and properties of a marker are. It looks like getting marker lists should be simple (not to mention faster than exporting from Avid)

f.create.Marker

So having created a marker, is there a proper way to fill in the comment, name, start, offset, etc. and attach it to timeline clip?

@communque
Copy link
Author

Playing with an idea like the one below.
It's not working but perhaps it communicates a bit.
Assuming a sequence in a bin at "BinPath, that has video track, with some clips in it, the following code seeks to add a green marker to each clip at 11 frames in. Tried various permutations and combinations, getting errors sometimes (hence the commented lines), but this is the basic idea:

with avb.open(BinPath) as f:
	for item in f.content.items:
		if item.user_placed and item.mob.name=="NameOfTargetSequence":
		for track in item.mob.tracks:
			if(hasattr(track.component, "components")):
				for component in track.component.components:
					attributes = component.attributes or {}
					if "attributes" in component.property_data:
						markers = attributes.get("_TMP_CRM",  [])
						NewMobRef = f.create.MobRef()
						# print("NewMobRef", NewMobRef)
						# NewMobRef.position = 0
						# NewMobRef.comp_offset = 11
						# NewMobRef.color = [13107, 52428, 13107]
						# NewMobRef.handled_codes = True
						# NewMobRef.attributes = avb.attributes()
						# NewMobRef.attributes._ATN_CRM_LONG_CREATE_DATE = 1690738361
						# NewMobRef.attributes._ATN_CRM_LONG_MOD_DATE = 1690738369
						# NewMobRef.attributes._ATN_CRM_DATE = u'07/30/2023'
						# NewMobRef.attributes._ATN_CRM_TIME = u'10:32'
						# NewMobRef.attributes._ATN_CRM_USER = u'myName'
						# NewMobRef.attributes._ATN_CRM_COLOR = u'Green'
						# NewMobRef.attributes._ATN_CRM_COM = u'MyComment'
						NewMarker = f.create.Marker(NewMobRef)
						markers.append(NewMarker)
	f.write(BinPath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants