After Effects Python



CREATE THESE FIVE EASY ANIMATIONS IN AFTER EFFECTS! We will cover five essential animations in After Effects and cover the exact techniques that will help.

This is a tutorial on how to automate content with Python, in this case graphics, by using Python and Adobe After Effects.

  • So watch the video to discover how to make an intro in After Effects that will truly wow your target audience. Popular After Effects Intro Templates. With the skills you've just learned, you can customise all kinds of Adobe After Effects intro templates. There are thousands to choose from, offering you many different styles of intro to work with.
  • Opportunities abound for building for After Effects. Extend the capabilities of After Effects using plug-ins, scripts, and panels that integrate seamlessly into existing workflows. Create stunning visual effects, manipulate project elements, and automate complex tasks using After Effects APIs.
  • If you create and sell After Effects project templates or MOGRTs for Premiere Pro users, this plugin is a necessary tool. Expression Universalizer automatically converts the expressions in your AE projects so that they are compatible with After Effects running in any language. Convert comps or entire projects with the simple click of a button.

This is what we are going to make in this tutorial:

If you don’t like reading and prefer to watch a mediocre at best programmer slowly live code it:

This program can then be used to update the information in this graphic in seconds. Use it on another city, use it on another day, use it on the same day but later and they have changed tomorrow’s forecast.

This process can be used to take any information and package it into a graphic. Weather, sports, headlines, news, tweets, whatever.

So this is just one example of how you can automate content with Python. You can change the information, you can change the format, and you can even make video instead of graphics (I can show you how, if people are interested).

I currently use this exact same process, but taken a bit further on 2 social media accounts. The bes one is golf stats, leaderboards, and player profiles. Check out my page here @newnumberonegolf. The second one is betting odds for sports events. I’ve kind of stopped this one, but check out that page here @growbot_futures.

Check out the PROJECTS page for past, present, and future projects happening on this site.

I chose Instagram because it’s all about photos and while posting on Instagram you can just check a box and it posts to Facebook and Twitter as well. Pretty easy posting to all 3 at once.

These are an advanced version of this tutorial, but I didn’t use anything to make these photos that I’m not showing in this tutorial. It’s just the next step.

To show you how these are made we are going to make a graphic of the weather for the next 7 days for your city of choice. Then once it’s made for one city it will work on any city. You copy the link to a city and paste it into the python program and it regenerates the info for that city.

The Steps To Automate Content With Python and After Effects:

  1. Web scrape the information from a site.
  2. Format it correctly into a JSON File.
  3. Create a template in After Effects
  4. Wire up the JSON to the After Effects layers so the content can be changed dynamically.

To go the extra step and fully automate these, so that they run and show up in your email by themselves:

  1. Automate the process by creating an After Effects script to fill in the layout, add the items to the render queue, and render.
  2. Use Python to email yourself the photos after they’ve rendered.
  3. Crontab the Python files/programs to run at a certain time.

Setting Up the Project

I’m using Pycharm on a Mac, but the Mac part doesn’t matter for this part, but it will later on when we automate through scripts in After Effects.

Once you set Pycharm up, or whatever IDE you’re using, you have to add the libraries we are going to use to the project interpreter.

In Pycharm on Mac go to Pycharm, Preferences, Project Interpreter and click the + button to add.

On Windows it’s File, Settings, Project Interpreter and click the + button to add.

WEB SCRAPE THE INFORMATION FROM A SITE

I used beautifulsoup for this and it’s beautiful. It downloads the HTML from a site without opening up a browser and you sift through it for the info you want.

Look at Pic_01 above:

  • Line 1 is importing urllib3. This is to call out to the world wide web.
  • Line 2 is importing Beautiful Soup
  • Line 5 defines our url. It goes to weather.com to a city and to the 10 day forecast.
  • Line 7 makes a request to the web gods using the url.
  • Line 8 reads the page that we requested.
  • Line 9 closes the request.
  • Line 11 makes the page_soup variable and then use the soup() function of BeautifulSoup. That function passes in the html we want to read, page_html. Also, passes in “html.parser” and I believe this is the way in which you want to parse the data. I have never used anything but “html.parser” but if for some reason you want to parse it differently this might be a good place to do it.
  • Line 13 uses our html that is stored in page_soup and uses the find_all() function. That function passes in what element you want to find. In our case it’s a span. And then we pass in what class to look for. So we are searching for all ‘spans’ with the class name ‘date-time’. There are multiple so it puts it into a list called days.
  • Line 14 finds all ‘span’ with the class name ‘day-detail’ and puts them into a list called dates.
  • Line 15 finds all ‘td’ with the class name ‘description’ and puts them into a list called descriptions.
  • Line 16 finds all ‘td’ with the class name ‘temp’ and puts them into a list called temps.
  • Line 17 finds all ‘td’ with the class name ‘precip’ and puts them into a list called precips.
  • Line 18 uses find() instead of find_all() which is the same idea it just finds one item. This finds a ‘div’ with the class name ‘locations-title’.
  • Lines 20-23 create lists for us to use later while we are arranging our information.
  • Line 25-26, and 28 are JSON related. We’ll talk about that in the next step.
  • Line 30 loops through the ‘days’ list and names each individual element as ‘day’
  • Line 31 prints the ‘day.text’. This is just to see if we have all the information we are looking for.
  • Line 33-37 do the same as above, just with different lists.
  • Line 39-57 is a bit confusing to explain so I suggest you watch the video tutorial but basically the temperatures were formatted like this ’78°52°’ where the first number is the high and the second number is the low. To split those up we use the split() function as you can see in line 51. That then created 2 pieces of info and put them in a list. So ’78’ is temp[0] and ’52’ is temp[1]. Then we add the 0 index to the high list and the 1 index to the low list. The problem is that if you check the weather late in the day it no longer has a high temp, and it would be formatted like this ‘–52°’ where 52 is the low. Line 41-49 is taking care of this. It checks to see if the first two characters of the string are “–“, in the end it’s the same the high is appended to the high list and the low is appended to the low list.
  • Lines 59-60 do the same as 30 and 31.
  • Line 62-71 is taking and formatting the city and state.
  • Everything else is JSON related.

