After Effects To Blender 2.70a Javascript Python Generator

I have changed the script to make the camera move up instead of down. (redownoad from link on first post)

Your After Effects scenes do point out that the camera and z-distance calculations are off. I am not sure how to correct it at this time.

When I made the 2.49 version of this script I simply cloned an existing exporter that supported Maya, Max and Lightwave. Lightwave was the closest match at that time. So the camera math is essentially for lightwave. I made this script public with the hope that someone a bit more savy on calculations might be able to offer up some suggestions. But all I can offer at this time is to say ā€œplay with the camera sensor size and focal lengthā€.

I have wanted to revisit the concept of how to implement a Blender unit in After Effects I just have not had the time.

Thank you for the update :slight_smile: I understand that youā€™re busy, thatā€™s what makes me thankful even more :wink: I often think that many people posting here (or in other places, doing regular tutorials, writing free plugins, scripts etc.) are almost like superheroes :wink:

I wish I could help more. Thereā€™s one more thing that comes to my mind - I had a chance to check PFHoe by Pixel Farm (it was the cheapest tracking solution at one moment) in the past and it had the ability to export script files for Blender 2.49. There were feature requests on their forum to update for 2.5 but they havenā€™t done it so far. This software is now discontinued so I think thatā€™s it. But maybe there is something in the code that PFHoe was producing which could help here. I donā€™t know, maybe itā€™s AE problem. If you want to look into the code hereā€™s an example script file I got some time ago:

Itā€™s for 2.49 however, so I possibly itā€™s useless. Thanks again :wink:

This is awesome!

Iā€™m trying to export a panning camera from AE CS6 but the Blender camera is off-kilter for me too.

I attached the AE file. Can you figure this out?

Thanks.

Attachments

AE_Track2.zip (48.3 KB)

Well, Atom said the script is not finished, updating it would take much time. I guess we just have to wait, maybe somebody comes up with a solution. I really need that functionality too. Someday weā€™ll get there.
Atom, if youā€™re reading this - have you archived the old version somewhere? The one which was working with blender 2.49? I googled like crazy but all the links are dead. We can still use it, save the file then open in new Blender. I thinks itā€™s a good workaround for now. Thanks :slight_smile:

Iā€™d gladly help with this script, but Iā€™m not good enough with jsx. I tried to go through this several times and gave up.
I think that the math here is a bit too complex and conversion can be done easier. For example I noticed that angles are used to convert AEā€™s lens to blenderā€™s lens. This is not necessary. Iā€™m sure about it, because I made all the calculations myself for the exporter from Blender to AE which is included in Blender. I didnā€™t at all use angles and everything sits precisely where it should.
I can do all the math, but I would have problems implementing it into existing script that I donā€™t quite understand.

Wow! Bartek Skorupa and Atom in one thread :slight_smile: Iā€™m crazy about using two-way workflow between Blender and After Effects so your script Bartek is just sooooo useful. Now we need the other half :wink: Iā€™ve used the contact form on your website some time ago to ask you about any solutions but I donā€™t know if the form is working. Do you remember getting my message? If you didnā€™t have time to answer no problem - weā€™re all so busy these days.
Back to the topic - I donā€™t have any programming skills, Iā€™m just a user that needs some features, so I cannot really help. I can test, I can feedback. I really think we need those scripts, tracking in AE is just so easy and fast (if thereā€™s a problem we can use the Foundryā€™s plugin which helps even more). It would be great to take that data into Blender.
Bartek - Iā€™ve published in this thread an old code exported from PFhoe. It was a cheap tracking software which could export data to Blender. It was Blender 2.49, however, so I donā€™t know how useful is this data.

I am willing to field questions for the parts of the code that are confusing. Remember, I built this from an existing working exporter for Maya, Max and Light Wave. So some math conversions for the camera may have been needed for those applications.

collectValueAtCurrentTime_XZY_Camera is where all animations data that will be written out for the camera is collected, calculated and returned to the caller. Put override values here to test your ability to alter the output stream.

Also getFLenOrFOVorZFacFromZoom has some math I do not understand.

You can ignore anything related to Masking at this time. It was a work in progress even in the 2.49 script. I left some code in there so I would not have to look it up again.

