Check for frames on local storage before loading. If exist load those instead

Hello,

I’d like to be able to use screening room in RV and load 4k EXR/DPX sequences from a local SSD. This is obviously much faster than the server. However not all media is on the server and only some on the SSD. Is there an option for the to tell RV to check a relative file path before loading the files from the server? If they don’t exist on the SSD just load from our server? Ideally I want this to be seamless to the user when using RV.

I have read the documentation here

but this seems to relate to swapping paths across different operating systems. Perhaps i’m misreading the documentation?

Would really appreciate help if anyone has any tips.

Thanks!

2 Likes

Hey K!

Thank you for using the community!

You can write a package that binds on source-group-complete event (Event Reference HERE), where you can cycle through media and replace the paths with what you need. The core code would look something like this:

    # Rough logic, please don't use as is!
    from rv import commands, extra_commands
    info = extra_commands.sourceMetaInfoAtFrame(rv.commands.frame())
    metadata = commands.sourceMediaInfo(info['node'])
    filename = metadata.get("file")
    sourceFrame = info['frame']
    files = commands.existingFilesInSequence(filename)
    frames = commands.existingFramesInSequence(filename)
    framesToFiles = dict(zip(frames, files))
    framesToFiles[sourceFrame]

You can set the path by modifying media.movie property on RVFileSource node by running commands.setStringProperty("%s.media.movie" % sourceNode, "/new/path/.1001-1004.exr").

If you need help writing your first package, we have some reference her:

Hope this helps!

Cheers,
Alexa

2 Likes

Thanks Alexa for taking the time to reply - super helpful. Will give it a go and let you know if I run in to issues!

1 Like

I am having problems getting this to work (7.6 - 2021).
Where you setStringProperty, if I take the same form that you show, it returns the following error :

TypeError: Bad argument (1) to function commands.setStringProperty: expecting dynamic array

But if I encapsulate the path in square brackets, then it hard crashes RV without any error.
The only difference I can see in my code is that the path I’m passing uses “%4d” instead of a framerange. Can you confirm the valid syntax of the path when using setStringProperty?
Thanks!

and if I get an array of files using “existingFilesInSequence”,

commands.setStringProperty(‘sourceGroup000000_source.media.movie’, files)

I get the error :

Exception: Exception thrown while calling commands.setStringProperty – exception: “in commands.setStringProperty: number of values does not match property size”, program exception

Hey @Patrick, the specific error you have is that you are trying to set an array into a slot for a single value. Check out commands.contractSequences to shrink your sequence down to a single sequence notation rather than a list of frames.

Also, you can be a little bit more efficien with this if you bind on incoming-source-path and set your path with event.setReturnContents rather than source-group-complete. Then you never have to load things twice (or set the movie property, just return the new path as the returnContents)

Function: returnContents
Path: Event.returnContents

returnContents (string; 
                Event)
Description
Access to the "return value" for this event set by previous event handlers. In order to "daisy-chain" event handling for events with a return value (for example, the "incoming-source-path" event), handlers should check the event's returnContents, so that work done by previous handlers is not overridden.
1 Like

Hi Michael,
If I don’t set an array it raises an error.

TypeError: Bad argument (1) to function commands.setStringProperty: expecting dynamic array

It must be in the form ‘[path]’.

I’ll certainly try the method you suggest though, but can you provide an example of a valid path value as neither single, dynamic or array values appear to be valid.

Thanks!
p.

Also, how do I find documentation on the “contractSequences” method? I see nothing about it in the docs.
How did you get the docstring you posted?

I also can’t find any reference to this event in any of the documentation. Can you point me in the right direction?
Thanks
p.

Hi again,
I’ve got the income_source_path event working now.
The problem remains though, if a user wants to revert the path-swap, I still need to execute a “setStringProperty” on the media node to update the path. When I do this, it crashes RV every time.

media_node = "sourceGroup000000_source.media.movie"
_path = '/Volumes/somepath/some_sequence_v074.%04d.exr'
commands.setStringProperty(media_node, [_path])

Is this not the correct way to update a source path on the fly?

This is on osx 10.15.6, RV2011.0.0

Thanks again
Patrick

The doc string is in the Mu API browser and the event is listed in 5.6 (Internal Events) of the reference manual.

The mu api browser is invaluable for both mu and python apis.

Aha! I forgot about that!

Ok, I figured out the problem. Using setStringProperty crashes RV, but setSourceMedia works!

The crash is probably worth making a reproduction case and submitting a ticket to the RV team.

Ideally if you are using the incoming-source-path you aren’t setting media, but instead just using the event.setReturnContents(newPath), then you aren’t loading media multiple times.

Yea the income_source_path works for when clips are loaded, but we also need to toggle the behaviour on and off after the clips are loaded, in which case I grab the sources and then update the paths… setSourceMedia did the job nicely!
Thanks again.
p

1 Like