finding embedded mattes in exrs

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline
User avatar

waltervolpatto

  • Posts: 7548
  • Joined: Thu Feb 07, 2013 5:07 pm
  • Location: 1146 North Las Palmas Ave. Hollywood, California 90038 USA

finding embedded mattes in exrs

PostSat Jan 18, 2020 7:50 pm

We are working on a huge project that has literally 2000 VFX shots. For some effect we will have multiple versions deliveries.

all VFX are delivered as EXR (zip compressed) and the colorist assist need to find which shots have embedded mattes and which does not have it and flag the shot for the colorist and report back to the editorial staff.

I cannot find any elegant way to do that short or load all the shots in a timeline, go to color page, right click add matte and see if another layer/channel exist.

While this works, it is really tedious and long. prone to errors.

so, i have a two fold questions:
1) I cannot see anywhere in the media page a column for embedded mattes/extra layers, it could be nice if there is one. that shows if a shot has alpha or extra layers and I can flagg it. either I missed entirely or it is simply not there.
2) I still need to solve the problem now, and i was wondering if there is way to python script it something that does two things:
A) find shots within a folder that have extra layer/channels
B) add a flag with color X to that shot.

Any ideas?

Walter.
SuperServer 5039AD-I
C9X299-PGF - DDR4-2400 16x4 GB
i9-7920xCPU 12c 2.90GHz Water cooled
2x 1080ti DeckLink Studio 4K (11.4)
W10-1903 - BMR St. 16.2.055
nvidia: 441.66 studio
Offline
User avatar

iddos-l

  • Posts: 288
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: finding embedded mattes in exrs

PostSat Jan 18, 2020 10:04 pm

I don’t know of a straight way to find embedded mattes data with the API.
When looking in the MediaPoolItem. GetClipProperty(), just like the clip attributes from the menu, there is no information of ext mattes.

But I was thinking, if the exr files with the mattes are bigger in size compare to the ones without, it is possible to catch them with a script.
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostSat Jan 18, 2020 11:44 pm

The current Resolve API can't find the extra channels in the EXR files, just like Iddo says. But, the Fusion API in Resolve can certainly do it. Not sure that's practical though, since you would need to put all the clips on a timeline and have the script create Fusion clips out of each one. Or use a single Fusion comp with a script that loads each EXR sequence from disk instead of from the Media Pool.

Instead I would probably use a command line utility like ffprobe or exiftool to find the clips with the extra channels outside of Resolve and output the filenames to a text file. Then use the text file as an input to a script in Resolve that adds the flag to each clip. No timeline or Fusion clips required.
Offline
User avatar

waltervolpatto

  • Posts: 7548
  • Joined: Thu Feb 07, 2013 5:07 pm
  • Location: 1146 North Las Palmas Ave. Hollywood, California 90038 USA

Re: finding embedded mattes in exrs

PostSun Jan 19, 2020 12:11 am

iddos-l wrote:I don’t know of a straight way to find embedded mattes data with the API.
When looking in the MediaPoolItem. GetClipProperty(), just like the clip attributes from the menu, there is no information of ext mattes.

But I was thinking, if the exr files with the mattes are bigger in size compare to the ones without, it is possible to catch them with a script.


unfortunately those are compressed ZIP, all over the place in size, we thought about that....
SuperServer 5039AD-I
C9X299-PGF - DDR4-2400 16x4 GB
i9-7920xCPU 12c 2.90GHz Water cooled
2x 1080ti DeckLink Studio 4K (11.4)
W10-1903 - BMR St. 16.2.055
nvidia: 441.66 studio
Offline
User avatar

waltervolpatto

  • Posts: 7548
  • Joined: Thu Feb 07, 2013 5:07 pm
  • Location: 1146 North Las Palmas Ave. Hollywood, California 90038 USA

Re: finding embedded mattes in exrs

PostSun Jan 19, 2020 12:12 am

roger.magnusson wrote:The current Resolve API can't find the extra channels in the EXR files, just like Iddo says. But, the Fusion API in Resolve can certainly do it. Not sure that's practical though, since you would need to put all the clips on a timeline and have the script create Fusion clips out of each one. Or use a single Fusion comp with a script that loads each EXR sequence from disk instead of from the Media Pool.

Instead I would probably use a command line utility like ffprobe or exiftool to find the clips with the extra channels outside of Resolve and output the filenames to a text file. Then use the text file as an input to a script in Resolve that adds the flag to each clip. No timeline or Fusion clips required.


