markreidvfx / pyaaf2

Read and write Advanced Authoring Format (AAF) files
http://pyaaf.readthedocs.io
MIT License
133 stars 36 forks source link

About AMA linking #10

Open hasielhassan opened 6 years ago

hasielhassan commented 6 years ago

Hi

I'm struggling a little with the ama linking and AVID, specially because I'm dealing with an old version (6.5.4)

I'm trying to replicate the structure that AVID used when it export its own AAF files, where if the media was linked as "ama" an import of that file properly relink the media again. But all my attempts end with offline media on Avid.

I indeed see some differences between the file from avid and the one that I'm getting from pyaaf2:

Right now I'm using the create_ama_link method to create the whole thing, but Im thinking that I will need to do it manually...

aaf_file = aaf2.open(output_aaf, "w")
source_path = "s01-ep02.scd020_030_editorial_v001.mov"

meta = probe(source_path)
# Note that I modified create_ama_link to use the MediaStreamPluginGUID 
master_mob, src_mob, tape_mob = aaf_file.content.create_ama_link(source_path, meta)

master_mob.comments.append(aaf_file.create.TaggedValue("_IMPORTED_AMA", 1))
master_mob.comments.append(aaf_file.create.TaggedValue("_AMA_METADATA_COUNT", 0))
master_mob.comments.append(aaf_file.create.TaggedValue("Video File Format", "MOV"))
master_mob.comments.append(aaf_file.create.TaggedValue("Video", "Photo - JPEG"))
master_mob.comments.append(aaf_file.create.TaggedValue("Audio Format", "LPCM"))
master_mob.comments.append(aaf_file.create.TaggedValue("Field Ordering", "Default"))

src_mob.comments.append(aaf_file.create.TaggedValue("_VERSION", 2))
src_mob.comments.append(aaf_file.create.TaggedValue("_AMA_FILE_DATE_TIME", 1483575123))

tape_mob.comments.append(aaf_file.create.TaggedValue("_VERSION", 2))

aaf_file.save()
aaf_file.close()

Here you can find some diagrams:

From PyAAF2 pyaaf2

From Avid avid

And both AAF files attached as zip aafs.zip

Hopefully you have a better idea of how to aproach this. Thansk in advaned!

markreidvfx commented 6 years ago

Haven't taken a look at this yet but a quick gotcha with ama linking is after you import the aaf into avid you might need to close and reopen the bin.

hasielhassan commented 6 years ago

Thats definitelly something i need to try xD But its curious that that is not requiered for Avid aaf files.

I will try it and let you know.

hasielhassan commented 6 years ago

After saving, closing and opening the bin, is still the same. I even restarted Avid with the same result.

And just for reference, on which Avid versions you are sure that the ama links from the pyaaf2 methods are working properly? I might give a try to update xD

hasielhassan commented 6 years ago

Its also not working for 8.5.3

markreidvfx commented 6 years ago

Sorry, don't have access to my dev computer at the moment, but I've been using the lastest version 2018.1 I think. Do the aaf generated by the test_ama.py work for you?

hasielhassan commented 6 years ago

Same thing, but I'm not sure if affects when that path point to the network drive: file://Y:\eng\hasielhassan\Development\aaftests\sandbox\tests\results\samples\ama_prores_proxy.mov

From my tests with the aaf exported from Avid, seems that they store the unc path instead, but even trying to replicate that was not succesful.

markreidvfx commented 6 years ago

Looks suspect, perhaps it's windows, I've done most of my dev work on Linux/Mac. I've seen MC do all different types of paths in the network locator. I see your original has a space in the file path too, some times is see that coverted to %20 like a web url. My advice is to try hard code it what avid does a see if that works.

hasielhassan commented 6 years ago

Checking the release notes from 8.5 to 8.10 (and 2018.1), I don't see anything related to aaf, but I understand that on 8.6 they implemented the "Source Browser", not sure if that changed the way they stored/read the values in the aaf files.

I also have a osx to work with, thats why I pushed the unc path in the first place, but event in osx with unc paths is not working (and a web browser is properly reading the files from those paths).

Can I know why you replaced the "MediaStreamPluginGUID" with the "MediaContainerGUID"?

I will verify the paths again, just to be sure....

Thanks for your help!!

markreidvfx commented 6 years ago

Any luck? I changed the name because it got changed in newer versions of MC. It shouldn't matter as the uuids are the same, I've been meaning to implement aliases for property names jus haven't gotten to it yet.

hasielhassan commented 6 years ago

I'm still having the same issues, and seems that the url paths in the Locators are the same for both aaf files (from avid and from pyaaf2): file://qnod/corp\projects/eng/Development/aaftests/sandbox/s01-ep02.scd020_030_editorial_v001.mov

I was curious of the baskslash path separator between "corp" and "projects" instead of slash, and tried using the slash separator but it was the same, and that exact path string is in the aaf from avid.

About the the media guid names, in my case the uuids are also different that those on pyaaf2 code: MediaStreamPluginGUID (in avid aaf): 781f84b7-b989-4534-8a07c595cb9a6fb8 MediaContainerGUID (in pyaaf2): b22697a2-3442-44e8-bb8f7a1cd290ebf1

But as i mention, i even tried replacing the values in pyaaf2 without luck.

One thing that i still need to try is to replicate the whole structure, but i'm still not sure how to define a Tagged value for another Tagged value, like the "__AttributeList" one in the aaf from avid. And maybe i also need to verify both dictionaries?

I leaving this for now, (i already spend more than a week trying to get them working xD) and i'm using embedded media instead for now, maybe we can try the latest version of MC after NAB and see if it works there.

markreidvfx commented 6 years ago

Can you share the aaf with the different UUID? I think we might be confusing the UUID of the property with the property value. The UUID in the model is the uuid of the property. It's value is set here https://github.com/markreidvfx/pyaaf2/blob/master/aaf2/ama.py#L275

That UUID you show is the QuickTime one https://github.com/markreidvfx/pyaaf2/blob/master/aaf2/ama.py#L31

The one pyaaf2 is setting looks like the generic, and I don't think it exists in those versions on MC

hasielhassan commented 6 years ago

Both files (from MC and from PyAAF) are in the original post: https://github.com/markreidvfx/pyaaf2/files/1878389/aafs.zip

I understand that in those files, the one from PyAAF is the one with the values that I modified, so here is one using the default PyAAF: pyaaf2.zip

Here is also the metadata from ffprobe: meta.zip

And a diagram of the aaf file structure: pyaaf2

Checking at the code you pointed, I now realize that the uuid is just indicating the media type right? I first thought that it was kind of an instruction to mark that as an AMA link :/

So yes, it seems that is taking the generic one because the codec_name is not 'prores', but apparently MC is taking it as QuickTime, maybe because of the Container (format_long_name, format_name)? QuickTime / MOV I did a test, just changing the get_container_guid function, based on the format_long_name instead of the codec_name, the resulted aaf file now get the proper uuid but is still as offline in MC.

Not sure if the name string of that uuid (MediaContainerGUID vs MediaStreamPluginGUID ) can affect the behavior in MC.

XDeschuyteneer commented 8 months ago

@markreidvfx I confirm the issue is still present on latest version. I tried to ama link MOV files from SHOGUN and it doesn't work. (while AMA link MXF works fine)

So I went back to your example "amalink.py": python3 ./amalink.py $(realpath ../tests/results/samples)/*.mov Then dropped the ama_link_external_mxf.aaf in AVID.

After a quick check: it's missing the start TC which could cause some issue in the relink maybe? Will investigate and compare with a working AAF/AMA link.

Using avid 2022.10.0.56239.0 on mac os sonoma 14.2.1

hdelgadin commented 1 month ago

Hi, i'm trying to use amalink.py to create an AAF file with a link to an MXF OP-Atom growing file (while it is being captured), but I encounter an error, which I believe is related to the length calculation.

The question is: can i create an AAF file from a MXF Growing File/s (Audio and Video) to import that "media" to AVID?

Thanks in advance.