markreidvfx / pyavb

Read and write Avid Bin FIles (AVB) files
https://pyavb.readthedocs.io
MIT License
58 stars 4 forks source link

Getting Clips Source timecode and tape name from track. #6

Closed rasmuslinden closed 4 years ago

rasmuslinden commented 4 years ago

Hi Mark.

First of all thanks for a great module, currently, I am using it for adding markers to clips. I can get the sequence, and the existing markers (TimeCrumbList) with no issue, add a marker and successfully save the file.

However, I'm having quite a hard time getting to the source clip object, holding timecode and tape name data. When I loop over the track components on the grouped clip holding the tracks ( avb.trackgroups.Composition NewTCGroup CompositionMob ), I get tracks, but they all start on 0, and does not seem to relate to the actual source clip I am trying to get to. Looping over the entire content does show the clip is there.

Could you point me in the right direction on how to get to the timecode and tape data, when I have a track object?

And thanks again.

Ras

I have attached a zip file containing an avb and a test python script. Archive.zip

russellaugust commented 3 years ago

@rasmuslinden did you ever find an answer to this? I'm currently digging deep into the avb to try and understand how Group Clips (called Selectors in pyavb) are synced. Im running into a similar issue finding timecode and accurate start times.

Anything you've found would be extremely helpful.

rasmuslinden commented 3 years ago

Hi Russel Yes I actually was able to figure it out eventually.

When you have a grouped clip, you will have a selector pr. track, and from that selector you can get to the source clips mobid.

When you know the mobid, you can then get the object with that mobid, and read the data from there. Quite cumbersome, I do not know why the mob object is not directly accessible from the grouped clip that holds the selector.

For the project I am using pyavb fore, I actually have everything working, reading, and setting locaters on clips.

BUT !!!

Writing avb files are very hit and miss, and I have been unable to find any pattern in when it works and when it does not. I have done tests both with my own code, and with the test copy code generously provided in the examples that Mark Reid has provided.

Even when I read a avb, and re-write it using test_write.py found in the /tests folder, I often end up with avid refusing to open the generated file, and reporting 'domain copy out failed'.

If you want, I'm happy to exchange code with you :)

Let me know!

Ras

russellaugust commented 3 years ago

Thanks @rasmuslinden I'd love to exchange code! I'm feel like I'm just scratching the surface of this. Avid's interaction with automation has always felt like a black box and this python library is the first time I've actually seen the possibility of really streamlining a workflow with automation. I'm really excited to use it.

I'd love to hear more about what you've been able to do. I think the shoot-for-the-stars goal would be to find a way to autosync and group clip a set of masterclips and audio files by timecode. If that's achievable then everything else I'd like to do is likely achievable too.

russellaugust commented 3 years ago

@rasmuslinden I'd love to trade code. should we do that here or someplace else? email?

cbenhagen commented 3 years ago

@russellaugust & @rasmuslinden I am also starting to work with this library again and it would be great if we all could contribute any higher level functionality back to this repository. This can be in the form of example scripts or additions to the library itself.

russellaugust commented 3 years ago

I'll be sure to include anything I end up writing.

mjiggidy commented 2 years ago

Even when I read a avb, and re-write it using test_write.py found in the /tests folder, I often end up with avid refusing to open the generated file, and reporting 'domain copy out failed'.

@rasmuslinden Have you found a solution to this problem yet? I'm in the same boat.

communque commented 1 year ago

On the question of getting source clip timecode, looking over a dump.py output reveals quite the labyrinth of logic.

Working with a bin containing a sequence composed on 1 picture track only with 2 edits in it -- two video clips. Call them Clip A & Clip B.

Clip A is a file that was drag-and-dropped into Avid directly from MacOS Finder. Clip B originated from a dailies house and was generated by drag-and-dropping an Avid media database (msmMMOB.mdb) into the project.

Iterating through the dump.py output: Clip A has a mob id pointing to a bin item, a "MasterMob" which can tell you the source start frame (not timecode, just the start frame counting from 0). This info under BinItem.mob.attributes._IN. In this case "5" To get the source time code involved a number of additional drilldown steps Step 1: Under BinItem.mob.tracks[0].component.mob_id use the mob id to get that bin item, call it "BinItem2". It too has no source TC, so... Step 2: Under BinItem2.mob.tracks[0].component.mob_id get that bin item, "BinItem3", also a SourceMob, and there you find source TC as follows... Step 3: From BinItem3.mob.tracks, iterate through that array until you reach a track with time code, "TrackN" Step 4: Then get TrackN.start where you get the clip's Source TC start represented in frames. Add that to your offset above to get your Source TC in point for the timeline clip.

For Clip B, the dailies house (i.e. ALE-generated) master clip, the story is different.

Clip B, using a similar approach, leads you to its BinItem3 which has multiple timecodes, presumably for picture and sound and whatever might have been generated in production. There doesn't seem to be an immediate way to distinguish which TC track refers to what, and all the start TC frames are different, so... ugh. It turns out, however, because Clip B was generated by an ALE file, you can avoid the drill-down actually take it back a few steps. Step 1: Under BinItem.mob.attributes._IN you get the source start frame offset from 0 (again, not the Source TC) Step 2: Under BinItem.mob.attributes._USER you get access to the bin columns data, where BinItem.mob.attributes._USER.Startframenumber\u0007 gives you the clip's start frame count which you can convert to TC. This bin column data does not seem to be available to Clip A, even though over in Avid you can see the Start TC.

This is hardly a rock-solid systematic way to reliably get source TCs from an edited sequence, but it's revealing. I was curious if anyone else has insights.