I see... Thanks!
SuperServer 5039AD-I
C9X299-PGF - DDR4-2400 16x4 GB
i9-7920xCPU 12c 2.90GHz Water cooled
2x 1080ti DeckLink Studio 4K (11.4)
W10-1903 - BMR St. 16.2.055
nvidia: 441.66 studio
Offline
User avatar

Igor Riđanović

  • Posts: 703
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: finding embedded mattes in exrs

PostSun Jan 19, 2020 8:22 am

Roger's method for flagging clips would work for sure. OpenEXR Python bindings can also read EXR headers. It's easier to use than Exiftool and more OS portable.

Instead of the end user generating a text file and feeding that to a script, it's possible to make a script that goes through all EXR files in a bin and flags any that have auxiliary channels. It becomes a single click operation.

I don't know if this is practical in your use case, but it's also possible to iterate timeline clips and build color page node trees with EXR auxiliary channel mattes already connected.
www.metafide.com - DaVinci Resolve™ Apps
Offline
User avatar

Igor Riđanović

  • Posts: 703
  • Joined: Thu Jul 02, 2015 5:11 am
  • Location: Los Angeles, Calif.

Re: finding embedded mattes in exrs

PostSun Jan 19, 2020 8:24 am

iddos-l wrote:But I was thinking, if the exr files with the mattes are bigger in size compare to the ones without, it is possible to catch them with a script.


This is highly unreliable because of compression. You can have a case where a file with more channels is smaller in size than a file with fewer channels.
www.metafide.com - DaVinci Resolve™ Apps
Offline

Oyvind Stiauren

  • Posts: 42
  • Joined: Mon Mar 06, 2017 11:31 pm
  • Location: Mexico City

Re: finding embedded mattes in exrs

PostSun Jan 19, 2020 9:59 am

waltervolpatto wrote:2) I still need to solve the problem now, and i was wondering if there is way to python script it something that does two things:
A) find shots within a folder that have extra layer/channels
B) add a flag with color X to that shot.


Hi Walter.

I have a python script that basically does that. Right now it's not putting a flag with a specific color on the clip, but rather it's putting a color to the clip. But it should not be very difficult to make it put flags in stead.

The script finds all the EXR clips in video track 1, scans the header of the file for alpha channel and color the clip Orange if they're a match. The script is very crude, and the header detection might not work on all EXR files without modifying the script. I've also only tested it on Linux CentOS.

If you're interested I can PM you the script.
--
Oyvind Stiauren, C.S.I.
Senior Colorist
Terminal, Mexico City
www.terminalmx.com
www.imdb.com/name/nm1008209/
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostWed Jan 22, 2020 11:19 pm

So, I took a deep dive into the OpenEXR specs and made a script in Resolve that can read the OpenEXR channels without any external applications or third party modules. I usually build scripts in Lua instead of Python which means the module Igor mentioned won't work. I have nothing against Python but I like the idea of Lua since it's built into Resolve and it doesn't require installation like Python does on Windows.

After I finally had the script working for OpenEXR v2 multipart files I discover that Resolve/Fusion actually has a scriptable module for this already built-in. :shock: It's called EXRIO, it's not documented except for a few calls in the External Matte Saver.fuse file that BMD includes with Fusion Studio. More info.

With the help of a hex editor and some spying in fusionoperators.dll you can find some of the available functions. Here's a simple Lua script that prints all the parts and channels in an OpenEXR file using EXRIO.
Code: Select all
local exr = EXRIO()
exr:ReadOpen("/Users/rogmag/Downloads/multipart.0001.exr", -1) -- filename, frame

assert(exr:ReadHeader())

for part = 1, exr.NumParts do
   if (exr.NumParts > 1) then
      print("Part: "..select(2, exr:GetAttribute(part, "name")))
   end
      
   for _, channel in ipairs(exr:GetChannels(part)) do
      print("   Channel: "..channel.Name)
   end
end

assert(exr:Close())

Image

Be aware that scripting EXRIO in Resolve is extremely volatile, if you make a mistake Resolve simply quits immediately. But it beats rolling your own like I first did. Oh well, at least I learned a lot about the file format.
Offline
User avatar

iddos-l

  • Posts: 288
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: finding embedded mattes in exrs

PostThu Jan 23, 2020 6:11 am

Great thanks for sharing
Offline
User avatar

waltervolpatto

  • Posts: 7548
  • Joined: Thu Feb 07, 2013 5:07 pm
  • Location: 1146 North Las Palmas Ave. Hollywood, California 90038 USA

