• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Reload footage does not react immediately

New Here ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

Hi,
I am working on extension and one of the functions is: change source file to existing image item.

The flow of the function should be:
1. changing the source file in the file/folder level (Node fs package, .copy() method) = no problem here
2. after succcessfull copy, jsx function is called using evalScript (CSInterface lib) = no problem here
3. jsx function should .reload() the file source - according to AE Scripting documentation
app.project.item(index).mainSource.file.mainSource.reload()
But I realized in my project the only working structure (existing path to correct properties) is this one:
app.project.item(index).mainSource.reload()
(The code example attached below.)

I have auto-reloading turned on in AE Preferences.

The problem is that .reload() is not working in the moment of calling. This happens when using Extendscript and also when trying to reload via user interface (right-click on imported image item in Project > "Reload Footage"). By that time, I can see the image is already changed in the folder (the path to the image is the same), but in AE the preview still shows the old image source.
After repeating the "reload" several times or reopening app or just waiting and unfocusing the window to the other app and back to AE - it will finally change the source to new.

It seems like there is some time period (reaction time) between change of the source file and mirroring this into the AE (so it is replaceable for the new source).

I would like to know "when" I am able to reload source and the change will be made visible in AE.
But there is no callback or information on which I could hang on in my script.
How to ensure, that the image would be reloaded (change of image reflected) on some user (or script) action?

Because of this, it looks like .reload() is not functioning properly.

Please, how do you manage to resolve such situation?

Thank you very much:)

CODE EXAMPLE:
js part:

const assetPath = [path to asset];
await fileDialog({ accept: "image/jpg" })
   .then(files => {
        try {
            fse.copy(files[0].path, assetPath)
                .then(a => {
                    lib.evalScript("changeCustom('" + type + "', '" + name + "')", changeCustomResult);
                })
                .catch(err => catchError(err));
        } catch (err) {
            catchError(err);
        }
    }).catch(err => {
        catchError(err);
    });

 

jsx part:

function changeCustom(type, name) {
    app.beginUndoGroup("Change image source");
    var file = getAssetByName(name + ".jpg"); // returns item - app.project.item(i)
    var result = "";
    try {
        file.mainSource.reload();
    } catch(e) {
        result = e;
    }
    app.endUndoGroup();
    return result;
}



TOPICS
Error or problem , Import and export , Preview , Scripting

Views

107

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

The thumbnail will update on a UI redraw call, which could be as trivial as setting a different time to jump to on your current comp's timeline, jumping to anotehr comp or some sort of that trickery. Point in case: The thumbnail is triggered by how the source footage is used somewhere, not the releoad procedure.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

Hi Mylenium,

thank you very much for your quick answer.
I tried switching to another comp, moving along the timeline, creating new layers and other types of "clicking" and trickery.
Unfortunately that does not seem to be the solution. The change of the image preview will either take several seconds (under a minute) or it will not change at all (only when I unfocus and refocus the window with AE. And apparently it is not triggered by any of my actions above.

So how I understand it now (to reformulate my problem) - I need to wait for "change of image in Project panel, demonstrated by preview thumbnail", because only after that, I am able to click "reload footage" and item will be actually reloaded to this "new" source.

How do I get to know that this situation just happened?

Or is there any workaround to "refresh the project"? As far as I know there is none. 😕

Thank you 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

LATEST

There is one important thing I did not highlight (and probably the reason why this is not behave as expected):
The part when I mention "(the path to the image is the same)" means, that the image I am trying to change has the same name.

I recently tried this last thing:

1. Change item source to placeholder with .replaceWithPlaceholder() (it is a method of FootageItem object).
2. Delete the image (for example myFile.jpg) from folder in my PC - so there will be no connection between AE item and its file source.
3. Copy/create the new image into that folder with the same name (myFile.jpg) as the deleted one. It was successful.
4. Replace item source to the myFile.jpg. And there is still the old version of image myFile.jpg!!! The one which was deleted.

Seeing this, I think that there definitely have to be some kind of caching or period (I tried setTimeout to loong duration) which could only be break by "refocusing"/ "refreshing" the app by clicking outside the AE app window.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines