PySegment.smart_replace_media fails if current media path includes a space

Can someone help me determine if this is a Flame bug or if I’m doing something incorrectly:

I have a conformed sequence with source media where some of the original media paths have space characters in the filename. I am using custom Python code to rebuild this conformed sequence with different media I have exported previously. If I use PySegment.smart_replace_media(), I get an exception RuntimeError: Invalid source clip.

Note that if I just do a “Sequence Publish” export on the original sequence and configure it to re-import the exported media that way, it works as expected, with my exported media in the new copy of the sequence all aligned to where it is supposed to be.

Is this a bug in the PySegment.smart_replace_media() method in the Flame API? Am I doing something wrong? The original paths are coming from external sources, so it’s not a trivial matter to ensure they have to spaces in them before the work completes, and that’s something I’d rather not have to deal with, if possible.

Any help is appreciated. Thank you,
-robin

Fix the names
If it’s coming from an external source and can be quarantined on the central storage, script a way to make hard links on the same file system with sanitized filenames.
Keep a log of this conversion.
Conform from the sanitized filenames.
Program everything afterwards.

You probably know how this will go, Phil, given the source of the media and the artists I am supporting…

I can certainly put that together as an option, but if this is a stupid bug in the Flame API itself, which clearly allows spaces in the names, I’d like to at least try to get Autodesk to fix it!

I’d love to help Robin.

Meanwhile, if you want to report a bug, submit it as a support case, through the manage.autodesk.com site.

If you submit the python script here, there are several generous souls who will most likely fly in to the rescue with a different perspective.

Be brave brother.

Everything will work out.

1 Like

I just had a thought.
I know:
It’s pretty rare.

Have you read about ‘Smart Replace’ and how it works?

The capability is dependent on the existence of a sequence into which the output node (render node or write file node) can ‘Smart Replace’ the result.

Have one of the artists load a sequence, with the corresponding batch groups to a desktop.

If the output of a batch group is feeding a segment in that timeline then ‘Smart Replace’ will function as you anticipate.

If you are using Render Nodes, you can keep doing this.

If you are using Write File Nodes and openclip, you only need to do this once.

If you send those batch groups to another station, that does not have the timeline, ‘Smart Replace’ does not function.

You must have the corresponding timeline, and that can be disastrous because there is not currently an openclip equivalent of a timeline where you have version001 and version002, so two artists buggering about with the same timeline can result in irreconcilable forking.

I’m happy to videoconference and show you.

FYI, you can recreate this in the Python console in Flame without a script. Just build a sequence with media that has spaces in it, import a clip with different media (without a space) and run something like this in the Python Console:

import flame
seq = flame.find_by_name("original_sequence")[0]
clip = flame.find_by_name("new_clip")[0]
segment = seq.versions[0].tracks[0].segments[0]
segment.smart_replace(clip)

Let me see what Autodesk says, but I may take you up on looking at your workaround next week. Thanks for your thoughts, Phil.

Also, in my case, the new replacement clip is an OpenClip, but the original sequence is conformed directly with the MOVs coming from the client (who is giving us the names with spaces).

In LOGIK-PROJEKT the write nodes automatically switch to Smart Replace after conform.
I just teach people to turn them off when rendering v0002 or above, since the openclip segment is now injected into the timeline.
Distributed batch groups just bump up the iteration/version so the timeline can be manipulated by script or by artist to load the latest version.
Smart Replace is only used immediately after conform, to swap the published openclips with the required ‘comp’ openclips.
My code is free and available if you want it:
LOGIK-PROJEKT

1 Like

The PySegment smart_replace (which overwrite the sequence TimelineFX with the source clip TimelineFX) and the smart_replace_media (which keep the sequence TimelineFX) only accepts the source clip if it fit one of the two following condition:

  • The source clip media has the same length as the media in the PySegment ( including head and tail ) or the source clip media is a virtual source ( 1 frame with infinite head and tail ).
  • The source timecode at the start of the PySegment can be found somewhere in the source clip and there is enough media between that time and the end of the source clip to fill the PySegment.
1 Like

Thank you for that information, Philippe. I will double check those conditions in my clips and make sure it’s not something going weird there. Do you know if there is sample Python code for how to handle swapping a clip in a sequence if those conditions are not met?

Thanks,
-robin

Replacing a Clip on the Timeline

OK, with more testing it seems it is not the space that is the issue. I can’t reproduce that so there must be something else going on with that data itself I will have to look at. Thank you all for your help.

Logik Live #140

This is how I use the ‘Smart Replace’ function.