Getting metadata from newly added sources through python

Using python I am attempting to access the start frame of a piece of media immediately after adding it to a session with a piece of code like this:

file_source = rvc.addSourceVerbose(sources)
source_start = rvc.sourceMediaInfo(file_source).get("startFrame")

If I run these two lines of code separately it works as excepted. If I run them together the start frame always returns 1. In fact, all of the metadata returned by sourceMediaInfo appears to be set to its default values.

I assume that, when the lines are run together, some evaluation step is delayed so that the metadata is not yet populated when I access it. Is there some command I can use to force RV to do this evaluation? Or some other solution to this issue?

Hello Will,

You guessed right: the rvc.addSourceVerbose() is asynchronous and this is what makes the following rvc.sourceMediaInfo() command behaves like you reported.

With the aim of improving loading performances of large playlists, progressive source loading was introduced in RV 7.8.

This makes the following RV commands asynchronous: rvc.addSource(), rvc.addSources(), rvc.addSourceVerbose(), and the new rvc.addSourcesVerbose().

I believe you currently have two options to solve this issue :

Option#1: You can disable progressive source loading by either setting the RV_PROGRESSIVE_SOURCE_LOADING environment variable to zero:

export RV_PROGRESSIVE_SOURCE_LOADING=0

or by adding the ‘-progressiveSourceLoading 0’ to the RV command line:
/Applications/RV.app/Contents/MacOS/RV -progressiveSourceLoading 0

Option#2: You can delay the call to rvc.sourceMediaInfo() in the ‘after-progressive-loading’ event that is triggered after the media has been loaded.

I hope this helps

Bernie

1 Like

Pair the after-progressive-loading with the Single-Shot binding I describe here: Single-Shot Binding and you might have a pretty good solution (that way you can fire and forget with a lambda).

1 Like

Thank for your help.

Can I confirm, addSources appears to be the only command that kicks off an after-progressive-loading event. addSource and addSourceVerbose don’t seem to do so.

I’m running this fairly simple test case in the Shotgun Python Console:

import rv.commands as rvc

def test(event):
    print("Loaded")
rvc.bind("default", "global", "after-progressive-loading", test, "")
rvc.addSourceVerbose(sources)

and I get no result. The same thing addSources works as expected. Is that anyone else’s experience?