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

Resolve: mediapool loader and inventory clearing plugins #140

Merged

Conversation

jakubjezek001
Copy link
Member

@jakubjezek001 jakubjezek001 commented Feb 29, 2024

Changelog Description

Adding plugin for loading into mediapool with option to also add into timeline. Inventory plugin for clearing timeline item container included unused media's from mediapool. Clips in mediapool are colormanaged via remapping.

Additional info

Following changes are adaptation from Colorbleed's code BigRoy/OpenPype@37da9c6#diff-3ec58869aa5ff3f62216d417256778fd5b44ea0132b953e67d7880f5e7b53df5. Thanks @BigRoy
The fix dealing with Adjustment Clips on timeline which was originally here were moved into #92.

Next steps

  • Adding settings for metadata loading

image

Testing notes:

Load media (loader)

  1. Open Resolve menu and chose Loader
  2. select any product type version and RMB click
  3. Chose Load media plugin and load anything
  4. see that the media is added to mediapool and also into timeline
  5. load again but this case use loader option box and disable add to Timeline
  6. This time it will load only into mediapool

Remove Unused Media (inventory)

  1. make sure you are having loaded some clip into timeline
  2. duplicate the mediapool clip so there is something to be erased
  3. open Inventory manager
  4. select any item in manager and RMB click
  5. in submenu go to actions and select Remove Unused Media
  6. it should remove all duplicates and only one clip should remain

…r setting the resulting bin as the current folder. Add iter_all_media_pool_clips function to recursively iterate all media pool clips in the current project. Introduce RemoveUnusedMedia inventory action plugin to remove unused media pool items and LoadMedia loader plugin for loading media into Resolve.

adaptation from BigRoy/OpenPype@37da9c6#diff-3ec58869aa5ff3f62216d417256778fd5b44ea0132b953e67d7880f5e7b53df5
…rences, and adjust track index handling in find_clip_usage function.
@ynbot ynbot added type: enhancement Improvement of existing functionality or minor addition host: Resolve size/S labels Feb 29, 2024
Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for transferring the logic into a PR. Here are some notes to keep in mind.