Re: finding embedded mattes in exrs

PostFri Jan 24, 2020 7:36 am

Thanks!
SuperServer 5039AD-I
C9X299-PGF - DDR4-2400 16x4 GB
i9-7920xCPU 12c 2.90GHz Water cooled
2x 1080ti DeckLink Studio 4K (11.4)
W10-1903 - BMR St. 16.2.055
nvidia: 441.66 studio
Offline

Hendrik Proosa

  • Posts: 811
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: finding embedded mattes in exrs

PostFri Jan 24, 2020 11:25 am

Can you access bins, markers etc Resolve side stuff with Lua too? That would make Walters original request pretty easy then.
I do stuff.
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostFri Jan 24, 2020 11:35 am

Yes, all of it is possible now. I'm thinking about doing something with a nice GUI if I find the time.
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostSun Jan 26, 2020 1:53 pm

It's coming along nicely I think. It's an exercise in patience though... :lol:
Anything I should add? I'm thinking I want to keep the GUI simple and not add everything to it. I can see making some variations of it though, like adding the channel names as keywords in the clip metadata.

@BMD, will I get into trouble if I use your icons in the form (the flags)?

Image
Offline
User avatar

iddos-l

  • Posts: 288
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: finding embedded mattes in exrs

PostSun Jan 26, 2020 4:27 pm

roger.magnusson wrote:It's coming along nicely I think. It's an exercise in patience though... :lol:
Anything I should add? I'm thinking I want to keep the GUI simple and not add everything to it. I can see making some variations of it though, like adding the channel names as keywords in the clip metadata.

@BMD, will I get into trouble if I use your icons in the form (the flags)?

Image


Looks great
When it comes to GUI dev there’s never enough patience!
Offline
User avatar

waltervolpatto

  • Posts: 7548
  • Joined: Thu Feb 07, 2013 5:07 pm
  • Location: 1146 North Las Palmas Ave. Hollywood, California 90038 USA

Re: finding embedded mattes in exrs

PostSun Jan 26, 2020 8:59 pm

At the moment that looks extremely slick to me!

(i'm Italian, I can only do spaghetti code!)

Is it operative system dependent?
SuperServer 5039AD-I
C9X299-PGF - DDR4-2400 16x4 GB
i9-7920xCPU 12c 2.90GHz Water cooled
2x 1080ti DeckLink Studio 4K (11.4)
W10-1903 - BMR St. 16.2.055
nvidia: 441.66 studio
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostSun Jan 26, 2020 9:45 pm

I once had a C language teacher that called it spaghetti code as well! I think we have the perfect name for a collection of Resolve scripts right there.

Yes, the goal is to get it working on all three platforms.
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostWed Jan 29, 2020 3:05 pm

No script would be worth its name if the script itself was not scriptable. So in addition to the GUI you will be able to execute the same thing from the Terminal/PowerShell/Command Prompt without user interaction. Or from another Lua script inside Resolve or the scripting Console.

Image
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostTue Feb 25, 2020 2:12 pm

I haven't forgotten about this. It's just that there's an elusive bug when using UIManager to display a window with a Tree inside it. It only affects Linux. It's intermittent but gets way worse once you start nesting controls (when the Tree is inside one or more layouts). Impact is severe, when you close the window and hover over another control in Resolve it completely crashes Resolve.

I don't think there's anything I can do about it and what's worse, BMD does not yet offically support this "new" (since Fusion 8) way of creating GUI:s for scripts. If I report it I imagine it will go straight to the bottom of the backlog.
Offline
User avatar

iddos-l

  • Posts: 288
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

Re: finding embedded mattes in exrs

PostTue Feb 25, 2020 2:54 pm

Maybe release a win/Mac version?
Is it in lua?
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostFri Mar 06, 2020 10:25 am

From my initial smoke test in v16.2 it seems the issue with UIManager on Linux has been silently (or unknowingly?) fixed. Will do more tests before confirming though.
Offline
User avatar

roger.magnusson

  • Posts: 1107
  • Joined: Wed Sep 23, 2015 4:58 pm

Re: finding embedded mattes in exrs

PostFri Mar 06, 2020 7:17 pm

Unfortunately it's still crashing, just not as frequent. Out of about 20 runs it crashed twice. I'll write up a report for BMD and hope they can fix it.

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], burn4ever, IsraEliteMedia and 61 guests