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

Mogrt getValue returns JSON in Extendscript

Community Beginner ,
Apr 27, 2020 Apr 27, 2020

Copy link to clipboard

Copied

Premier Pro V 12.1

I made a simple mogrt in Premier Pro and then saved it as a mogrt template and inserted it on the timeline.

It just contains a text field with a rectangle background. 

 

I want to change the text of the  mogrt by extendscript.

However when I try to do that in Extendscript using

 

seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").setValue("Test Text");

 

the mogrt on the timeline just loses its existing text. I mean the text just vanished only the background stays.

To debug the issue I tried reading the value of the mogrt using

 

var obj = seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").getValue();

however here I get some kind of json value when I look at obj using

 

$.writeln(JSON.stringify(obj));

 

The printed output is like this for 

"ऒ\u0000\u0000\u0000{\"mTextParam\":{\"mAlignment\":0,\"mDefaultRun\":[],\"mHeight\":0,\"mHindiDigits\":true,\"mIndic\":true,\"mIsVerticalText\":false,\"mLeading\":0,\"mLigatures\":true,\"mRTL\":false,\"mShadowAngle\":135,\"mShadowBlur\":40,\"mShadowColor\":4144959,\"mShadowOffset\":7,\"mShadowOpacity\":75,\"mShadowSize\":0,\"mShadowVisible\":false,\"mStyleSheet\":{\"mBaselineOption\":{\"mParamValues\":[[0,0]]},\"mBaselineShift\":{\"mParamValues\":[[0,0]]},\"mCapsOption\":{\"mParamValues\":[[0,0]]},\"mFauxBold\":{\"mParamValues\":[[0,false]]},\"mFauxItalic\":{\"mParamValues\":[[0,false]]},\"mFillColor\":{\"mParamValues\":[[0,16777215],[10,16745993],[11,16745993],[12,16745993],[13,16745993],[14,16745993],[15,16745993],[16,16777215]]},\"mFillOverStroke\":{\"mParamValues\":[[0,true]]},\"mFillVisible\":{\"mParamValues\":[[0,true]]},\"mFontName\":{\"mParamValues\":[[0,\"Assistant-SemiBold\"]]},\"mFontSize\":{\"mParamValues\":[[0,140]]},\"mKerning\":{\"mParamValues\":[[0,0]]},\"mStrokeColor\":{\"mParamValues\":[[0,16777215]]},\"mStrokeVisible\":{\"mParamValues\":[[0,false]]},\"mStrokeWidth\":{\"mParamValues\":[[0,1]]},\"mText\":\"This is a sample text\",\"mTracking\":{\"mParamValues\":[[0,0]]},\"mTsumi\":{\"mParamValues\":[[0,0]]}},\"mTabWidth\":400,\"mWidth\":0},\"mVersion\":1}"

I don't understand what are those extra characters at the start of the json, it has some indic character and 3 Nul characters, due to which JSON.parse() throws an exception.

 

Can we use this JSON and modify the text string of the mogrt? Or is there any other way to achieve this?

TOPICS
How to , SDK

Views

3.5K

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

correct answers 5 Correct answers

Adobe Employee , Apr 27, 2020 Apr 27, 2020

The API was designed to support .mogrts created in After Effects; we do hope to eventually support PPro-created .mogrts, but currently no, they won't work.

 

 

Votes

Translate

Translate
Explorer , Apr 27, 2020 Apr 27, 2020

From my experience with it, you can actullay create an object if you remove that first 3 object - while storing it in temp var.

Then modify the valuse in the jsoned object. 

When u done jest set the value of the fx to be the temp var + the modifyed json obj. 

 

I did managed to do so, and it is possible even if its "unsupported".

 

this form post might help, its not directly about it but yea.. https://community.adobe.com/t5/premiere-pro/timevarying-for-text-source/m-p/10521326?page=1#M218212

Votes

Translate

Translate
Community Beginner , Apr 28, 2020 Apr 28, 2020