I wrote a javscript version of our beloved python dir() function and it is available in the script. It is called pythonDIR (). If you want to examine a javascript variable you can pass it to pythonDir and it will try to return a string of attributes like dir. You can pass the results to a javascript alert() function to popup a message box with that variables attributes.
Usage:


myStr = pythonDir(unknownVar);
alert(myStr);

Be warned not to leave an alert inside a loop, there is no way to stop a javascript once it is lanuched under After Effects.

Thanks for working on this. Iā€™ve been using AE CS6, which has built in 3D camera tracking that works quite well, not to mention easily and quickly. Iā€™d love to be able to build my composition in AE, and export a camera and some nulls to Blender in order to create some 3D text or objects with Cycles rendering.

Life saving thing. Good Work!

@loogas: Sorry for the late reply, but I am finally looking back into making this script work better. After some research I realize that the script is missing the sensor size for your footage. While the script can look at the After Effects camera sensor size, it canā€™t really know what sensor size the footage was shot with. Do you happen to know what camera was used to for the footage you have posted? If so, it might be possible to simply set the After Effects lens and sensor size to match the lens and sensor of the camera that shot your footage.

Thank you Atom for any effort any time :slight_smile: For my footage I use Canon 550d but in the one posted Canon 5d Mark II was used, here are the specs: http://www.dpreview.com/products/canon/slrs/canon_eos5dmkii

As a side note (if you happen to have some time to read it ;)):
Iā€™ve been checking online tutorials to look into camera ā€œinterchangeabilityā€ between different packages - 3dmsax, maya, pftrack, nuke, after effects, cinema4d - and this functionality is there. I wonder how they achieved in on the coding side. I mean you donā€™t even have to know what was the camera that the footage was shot with etc.

I donā€™t know how many people would need this functionality in Blender but something like this was a major feature in the last 3dsmax (you can import whole scene data into AE and back) and is being advertised for the upcoming update of AE (great interoperability with Cinema 4d). I really donā€™t want to leave Blender and learn another package, all over again :wink:

Thanks again Atom! :slight_smile:

Thanks for the info, I see the Canon is a 36mm x 24mm sensor now. I was digging around in the After Effects javascript API and I just canā€™t find any reference to the sensor size, after the camera is created in After Effects. All you have is zoom and FOV. I have a math request posted on aenhancers.com and hope someone chimes in. But I think for worst case scenario, the exporter can still work for motion graphics even if the camera is off for footage tracking. I was looking into Bartek Skorupaā€™s exporter code hoping to reverse engineer his camera export, but it is still a work-in-progress.

wow, this is awesome! couldnā€™t get it to work in blender 2.66, but it works perfectly in 2.63ā€¦

this is just what i needed right now! thank you atom!!

Woah, coolā€¦ I canā€™t wait to see what comes of this

Now if only premiere was more compatible with After Effects. Premiere -> Blender would be awesome

Hi All,

I have revised the After Effects To Blender exporter to update it for Blender 2.6.6 api changes.

Instead of trying to match the camera to one type of footage or lens I decided to match the After Effects Camera to Bartek Skorupaā€™s Blender To After Effects Export script. I think this makes the most sense for us Blender users because it is in the official release of Blender. The CS5 version of this javascript will now reliably transfer a camera back to Blender with the lens settings matching Bartekā€™s Exporter. So you can export using Bartekā€™s script to After Effects, make changes and send it back to Blender with this CS5 version of the javascript and there should be no camera distortion. This should give more confidence to the two-way pipeline from Blender to After Effects and back to Blender for Motionographers.

As far as tracking and camera matching tasks, however, we are still in untested waters.

For example I noticed that angles are used to convert AEā€™s lens to blenderā€™s lens. This is not necessary.

@Bartek: Thanks for the tip, I have revised the lens zoom calculation with a magic # that seems to match your export code for tested camera zooms. I transfered 5 cameras with different zoom values from Blender2AE2Blender without any distortion to the lens or LOC/ROT of the cameras.

There is a lot of math in the exporter that I donā€™t understand either, having taken it from the Maya/Max/Lightwave exporter years ago. Internally I think the original authors of that script turned After Effects zoom values in to radians for internal calculations and thus it needs converted back for final output.