client/ayon_core/hosts/resolve/plugins/load/load_media.py Outdated Show resolved Hide resolved
client/ayon_core/hosts/resolve/plugins/load/load_media.py Outdated Show resolved Hide resolved
Comment on lines 341 to 348
# Get the start and end frame of the image sequence, incl. handles
frame_start = version["data"].get("frameStart", 0)
frame_end = version["data"].get("frameEnd", 0)
handle_start = version["data"].get("handleStart", 0)
handle_end = version["data"].get("handleEnd", 0)
frame_start_handle = frame_start - handle_start
frame_end_handle = frame_end + handle_end
padding = len(representation["context"].get("frame"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've heard of cases where a particular representation might have differing frame ranges than the version data (e.g. slates added, etc.) and as such this MIGHT be incorrect for some edge cases. We might need to at some point store those ranges in representation["data"] so we can reliably get frame ranges per representation instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good point for the new Representation model @antirotor is working on.

Added a list of metadata items for clip properties. Refactored setting clip metadata based on context.
- Refactored clip color variables
- Updated media pool bin path template
- Modified metadata mapping structure for LoadMedia plugin
@tokejepsen
Copy link
Member

load again but this case use loader option box and disable add to Timeline
This time it will load only into mediapool

This wont load the same product if its already in the timeline. Do you mean we should remove it first?

Copy link
Member

@tokejepsen tokejepsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Unused Media (inventory)

This does not work atm. The duplicated clip is not removed.

@BigRoy
Copy link
Collaborator

BigRoy commented Mar 11, 2024

This does not work atm. The duplicated clip is not removed.

Could you show what happens for you?
Does Resolve itself still list usages for that clip in the media pool? Right click it > Usages.
If no usages, only then should it remove it.

@BigRoy
Copy link
Collaborator

BigRoy commented Mar 11, 2024

This wont load the same product if its already in the timeline. Do you mean we should remove it first?

There is an option box on the Load Media loader - in there you can disable "re-use existing" - when disabled this should load the media pool item another extra time into the media pool instead of continuing to use the existing media pool item of this version that you had loaded previously.

Note however: there are certain file types that I loaded where Resolve just seemed incapable of loading it again (I believe exr sequence?) even though I'm explicitly requesting there API to load it again. In those cases, the logic to 'not re-use, load again' will likely fail and actually continue to re-use since Resolve API just doesn't want to load it again into the same Media Pool Folder.

Also, during testing I'd recommend having the Resolve "console" open to debug whether the python scripts spew out any errors at all.

@jakubjezek001
Copy link
Member Author

jakubjezek001 commented Mar 12, 2024

This does not work atm. The duplicated clip is not removed.

Could you confirm there are no logs in Console in regards of removing?

Here is a video on how it works on myside and where to look for logging.

Untitled.mov

@BigRoy
Copy link
Collaborator

BigRoy commented Mar 12, 2024

Uploading removing_mediapoolitem.mp4…

@jakubjezek001 I think you just submitted your comment too early before the file finished uploading. 🌪️

Copy link
Member

@tokejepsen tokejepsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load again but this case use loader option box and disable add to Timeline

I cant get the media to load a second time. I've tried disabling the Re-use existing option, but it does not bring in any extra clip.

select any item in manager and RMB click

Looks like you need to select at least the group of containers with unused media in it. Maybe this action should either be fixed so you can select any item in the manager or entry to the tool should be somewhere else than the manager?

@BigRoy
Copy link
Collaborator

BigRoy commented Mar 15, 2024

I cant get the media to load a second time. I've tried disabling the Re-use existing option, but it does not bring in any extra clip.

What type of media are you loading? A sequence or video file? What extension?

I've had this a few times where Resolve just didn't want to load it again but it only occurred with certain files. That's the note I mentioned there. I didn't investigate too much as to why that happens exactly.

Looks like you need to select at least the group of containers with unused media in it. Maybe this action should either be fixed so you can select any item in the manager or entry to the tool should be somewhere else than the manager?

Any inventory action only runs over the entries you've selected in the manager - so yes. It would only clear from your selection.
It is possible to ignore the selection in the action and remove ALL regardless of selection - but usually these actions apply to the selection.

@tokejepsen
Copy link
Member

What type of media are you loading? A sequence or video file? What extension?

EXR sequence, so maybe this is the issue you are referring to. Maybe we can warn the user at least about the non-existent functionality of EXRs?

Any inventory action only runs over the entries you've selected in the manager - so yes. It would only clear from your selection.
It is possible to ignore the selection in the action and remove ALL regardless of selection - but usually these actions apply to the selection.

Yeah, question is what makes sense to the user?
I would have thought an action like Remove unused... would remove all, but maybe we just need to change the label of the action to Remove unused... from selection?

@BigRoy
Copy link
Collaborator

BigRoy commented Mar 15, 2024

Yeah, question is what makes sense to the user?
I would have thought an action like Remove unused... would remove all, but maybe we just need to change the label of the action to Remove unused... from selection?

We have the same in Maya "Remove unused looks" which also removes only from the selected containers so might be that we were just familiar with that 'workflow'.

However there if you were to run remove_unused_looks without containers then it does remove all. I wonder if that's actually possible from the manager UI, to trigger it without selection. If so, then I'd also do that here - remove all if none selected, otherwise operate only on selection?

@tokejepsen
Copy link
Member

If so, then I'd also do that here - remove all if none selected, otherwise operate only on selection?

Sounds good to me.

@BigRoy
Copy link
Collaborator

BigRoy commented Mar 27, 2024

@BigRoy BigRoy assigned BigRoy and unassigned jakubjezek001 Jun 11, 2024
BigRoy and others added 3 commits June 11, 2024 13:55
- Renamed resolve paths for media pool items
- Updated imports for media loading functionality
BigRoy and others added 4 commits June 11, 2024 14:10
…ns' into enhancement/AY-2612-resolve-adaptation-colorbleed-plugins
Deleted unused subproject integration for Unreal Engine.
…ation-colorbleed-plugins

Resolve: mediapool loader and inventory clearing plugins
Bumped up the version number from 0.2.1 to 0.2.2 in the package.py file for DaVinci Resolve addon.
Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. :)

Update the addon version from 0.2.1 to 0.2.2 in the codebase.
- Refactored file path handling for importing media.
- Updated method to determine if the file is a sequence.
- Improved handling of frame numbers in file paths.
Extracted media import logic to a separate method for clarity. The new method handles importing media to Resolve Media Pool and creating bins if necessary.
@BigRoy
Copy link
Collaborator

BigRoy commented Jun 12, 2024

@jakubjezek001 could you let me know what the conditions are to test this fix since I had tested both sequences and video files just fine before that.

I want to make sure I run through what's needed there. The code seems quite "involved" for something that should be trivial - so I'm hoping to find a way better than this madness.

@jakubjezek001
Copy link
Member Author

jakubjezek001 commented Jun 12, 2024

I want to make sure I run through what's needed there. The code seems quite "involved" for something that should be trivial - so I'm hoping to find a way better than this madness.

There was bug in the code, for some reason sequences were not loading at all for me until the fix. Also I wanted to make sure frame range is taken from real frames rather then from version data.

Here is the traceback from image sequences before:

Traceback (most recent call last):
  File "C:\CODE\__PYPE\ayon-core\client\ayon_core\tools\loader\models\actions.py", line 740, in _load_representations_by_loader
    load_with_repre_context(
  File "C:\CODE\__PYPE\ayon-core\client\ayon_core\pipeline\load\utils.py", line 323, in load_with_repre_context
    return loader.load(repre_context, name, namespace, options)
  File "C:\CODE\__PYPE\ayon-core\server_addon\resolve\client\ayon_resolve\plugins\load\load_media.py", line 227, in load
    assert len(items) == 1, "Must import only one media item"
AssertionError: Must import only one media item

@jakubjezek001 jakubjezek001 merged commit 05b2b78 into develop Jun 12, 2024
1 check failed
@jakubjezek001 jakubjezek001 deleted the enhancement/AY-2612-resolve-adaptation-colorbleed-plugins branch June 12, 2024 14:25
@BigRoy
Copy link
Collaborator

BigRoy commented Jun 12, 2024

For what it's worth - seemed to work fine on my end also with the changes. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
host: Resolve size/S sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants