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

How to get/set paramaters value in After Effects

Explorer ,
Aug 23, 2024 Aug 23, 2024

Copy link to clipboard

Copied

Hello,

 

in PremierePro, I use the combo PF_CHECKOUT_PARAM/PF_CHECKIN_PARAM in various places (SequenceSetup, SequenceResetup, Render, ...) to get/set (read/write) paramaters value but in AfterEffects params paremeter is NULL in PF_Cmd_SEQUENCE_SETUP, PF_Cmd_SEQUENCE_RESETUP and 

PF_CHECKOUT_PARAM crashes the plugin.

 

Is there a way to get/set parameters values outside of Render ?

 

Thanks in advance

 

David

TOPICS
Error or problem , SDK

Views

184

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
Community Expert ,
Aug 25, 2024 Aug 25, 2024

Copy link to clipboard

Copied

i'm not fluent in premier, but in AE during sequence setup/resetup the instance is not yet associated with an instance. AE knows it needs that data, so it calls upon your plugin to make that data for it, and only then does it create the instance where you can check your params.

 

i'll ask this: is the purpose of that process to "initialize" an effect instance's param state?

if so, in AE you'll want to do that during UPDATE_PARAMS_UI, which is called immediately after an inastnace is applied. (if you set the falg in global data of course)

that call, is intended only for cosmetics, i.e. showing/hiding/renaming. technically, you CAN change param values during that call, but there could be occurences where that call in not triggered (such as running AE without ui and loading a project, or automating it).

if you want to change param values on application in AE (i'm assuming dynimically, otherwise you'd just set the defaults in param setup), is to flag your effect as "new" (by some hidden checkbox, or sequence data), and during the first idle_hook call, you can externally change any param value you wish.

 

if you'd like to describe your work scenario perhaps i can think of a more suiting solution.

Votes

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
Explorer ,
Aug 26, 2024 Aug 26, 2024

Copy link to clipboard

Copied

Thanks Shachar for your answer. I will try to describe my use case which is quite "complicated". 

 

I am integrating an OpenFX plugin in Premiere/AfterEffects, for this I emulate an OpenFX Host inside the plugin. So I need a way to synchronize parameters between AE/Premiere and OFX instances.

 

The way it works in Premiere:

  • SequenceSetup: create OpenFX plugin instance and associate it with sequence_data , set all the PF_ParamDef to the values from the OFX instance. These are usually the default values given in ParamsSetup but could sometime differ.
  • SequenceResetup (usually called when loading a file): get all the PF_ParamDef and sets the corresponding OFX instance parameters
  • I set PF_ParamFlag_SUPERVISE on all params, so PF_Cmd_USER_CHANGED_PARAM is called when a change is made and I also apply it to the corresponding OFX instance.
  • UpdateParamsUI is used to update PF_PUI_INVISIBLE, PF_PUI_DISABLED from the status of the corresponding OFX parameter.

 

I also had to add PF_OutFlag2_PPRO_DO_NOT_CLONE_SEQUENCE_DATA_FOR_RENDER flag to prevent sequence_data to be recreated at each render which meant destroying/recreating my OFX instance at each render.

 

I also use the PF_UtilitySuite4 and PrSDKOpaqueEffectDataSuite to RegisterOpaqueEffectData to be able to access sequence_data in the Premiere's xGPUFilterEntry callback which does the GPU rendering but these suites are not accessible in AE.

 

So in AE, I had not (yet) found a hack to know:

  • when to create my OFX instance and associate it with sequence data
  • synchronize the parameters when creating a new instance OR loading an instance from disk
  • get access to sequence_data from xGPUFilterEntry (which is a PPro callback but is called in AE for GPU rendering, but PrSDKOpaqueEffectDataSuite does not seem to be available before render)

 

Thanks in advance

Votes

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
Community Expert ,
Aug 26, 2024 Aug 26, 2024

Copy link to clipboard

Copied

i see. indeed a complicated situation.

i'm not familiar with the OFX API, so some of what i would tell might not be applicable to your case.

 

1. sequence data.

in AE, sequence data for the render threads is always separate from the one in the UI thread.

you can have all render threads share one seq data handle or have each one have it's own, by using PF_OutFlag2_MUTABLE_RENDER_SEQUENCE_DATA_SLOWER.

in the case of multiple render threads, a single OFX plugin shared between them may have asynchronous param values being updated (because of keyframed params, or expressions), and thefore produce wrong render results for a given frame. i don't know if that's a valid concern in the way your system is set up...

perhpas you should consider the render threads copy of the OFX effect as a separate entity. it seems wasteful, but all it would mean that for every change on the UI instance, the render instances of the OFX are destroyed (on sequence_setdown) and rebuilt (on sequence_resetup) when syncing the ui and render thread seq data. if you're comfortable with that idea, then the nighmare trying to merge the render and ui seq datas into one persisant piece of memory is over. (and it is a nightmare, let me assure you)

 

2. initaiting a new instance.

since in AE during a sequence_setup call the effect instance does not yet exist and is therefore inaccessible, i would suggest you mark the new OFX effect int he sequence data as "uninitiated", and then:
- on the ui thread, use the first UPDATE_PARAMS_UI call and set the default params data then.
- on the render thread, if a render call is triggered on an "uninitialized" OFX, just ignore the param values AE has, and use the deault ones in the OFX.
that way, you'll get a correct render even before the UI thread has a chance to update the params.

 

3. sequence data is always available. is it not during xGPUFilterEntry? isn't PF_EffectSequenceDataSuite1 available there?

Votes

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
Explorer ,
Aug 26, 2024 Aug 26, 2024

Copy link to clipboard

Copied

LATEST

1) sequence data

My OFX instance is loading large data files and uploading them on GPU.  And the data loading could depend on the parameter value. So creating/destroying sequence_data at each render will be a performance killer.

 

2) initializing a new instance

OK, marking OFX as uninitialized and initializing it in UpdateParamsUI or on "first" render could do the job.

My other oncern was to initialize AE parameters on first OFX creation.

For example, choosing an option in a popup, sets values in multiple hidden float sliders. So during OFX instanciation, these hidden float sliders are setted with correct values.

A possible solution would be to create a dummy OFX instance during ParamsSetup and use the parameters as default values.

 

3) PF_EffectSequenceDataSuite1 is not accessible in the xGPUFilterEntry Premiere side. And even if it was accessible, the suite function PF_GetConstSequenceData needs an effect_ref but  xGPUFilterEntry never gets  PF_InData/PF_OutData. 

A possible solution would be to switch to PF_Cmd_SMART_RENDER_GPU but I did not find any example on how to use it ?

 

Regards

 

David

 

Votes

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