markreidvfx / pyaaf

Python Bindings for the Advanced Authoring Format (AAF)
http://markreidvfx.github.io/pyaaf
MIT License
49 stars 9 forks source link

Descriptive Marker #13

Open Toadman30 opened 9 years ago

Toadman30 commented 9 years ago

Is there a way to make a descriptive marker?

markreidvfx commented 9 years ago

just added support in 4d6eac14945d0e9423202def2165b8d328871d06

import aaf
f = aaf.open()
marker = f.create.DescriptiveMarker()
Toadman30 commented 9 years ago

Thank You!

On Apr 25, 2015, at 5:36 PM, Mark Reid notifications@github.com wrote:

just added support in 4d6eac1

import aaf f = aaf.open() marker = f.create.DescriptiveMarker() — Reply to this email directly or view it on GitHub.

Toadman30 commented 9 years ago

I'm getting the same error as the Selector when trying to append a marker to a sequence.

        # Marker
        marker = f.create.DescriptiveMarker()
        marker.media_kind = "picture"
        sequence1.append(marker)

Is there a way to add a comment to the marker?

markreidvfx commented 9 years ago

the media_kind of the marker should be "DescriptiveMetadata" try:

sequence = f.create.Sequence("DescriptiveMetadata")
marker =  f.create.DescriptiveMarker()
marker.media_kind = "DescriptiveMetadata"
sequence.append(marker)
Toadman30 commented 9 years ago

Thanks that worked. Now can you add a comment, color or position?

markreidvfx commented 9 years ago

to set a comment

d = f.create.DescriptiveMarker()
#print all the property available
print d.all_keys()
[u'Description', u'DescribedSlots', u'Annotation', u'Position', u'Comment', u'DataDefinition', u'Length', u'UserComments', u'KLVData', u'Attributes', u'Generation', u'ObjClass']
d['Comment'].value = "Some comment"

The position I think is determined by they Length, but I'm not entirely sure, I'd recommend taking a look at a aaf with markers exported from avid. You can use the aaf2xml.py to convert it to something readable.

ertee commented 8 years ago

This is great, managed to get DescriptiveMarkers applied but wondered if you would be able to provide any insight as to how to get the other properties that Avid is looking for set through pyaaf. This is a dump of a marker from an Avid exported AAF:

[DescriptiveMarker ] DataDefinition: Descriptive Metadata UserComments: Strong Object Reference Array [2] of TaggedValue kAAFTypeID_TaggedValueStrongReferenceVector 0: [ TaggedValue ] Name: "Comment" Value: (indirect type: aafString) "This is the first marker text" kAAFTypeID_TaggedValueStrongReferenceVector [1]: [ TaggedValue ] Name: "DatabaseID" Value: (indirect type: aafString) "060a2b340101010101010f0013-000000-5766066e2cd404e5-060e2b347f7f-2a80" Position: 18580 Comment: "This is the first marker text" DescribedSlots: Set[1] of aafUInt32

    CommentMarkerAttributeList: Strong Object Reference Array [8] of TaggedValue
       kAAFTypeID_TaggedValueStrongReferenceVector [0]: 
         [ TaggedValue ]
         Name: "_ATN_CRM_LONG_CREATE_DATE"
         Value: (indirect type: aafInt32) 1466304031
      kAAFTypeID_TaggedValueStrongReferenceVector [1]: 
         [ TaggedValue ]
         Name: "_ATN_CRM_USER"
         Value: (indirect type: aafString) "USERNAME"
      kAAFTypeID_TaggedValueStrongReferenceVector [2]: 
         [ TaggedValue ]
         Name: "_ATN_CRM_DATE"
         Value: (indirect type: aafString) "06/18/2016"
      kAAFTypeID_TaggedValueStrongReferenceVector [3]: 
        [ TaggedValue ]
         Name: "_ATN_CRM_TIME"
         Value: (indirect type: aafString) "22:40"
     kAAFTypeID_TaggedValueStrongReferenceVector [4]: 
       [ TaggedValue ]
       Name: "_ATN_CRM_COLOR"
       Value: (indirect type: aafString) "Red"
      kAAFTypeID_TaggedValueStrongReferenceVector [5]: 
         [ TaggedValue ]
         Name: "_ATN_CRM_COM"
         Value: (indirect type: aafString) "This is the first marker text"
      kAAFTypeID_TaggedValueStrongReferenceVector [6]: 
          [ TaggedValue ]
         Name: "_ATN_CRM_LONG_MOD_DATE"
         Value: (indirect type: aafInt32) 1466304042
      kAAFTypeID_TaggedValueStrongReferenceVector [7]: 
         [ TaggedValue ]
         Name: "_ATN_CRM_ID"
         Value: (indirect type: aafString) "060a2b340101010101010f0013-000000-5766066e2cd404e5-060e2b347f7f-2a80"
    CommentMarkerTime: "22:40"
    CommentMarkerDate: "06/18/2016"
    CommentMarkerUSer: "USERNAME"
    CommentMarkerColor: { 41471, 12134, 6564 }

As you can see, there are several additional properties other than the ones exposed by pyaaf:

CommentMarkerTime,Date,User,Color, etc. as well as CommentMarkerAttributeList, which is an array of TaggedValues. How can we create the array of TaggedValues to provide Avid Marker compatibility? Has Avid extended the AAF SDK in order to add these additional properties?

markreidvfx commented 8 years ago

Avid adds a lot of extensions. There are a couple of tests that show how to register new properties. It really annoying to do and unfortunately I haven't had time to implement all types. A work around is export a empty aaf from avid and use that as your base file.

Liametc commented 8 years ago

Hey there, I am trying to register a new string property to a DescriptiveMarker, so I can set the "User" attribute. I think I am going about it the correct way, but it doesn't look like string types are supported. Here's my snippet of code, (it never gets to the last line, but included it anyway). I've been through the examples in test_TypeDefVariableArray.py, and am aware of the workaround you mentioned above.

Can you explain it in some more detail please?

Thanks

import aaf
f = aaf.open('test.aaf', 'w')
marker = f.create.DescriptiveMarker()
type_id =  aaf.util.AUID.from_list([0xda60bb00, 0xba41, 0x11d4, 0xa8, 0x12, 0x8e, 0x54, 0x1b, 0x97, 0x2e, 0xa3 ])
typedef = f.dictionary.lookup_typedef("string")
strongref_typedef = aaf.define.TypeDefString(f, typedef, type_id, "TaggedValueStrongReference type")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "aaf/base.pyx", line 19, in aaf.base.AAFBase.__init__ (aaf/base.cpp:2762)
TypeError: TypeDefString cannot be instantiated from Python
propery_def = component_classdef.register_optional_propertydef(strongref_typedef, marker.class_auid, "User")
markreidvfx commented 8 years ago

yup I see what you mean. I just add a init to TypeDefString in the dev branch. see test_TypeDefString for a example.

markreidvfx commented 8 years ago

I still don't think thats what your looking for let me take a deeper look

markreidvfx commented 8 years ago

I added test_CommentMaker in the dev branch, in it shows a example of how to add most of those properties

Liametc commented 8 years ago

Thanks Mark, I'll give it a try, it looks like exactly what I need :)

Liametc commented 8 years ago

Works great, thanks!

Just one question, are the uuids you are using totally random or is there a reason behind them? AUID("urn:uuid:c4c45d9a-0967-11d4-a08a-006094eb75cb") for most of the attrs, AUID("urn:uuid:c72cc817-aac5-499b-af34-bc47fec1eaa8") for the attr list id and "060a2b340101010101010f0013-000000-5766066e2cd404e5-060e2b347f7f-2a80" for the crm id?

Thanks

markreidvfx commented 8 years ago

They should be the correct ones unless I made a mistake. There are couple ways to get them. I converted a avid exported aaf to XML via aaf2xml.py and got the ids from the extension section.

Liametc commented 8 years ago

Nice one. Guessing the crm id/database id is unique each time? Just don't want to screw up a project by using incorrect data.

markreidvfx commented 8 years ago

I don't know, you'll have to check a couple files to make sure. I don't know what the crm id/database id tags are used for.

Liametc commented 8 years ago

no worries. Thanks for the help though, really means a lot