FORMAT IT CORRECTLY INTO A JSON FILE

We have to put the info into a JSON file in a certain way so that our After Effects template can read it.

In Pic_02:

  • Line 73-76 creates an empty JSON structure with 2 categories of “Days” and “City”
  • Line 78 declares a variable i=0.
  • Line 79 runs a loop as long as i < 10.
  • Line 90 increases i by 1 at the end of our loop.
  • Line 80 creates a blank list named days_info.
  • Right now all our data is spread out into different lists. We are going to put all that info into one list and append it to what will eventually go into our JSON file.
  • Lines 81-86 take the i index of all our lists and add it to the days_info list. For example, the 0 index of all our lists is the info for the first day, this loop goes through all of them and adds it to days_info list. Now all the information for day 1 is in the days_info list, not spread out anymore.
  • In line 91 we append the full days_info list to the days_output list.
  • After the loop finishes we have a full days_output list with the 10 day forecast. In line 95 we update the “Days” category of our outputJSON with days_output list. In line 96 we update the “City” category of our outputJSON with the city variable.
  • Line 100 is creating a file called weather2.json and it’s creating it in the same file as our python project. To save it somewhere else you have to have the full path.
  • Line 101 is putting our outputJSON that we just updated into that new file weather2.json.

CREATE A TEMPLATE IN AFTER EFFECTS

This part is almost impossible to explain through text, so I recommend you watch the full tutorial. Or at least the “Making a Template in AE” and the “Configuring Layers for JSON” parts of the video.

In After Effects we are going to create a 1:1 square comp that is going to be our background and comp that we will output.

After effects python api

Next, we create a composition about 140px or so tall and as wide as the background. We name this comp “1”. It looks like this:

All the information on here was scraped from the website and it comes from our JSON file.

When the comp named “1” is duplicated After Effects automatically gives it the name “2” and then “3” and so on.

We use that formula to extract the data from the JSON and put it into our graphic. I know, confusing. Watch the video tutorial.

For now, that is enough to get started making your own. There are next steps to take to fully automate this process and I mentioned them in the beginning of the post. I will be happy to make more videos and posts on how to do it, I just need to know people are actually interested first.

Thanks for reading.

I write these for humans to read. For humans to find my page on Google I need to appease the SEO gods. Please excuse the following lines as it is meant for the Google Gods. It’s either this or you have to read “automate content with python” sprinkled throughout the post where it has no business being, making you hate me. I hope you understand.

Automate Content with Python and After Effects – Create Automated Info-Graphics Tutorial

Automate Content with Python and After Effects – Create Automated Info-Graphics Tutorial

Automate Content with Python and After Effects – Create Automated Info-Graphics Tutorial

After

Automate Content with Python and After Effects – Create Automated Info-Graphics Tutorial

Automate Content with Python and After Effects – Create Automated Info-Graphics Tutorial

Latest version

Released:

asyncio wrapper for Adobe After Effects aerender

Project description

Render Adobe After Effects projects using Python

aerender is an asyncio wrapper over aerender (Adobe After Effects 2019)built and tested on Windows 10. It can be used to automate the rendering ofAfter Effects projects.

Install it

Usage example

  • To render just Comp 1 to a specified file:

aerender -help

Below you can see the -help output of aerender executable on Windows.

