Copy link to clipboard
Copied
I am working on importing video from a panel. I have links to full-res video and also a proxy. I would like to download the proxy first and import into project, so that the user can start working on it while the full-res is still being downloaded.
Is there a way to achieve this from panel code?
Thanks,
Andaleeb
1. Correct, importFiles() takes only one path.
2. The changeMediaPath() method is from the time before PPro supported proxies. Instead, PProPanel shows how to attach a proxy path to an existing projectItem.
Note: The path used to create a projectItem, is presumed to be full-res. When you call attachProxy(), you can attach the new path as either full-res, or proxy; the original path will be used as proxy / full-res (whichever the newly-added path, isn't).
3. As demonstrated in PProPanel, you can u
...Copy link to clipboard
Copied
1. Correct, importFiles() takes only one path.
2. The changeMediaPath() method is from the time before PPro supported proxies. Instead, PProPanel shows how to attach a proxy path to an existing projectItem.
Note: The path used to create a projectItem, is presumed to be full-res. When you call attachProxy(), you can attach the new path as either full-res, or proxy; the original path will be used as proxy / full-res (whichever the newly-added path, isn't).
3. As demonstrated in PProPanel, you can use app.project.getInsertionBin() to find out where the files you're importing will land. If you count the projectItems in that bin before and after your import, you'll have a list of newly-added projectItems.
Copy link to clipboard
Copied
Thanks Bruce. I tried the way you described:
I found that the second step does not always take effect in our case for some files (though the call returns true). I am guessing that Premiere runs some checks before setting the highres like whether it matches some properties/format of the previously set file in step 1, which our proxy is not meeting. Can you shed some light in this regard like what is expected in the proxy? We generate the proxy ourselves so maybe we can tweak some transcoder params to make it work. But we need to know what is expected by Premiere.
Thanks,
Andaleeb
Copy link to clipboard
Copied
We have mismatch in the number of audio channels between full-res and proxy, which may have caused the problem above.
Copy link to clipboard
Copied
That would prevent it from working, yes.
Copy link to clipboard
Copied
Is there any documentation or API refferences for this? As as far as i've found theres just this one function with no coments and the rest is left to guess work.
Copy link to clipboard
Copied
In case you haven't seen it, here's a link to that function in the Premiere Pro ExtendScript-based API docs
Copy link to clipboard
Copied
Thanks! is there anywhere that discribes how the proxies may differ? As number of audio channels seem to cause issue. are there any other factors?
Copy link to clipboard
Copied
Updating this old thread with a detailed explanation of how I made it work, to help others who are asking about similar situations.
1. Since Premiere does not have a way to import a file directly as a proxy, I needed to first import the proxy "as highres", with the importFiles API:
app.project.importFiles(
proxyFilePath,
1,
app.project.rootItem,
0
);
2. Immediately after the import, I identified and captured the reference to the newly added clip, which I found to be the last clip added to the bin:
var insertedClip = app.project.rootItem.children[app.project.rootItem.children.numItems - 1]
3. Then I set the proxy path of the clip to the path I imported it from, so that Premiere knows to show it as proxy:
insertedClip.attachProxy(proxyFilePath, 0);
4. Then I clear the full-res path of the clip by setting it to an empty string, since this clip does not really have a full-res media available yet. Please note that I have seen that this resetting of the full-res path is not be reflected in the Premiere bin UI immediately - you may need to reopen the project to see it. But the code updates the internal state correctly.
insertedClip.attachProxy("", 1);
5. Now I have the proxy media correctly set up for the imported clip in the bin. Next, when I have the full-res file of the clip available, I will need to set the full-res path on the clip by calling changeMedia on the clip (I don't remember exactly, but I think attachProxy with the second parameter set to 1 did not work in this case):
clipToSetFullResOn.changeMediaPath(fullResPath, true);
Now, the question is, how do I find the clipToSetFullResOn above in step 5? How do I know which child in app.project.rootItem.children corresponds to the insertedClip referred before at step 2-4? For this, some kind of bookkeeping is needed to tag the clip at the earlier steps, and then look for that tag by looping through all the clips at step 5. In my case, I needed this tag to be persistent, to be able to work across Premiere sessions, so I tagged it by setting an external ID for the clip with insertedClip.setProjectMetadata(). This associates the ID with the clip, and saves it persistently with the prproj file. Later, I went through all the clips, called getProjectMetadata() on each, and checked which one corresponds to my previously set ID, to ultimately find the right clip(s) to set the full-res path. Of course, setting/getting project metadata involves the use of some serialization/deserialization with XMPMeta.
Note: the proxy and the full-res needs to have the same number of audio channels. Apart from this, I do not know of any other properties that must match. It works even if the dimensions are different. But of course the more the proxies look and feel the same as the full-res, the more the user will be able to rely on the preview being the same as the final rendered result.
Hope this explanation helps.
- Syed Andaleeb Roomy