Just tried out something that seems to WORK!

 

var jsonVal = seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").getValue();
var jsonObjPart = jsonVal.substring(0, 4);
var jsonObj = JSON.parse(jsonVal.substring(4));
jsonObj.mTextParam.mStyleSheet.mText = "This is a new text";
var jsonOutstr = JSON.stringify(jsonObj);
var jsonOutstr = jsonObjPart + jsonOutstr;
seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").setValue(j
...

Votes

Translate

Translate
Adobe Employee , Jun 25, 2020 Jun 25, 2020

Yes. All our testing has been with AE-sourced .mogrts, like the one included with PProPanel.

(The API's preference for AE-sourced .mogrts should be better documented, I'll fix that.)

 

Votes

Translate

Translate
Adobe Employee , Sep 22, 2021 Sep 22, 2021

The JSON object is not part of PPro's ExtendScript API; it's only available if the CC Libraries panel is open. 

 

To make sure your JSON works even when the Libraries panel is not open, we recommend Douglas Crockford's json2.js.

https://github.com/douglascrockford/JSON-js


Votes

Translate

Translate
Adobe Employee ,
Apr 27, 2020 Apr 27, 2020

Copy link to clipboard

Copied

The API was designed to support .mogrts created in After Effects; we do hope to eventually support PPro-created .mogrts, but currently no, they won't work.

 

 

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 Beginner ,
Apr 28, 2020 Apr 28, 2020

Copy link to clipboard

Copied

Thanks for the information, I'll try some workaround's as suggested by "olympica"

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 ,
Apr 27, 2020 Apr 27, 2020

Copy link to clipboard

Copied

From my experience with it, you can actullay create an object if you remove that first 3 object - while storing it in temp var.

Then modify the valuse in the jsoned object. 

When u done jest set the value of the fx to be the temp var + the modifyed json obj. 

 

I did managed to do so, and it is possible even if its "unsupported".

 

this form post might help, its not directly about it but yea.. https://community.adobe.com/t5/premiere-pro/timevarying-for-text-source/m-p/10521326?page=1#M218212

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 Beginner ,
Apr 28, 2020 Apr 28, 2020

Copy link to clipboard

Copied

Thanks for the reply I tried doing something on this lines on what you suggested,

 

 

var obj = seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").getValue()
var objStr = JSON.stringify(obj);
objStr = objStr.replace("ऒ\\u0000\\u0000\\u0000");
var jObj = JSON.parse(objStr);

 

If I remember correctly I got some wierd results in "jObj" I will look into that link what you suggested, and see how to move ahead.

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 Beginner ,
Apr 28, 2020 Apr 28, 2020

Copy link to clipboard

Copied

Just tried out something that seems to WORK!

 

var jsonVal = seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").getValue();
var jsonObjPart = jsonVal.substring(0, 4);
var jsonObj = JSON.parse(jsonVal.substring(4));
jsonObj.mTextParam.mStyleSheet.mText = "This is a new text";
var jsonOutstr = JSON.stringify(jsonObj);
var jsonOutstr = jsonObjPart + jsonOutstr;
seq.videoTracks[0].clips[0].components[2].properties.getParamForDisplayName("Source Text").setValue(jsonOutstr, true);

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 ,
Apr 28, 2020 Apr 28, 2020

Copy link to clipboard

Copied

Cheers!

Happy to help 🙂 

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
Engaged ,
May 16, 2020 May 16, 2020

Copy link to clipboard

Copied

Just FYI for anyone who might stumble across this topic (like myself)... a quick test seems to suggest that this method is no longer possible with 'NewWorld' scripting enabled. Works well otherwise tho.

 

 

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
Adobe Employee ,
May 16, 2020 May 16, 2020

Copy link to clipboard

Copied

Specifically, what method fails in New World? 

 

 

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
Engaged ,
May 16, 2020 May 16, 2020

Copy link to clipboard

Copied

Hey Bruce, I'm refering to the unsupported method, detailed above, for accessing the Source Text (object) of a basic Premiere Pro authored Text Item ie MOGRT clip instance, using:

JSON.stringify(app.project.activeSequence.videoTracks[track].clips[clip].components[3].properties[0].getValue());
 
In 'OldWorld' that call returns a string that contains the Source Text object (which can be succesfully manipulated as directed above).
In NewWorld it seems to return just a single character 
 
 

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
New Here ,
Jan 15, 2022 Jan 15, 2022

Copy link to clipboard

Copied

Did you able to resolve? I am also getting single char.

 

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 Beginner ,
Jun 25, 2020 Jun 25, 2020

Copy link to clipboard

Copied

I also have this issue. Under NewWorld using the above workaround returns a single character. Has anyone had success in the last month?

 

The specific method is getValue() on the MOGRT. It returns a single (non-ascii) character.

 

I understand this is unsupported, but it's quite important to have access to the text. Is there a timeline when it is expected to be working? I just tried the Premiere Pro beta with no success as well.

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
Adobe Employee ,
Jun 25, 2020 Jun 25, 2020

Copy link to clipboard

Copied

In what application was the .mogrt you're using, created?

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 Beginner ,
Jun 25, 2020 Jun 25, 2020

Copy link to clipboard

Copied

Thanks for the fast reply. It was created in premiere. I assume that's probably my answer, it's only somewhat supported for after effects templates correct? And not at all for premiere?

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
Adobe Employee ,
Jun 25, 2020 Jun 25, 2020

Copy link to clipboard

Copied

Yes. All our testing has been with AE-sourced .mogrts, like the one included with PProPanel.

(The API's preference for AE-sourced .mogrts should be better documented, I'll fix that.)

 

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 Beginner ,
Jun 25, 2020 Jun 25, 2020

Copy link to clipboard

Copied

In my case it's not convenient to use AE .mogrts so I'll have to wait until the premiere-created ones are editable. Thanks again for the answer!

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 Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Hi Bruce, have just checked the latest release of Premiere Pro (15.0) and getValue() on the Source Text Property for Premiere Pro built .mogrt is still returning that random single unicode character instead of the expected text string. As you've said the API's main focus is to support AE built .mogrt but was wondering if there are any plans to eventually solve this bug for premiere pro .mogrts (along with I assume ,setValue(), which also doesn't look to work at the mo as well)?

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
Adobe Employee ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

PPro's APIs are in the process of being re-exposed for use from UXP plug-ins (which are actually extensions); any plans such as [above], while good ideas, should not be considered 'near term'.

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 ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

I'm trying to deal with the same issue, and I would like the solution you are proposing.

my code is the folowing:

 

var obj = sequence.videoTracks[0].clips[0].components[3].properties[0].getValue();
$.writeln(JSON.stringify(obj));

 

 

However, the VSCODE returns me the following error:

 

Runtime Error: Error Code# 2: JSON is undefined @ file '/c/premieretesti/TESTI.jsx' [line:227, col:1]
 
It seems like JSON is unabled....
 
could you please help me enabling it?

 

 

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
Adobe Employee ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

The JSON object is not part of PPro's ExtendScript API; it's only available if the CC Libraries panel is open. 

 

To make sure your JSON works even when the Libraries panel is not open, we recommend Douglas Crockford's json2.js.

https://github.com/douglascrockford/JSON-js


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 ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

Any update regarding the possibility to change the text value in Mogrts created in Premiere Pro 2021?

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
Adobe Employee ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

No such behavior changes have yet been scheduled.

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
New Here ,
Feb 12, 2023 Feb 12, 2023

Copy link to clipboard

Copied

Any update on this please?

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
Adobe Employee ,
Feb 13, 2023 Feb 13, 2023

Copy link to clipboard

Copied

LATEST

There is no update. No further ExtendScript API work is planned or scheduled. 

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