USAGE:

  1. aerender renders After Effects comps. The render may be performed eitherby an already running instance of AE or by a newly invoked instance. Bydefault, aerender will invoke a new instance of AE, even if one isalready running. To change this, see the -reuse flag below.

  2. aerender takes a series of optional arguments.

    Some are single flags, like -reuse. Some come in flag-argumentpairs, like -project project_path. And one comes in a triplet,-mem_usage image_cache_percent max_mem_percent.

  3. aerender with 0 arguments, or with any argument equaling -helpor -h, prints this usage message.

  4. The arguments are:

    • -h print this usage message

    • -help print this usage message

    • -reuse use this flag if you want to try and reusean already running instance of AE to perform therender. By default, aerender will launch a newinstance of After Effects, even if one is alreadyrunning. But, if AE is already running, and the-reuse flag is provided, then aerender willask the already running instance of AE to performthe render. Whenever aerender launches a newinstance of AE, it will tell AE to quit whenrendering is completed; otherwise, it will notquit AE. Also, the preferences will be writtento file upon quit when the -reuse flag isspecified; otherwise it will not be written.

    • -project project_pathwhere project_path is a file path or URIspecifying a project file to open.If none is provided, aerender will work with thecurrently open project.If no project is open and no project is provided,an error will result.

    • -teamproject project_namewhere project_name is a name of ateam project to open.

    • -comp comp_namewhere comp_name specifies a comp to be rendered.If the comp is in the render queue already, andin a queueable state, then (only) the firstqueueable instance of that comp on the renderqueue will be rendered. If the comp is in theproject but not in the render queue, then it willbe added to the render queue and rendered.If no -comp argument is provided, aerender willrender the entire render queue as is. In thiscase (no -comp), the only other arguments usedwill be -project, -log, -v, -mem_usage, and-close; the -RStemplate, -OMtemplate, -output,-s, -e, and -i arguments will be ignored.

    • -rqindex index_in_render_queuewhere index_in_render_queue specifies arender queue item to be rendered. Options that makesense when rendering a single render queue itemare available like with the -comp flag.

    • -RStemplate render_settings_templatewhere render_settings_templateis the name of a template to apply to the renderqueue item.If the template does not exist it isan error.Default is to use the render template alreadydefined for the item.

    • -OMtemplate output_module_templatewhere output_module_templateis the name of a template to apply to theoutput module. If the template does not existit is an error.Default is to use the template already definedfor the output module.

    • -output output_pathwhere output_path is a file path or URIspecifying the destination render file.Default is the path already in the project file.

    • -log logfile_pathwhere logfile_path is a file path or URIspecifying the location of the log file.Default is stdout.

    • -s start_framewhere start_frame is the first frame to render.Default is the start frame in the file.

    • -e end_framewhere end_frame is the last frame to render.Note, this is 'inclusive;' the final framewill be rendered.Default is the end frame in the file.

    • -i incrementwhere increment is the number of frames toadvance before rendering a new frame. A valueof 1 (the default) results in a normal renderingof all frames. Higher increments will repeat thesame (frame increment-1) times and then render anew one, starting the cycle again. Higher valuesresult in faster renders but choppier motion.Default is 1.

    • -mem_usage image_cache_percent max_mem_percentwhere image_cache_percent specifies the maximumpercent of memory used to cache already renderedimages/footage, and max_mem_percent specifiesthe total percent of memory that can beused by After Effects.

    • -v verbose_flagwhere verbose_flag specifies the type ofmessages reported. Possible values are ERRORS(prints only fatal and problem errors) orERRORS_AND_PROGRESS (prints progress of renderingas well).Default value is ERRORS_AND_PROGRESS.

    • -close close_flagwhere close_flag specifies whether or not toclose the project when done rendering, andwhether or not to save changes. If close_flag isDO_NOT_SAVE_CHANGES, project will be closedwithout saving changes. If close_flag isSAVE_CHANGES, project will be closed and changeswill be saved. If close_flag is DO_NOT_CLOSE theproject will be left open; but the project isleft open only if using an already-runninginstance of AE, since new invocations of AE mustalways close and quit when done.Default value is DO_NOT_SAVE_CHANGES.

    • -sound sound_flagwhere sound_flag specifies whether or not to playa sound when rendering is complete. Possiblevalues are 'ON' or 'OFF'.Default value is 'OFF'.

    • -versiondisplays the version number of aerender to theconsole. Does not render.

    • -continueOnMissingFootageDo not stop rendering on missing footage. Log andrender with placeholder color bars.

  5. EXAMPLES:To render just Comp 1 to a specified file:

    To render everything in the render queue as is in the project file:

    To render frames 1-10 using multi-machine render:

Release historyRelease notifications | RSS feed

Ae Tutorial Video

0.1.3

0.1.2

After Effects Scripting

0.1.1

0.1.0

Download files

Python

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aerender, version 0.1.3
Filename, sizeFile typePython versionUpload dateHashes
Filename, size aerender-0.1.3.tar.gz (8.7 kB) File type Source Python version None Upload dateHashes

After Effects Python

Close

After Effects Python Free

Hashes for aerender-0.1.3.tar.gz

Aescripts

Hashes for aerender-0.1.3.tar.gz
AlgorithmHash digest
SHA256b4b84b03e67443256c622f77fb5dc6fb439501f048cc4e4276a88800088d7ca2
MD5e1953e0f477f297fa6fdfba8c1708139
BLAKE2-2568d15a32f4cfe59b3731b41af4160fac5de631de3c0af18bc1548d612e68d95a5