"ca.lens = " + radiansToDegrees(G.CAMERA_ZOOM) / 6.3662  // Magic #

@Atom: Letā€™s assume that I do all the math. If I do it and give you all the formulas, would you be able to implement this in your exporter?

Letā€™s say I give you data like this:

location.x = AE_position_x * something minus something else plus comp_width
location.y = blabliblebli.

When it comes to camera data, Iā€™d assume using default camera settings (I mean sensor, ā€œfitā€ etc.) and match all the math to those settings.
Math here should be easy. Iā€™d assume that we have the access to ā€œzoomā€ value in AE. If so - I can easily create a proper equation, like:

blender_lens = comp_width * something minus something times zoom.

Will it help?
Maybe this way we could somehow ignore all those crazy ā€œRadiansToDegreesToRadiansAgainToAnythingElseThatIsNotNeededā€ stuff?

There are still some things going on in the javascript exporter that I am not sure about (like layers being created on-the-fly and then discarded). So Iā€™d rather not try to fix something until it is broken. At this point all we need is more testing to identify any camera cases, if any, that are still not working.

I agree the javascript code I present is cluttered and messy. I left a lot of experimental code in the script, but commented out, hoping to return to it when I get more time. Mainly I do think it is possible to extract mask information in After Effects and translate it into curve objects inside Blender. However, my adventures into trying to extract particle data from Particular have lead to a deadend due to Trapcodeā€™s failure to expose properties to the After Effects API.

Itā€™s nice to see youā€™re still trying to figure things out guys :slight_smile:

Well, the only thing I can do to help is to keep testing, so I did. Itā€™s better but still something is off.

First of all, you have to know I didnā€™t export anything from Blender, then back to Blender. Iā€™ve used a situation I face almost every day - Iā€™ve tracked the footage inside AE (fast track, not fully tested), created a scene, a camera and some 3d solids for reference.
Letā€™s say I want to take this to Blender (itā€™s an unused shot from a tornadoes and destruction music video I did a while ago), add stuff to the ground, the building in the background, and then render to compose in AE.

Iā€™ve run the script (I hope Iā€™ve used the correct version, the bottom one from the first page of this thread: ATOM_AE2Blender26_04162013.jsx) in CS6 and CS5. Then I tried to use the resulting .py files in Blender 2.66a - it doesnā€™t work, some error. But this doesnā€™t matter - we cannot expect Atom to keep updating it all the time :wink: Iā€™ve run it in Blender 2.63a and here it works, it creates the scene and stuff. The camera seems to be shifted in its position to the right. Whatā€™s more, if I use the ouput from CS6, the camera is below the ground (but again, letā€™s leave CS6 for now, if it works at least in CS5 thatā€™s gonna be great).
I thought first that maybe camera parenting to a scene-controlling null is a problem, but if you unparent it so it displays itā€™s true position in space and then export, you get the same result.

Here are some screengrabs:

CS5 scene:


CS5 to Blender 2.63a result:


CS6 to Blender 2.63a result:


I hope this doesnā€™t discourage you Atom (and Bartek ;)). Zhajym reported it works for him - could you tell us more? Have you created a scene in Blender, went to AE, then back to Blender, or it all started in AE?

If you need the scene and my files to look into them, like with the previous case youā€™ve checked, you can find them here:

By the way:

Even though I donā€™t like marketing mumbo jumbo about how great the dynamic link between AE and Premiere is (it can fail you in some really demanding situations) it usually works nice, so what do you mean Veggiet by saying that AE is not compatible with Premiere? They work great together. Premiere is and editing software - why would you like to export to Blender? Or maybe youā€™re talking about Blenderā€™s sequencer, not 3d space? That would be a completely different matter :wink:

Thanks for the test files, verified, the script does not work. I just donā€™t know enough about the math to make the camera work correctly. The objects seem to be in the correct location. But the camera is just fracked.

No problem. Thanks for coming back to this - maybe some solution will come up eventually. By the way - do you still have the older version of your script which worked for Blender 2.49 and AE CS3? All links are dead but I think it could be used as workaround for now. Thanks in advance :wink: