Search code examples
replacemp4video-processingafter-effectsvideo-conversion

Change text in aepx file programmatically


I am trying to develop an API using PHP, Which will receive Text from user as Input. I need to change text inside the aepx file. On my research I found <string> tag and <ldata> contains text value and corresponding its hexadecimal value respectively.

I am able to parse and replace text of <string> tags in aepx. I am also able to change the hexadecimal values of bdata attribute of <ldata>.

But after all the changes I have made, it is not rendering(tried to run using aerender command). Also After Effect Application(latest -cc 2018) is crashing while opening changed aepx file.

Example:

Original

<ldta bdata="0000000c00020000000000010000000000005da80000000000005da8000afc8000005da80000008700 0000000000000000000000000000000000000100010000506c616365686f6c6465722074657874000000000000 000000000000000000000000000200000000000000000000000100000000000000000000000000000000000000 0300000000000000000000000000000000000000000000000000000000"/>

<string>Placeholder text</string>

After Change

<ldta bdata="0000000c00020000000000010000000000005da80000000000005da8000afc8000005da80000008700 000000000000000000000000000000000000010001000048656C6C6F20576F726C642100000000000000000000 000000000000000000020000000000000000000000010000000000000000000000000000000000000003000000 00000000000000000000000000000000000000000000000000"/>

<string>Hello World!</string>

Solution

  • You can do this using After Effects Expressions. Following are the steps which worked for me:

    1. Open the project in AfterEffects
    2. Go to Text layer you wish to modify
    3. Click arrow icon which shows a sub section with a stopwatch icon and the text "Source Text"
    4. ALT + click the stopwatch icon, you will see another section underneath it with text "Expression Source Text"
    5. Give its value as "thisLayer.name"
    6. Click File > Save as > Save as xml
    7. This will create you a aepx file.
    8. Open aepx file in any text editor and search for the text you wish to modify. Confirm that it looks like in the attached sample aepx image. The following is the expression line "thisLayer.name" that we created through AfterEffects in above steps.
    9. Now change the text "This is the text to be changed" to whatever you wish,
    10. Render and check. If all ok then it must be changed.

    Attached images:

    1. After Effects steps to setup expression
    2. Sample aepx glimpse.

    enter image description here

    enter image description here