Camera data from Adobe After Effects

Is there a way to import camera movement from Adobe After Effects? If not, can Blender export camera data to After Effects? It does not even have to be camera movement per se. I could use object data for an object the camera was parented to. I’m primarily concerned with panning, not focus or zoom.

You can try my exporter here:
http://www.sharecg.com/v/32616/Script/Export-After-Effects-Camera-To-Blender

Open up your scene in After Effects then select your camera. Run the script and choose Blender for your output type. This will generate a python file that you can then load into Blender and execute. After the python file executes, you will have an animated camera in your Blender scene that more-or-less matches what you had in After Effects. You can also select other layer types in After Effects as well. The script will convert Text layers to true 3D font objects. Solids with masks will transfer as well.

It may not be pixel perfect, but it might help you out.

Thank you, Atom. This seemed to work in After Effects CS3, even with the problems pointed out at AE Enhancers. However, when I tried to run the data in Blender, I was prompted with “syntax error”. My AE camera is controlled by a parent null object, which should be OK per the associated notes. What should I look for? It looks like I’m running Python 2.3 and Blender 2.4.7.

I’m using a Mac with OS 10.4.11

It is a Mac bug. After Effects on a Mac will not output the correct LFCR character sequence. Then when you import the python file it all comes in on one line. The data is there. You can manually put line feeds into the python script in Blender and it will work. Success depends on how badly you need to get your camera into Blender?

I have posted on AEnhancers and posted a bug in Blender as well. It might be a Blender Mac only bug. Presently I have no solution other than hand editing the python code as I mentioned above. I even tried BEdit to see if that robust editor could fix the dang file.

Sorry to disappoint.

I did notice that the script came into Blender on one line, and that there was a note about a Mac problem at AE Enhancers. Oddly, this morning when I reopened Blender, I could click back on the previously loaded scrips and the AE camera output was now displaying more appropriately in the Blender text editor; no longer in one line but tabbed and arranged in paragraphs. I haven’t tested this because I eyeballed the camera move over a test render yesterday. I’ll check it later though.

My skills are mostly oriented toward illustration and 2D, so I really appreciate the help when I do find a need for 3D. And, thankfully Blender is more strait forward than apps. like Maya.

Wow, I was wondering if this was possible today, so the script may be very helpful…BUT what about exporting camera data from Blender to AE?

Jeremiah

P.S. First time to post here, known about the forum a while, but just signed up.

There are a couple of script floating around to go from Blender to After Effects.

Here is one I used that creates clipboard data in the AE format. Simply copy the output from this script to the clipboard and then do a paste to the Camera in AE.


import Blender as B

scn = B.Scene.GetCurrent()
context = scn.getRenderingContext()

SizeX = float(context.sizeX)
SizeY = float(context.sizeY)
AspectX = float(context.aspectRatioX())
AspectY = float(context.aspectRatioY())
Aspect = AspectX / AspectY
FrameRate = context.fps

startframe = context.startFrame()
endframe = context.endFrame()


def get_BlenderCamData():
    obs = B.Object.GetSelected()
    locations = []
    rotations = []
    for i in obs:
        if i.getType() == 'Camera':
            mat = i.mat        
            for frame in range(startframe,endframe+1):
                B.Set('curframe', frame)
                x = mat.translationPart().x
                y = mat.translationPart().y
                z = mat.translationPart().z
                rx = mat.toEuler().x
                ry = mat.toEuler().y
                rz = mat.toEuler().z
                loc = ('%.3f' % x,'%.3f' % y,'%.3f' % z)
                rot = ('%.3f' % rx, '%.3f' % ry, '%.3f' % rz)
                locations.append(loc)
                rotations.append(rot)
        else:
            print i.getType(), ' not supported'
    return locations, rotations

def blender2AE(bloc,brot):
    aloc,arot = [],[]
    for i, xyz in enumerate(bloc):
        # Works for 720x576 with a 50° Camera-Lens
        # y and z switch places and y-axis is negativ
        x = (float(xyz[0])*130)+SizeX/2
        y = -1*(float(xyz[2])*137)+(SizeY/2)
        z = float(xyz[1])*137
        # Not tested yet
        rx = 0 #float(xyz[0])
        ry = 0 #float(xyz[2])
        rz = 0 #float(xyz[1])
        loc = ('%.3f' % x,'%.3f' % y,'%.3f' % z)
        rot = ('%.3f' % rx, '%.3f' % ry, '%.3f' % rz)
        aloc.append(loc)
        arot.append(rot)
    return aloc,arot

def write_file(aloc,arot):
    #    File writing starts HERE!
    File = open ('AfterEffectsExporter.txt','w')
    #    The header
    File.write ('Adobe After Effects 7.0 Keyframe Data

\
    Units Per Second    %i
\
    Source Width    %i
\
    Source Height    %i
\
    Source Pixel Aspect Ratio    %.4f
\
    Comp Pixel Aspect Ratio    %.4f
\
'%(FrameRate, SizeX, SizeY, Aspect, Aspect))

    # Loc and Rot values are writen in an entirely diferent way, how clever...

    #    Write Loc values -----------------------------------
    File.write ('
Transform    Position
\
    Frame    X pixels    Y pixels    Z pixels')

    for i, xyz in enumerate(aloc):
        File.write ('
	%i	%f	%f	%f	' % (i+1,float(xyz[0]),float(xyz[1]),float(xyz[2])))

    #    Write Rot values -----------------------------------

    #    Z values
    File.write('

Transform	Rotation
	Frame	degrees')
    for i,xyz in enumerate(arot):
        File.write('
	%i	%f' % (i+1, float(xyz[2])))

    #    X values
    File.write('

Transform	X Rotation
	Frame	degrees')
    for i,xyz in enumerate(arot):
        File.write('
	%i	%f' % (i+1, float(xyz[0])))

    #    Y values
    File.write('

Transform	Y Rotation
	Frame	degrees')
    for i,xyz in enumerate(arot):
        File.write('
	%i	%f' % (i+1, float(xyz[1])))

    #    THE END -----------------------------------
    File.write('


End of Keyframe Data
')


def main():
    bloc, brot = get_BlenderCamData()
    aloc, arot = blender2AE(bloc,brot)
    write_file(aloc,arot)
    print "
Exporting Done!
Your file is located in \
Blender's root folder, now send bug reports to ZanQdo and/or knekke"

main()

This is great,
I was just trying to get Icarus 3d motion tracking to work to day and it said I needed an older version of blender to run the script,

Thanks for the help guys,

P.S. JWlane, I am a Tennessee native as well, hour south of nashville

I imported the scrip into Blender, but could not get it to run…(Alt+P).

jeremiahjw,

little help here…which script?
Did you get any errors?

I just got this bug confimation email from Ton today!
http://projects.blender.org/tracker/?func=detail&atid=264&aid=18397&group_id=9

It is a bug in the editor of the Mac version of Blender that causes all the text to stay on one line. Yeah! it’s ging to get fixed!

The script I had problems with is the one that exports Blender camera movement to After Effects. I hit Alt+P and nothing happened.

It you read the console after running the script it tells you that your file has been created in the root folder where you run Blender. The text file is called “AfterEffectsExporter.txt”. Open that text document, select it all and copy it to the clipboard. Then open After Effects and select the camera and do a paste.

Ok, I found the file. When I copy the text in the file and tried to paste it to my camera (edit-paste in AE window) the “paste” option is grayed out. I’m using a 3D camera, and AE CS4.

Jeremiah

Thanks for the script, yah i got the same errror, but i think there’s a solution that may works.

  1. Open the file.py (AE camera info) with OpenOffice .
  2. Copy and paste the text to Blender Text Editor.
    Now text will be tabbed and arranged in paragraphs correctly.
  3. Run python Script.

It works in Mac OSX v.10.5.2, AE 8.0.2.27, OpenOffic.org 3.0.0 Beta

You have to select the camera layer in the comp window. If that does not work, try selecting the position track of the camera itself and do a paste (it has been a while since I did this).

Actually, simply open the file.py with OpenOffice, Select all text and copy to blender text editor, the text can be arranged and tabbed correctly. It works on mac 10.56 and AAE 8.02.

I apologize if you have already found the solution to the Mac/Blender script bug you have here, but I have discovered a very simple soultion for the problem. If you open the py file created by the script in a text editor like Text Wrangler, you can change the document options to “Windows (CRLF)” instead of “Mac (CR)” Save the file and open the script in Blender…VOILA!! It works like it should.

I used Text Wrangler on the Mac to open the script file and went to “Edit > Document Options” and changed the Line Endings to Windows (CRLF), saved the file and imported perfectly to Blender. Not sure if BBedit gives you that option, but in researching the issue, the CRLF issue is what needs to be addressed.

tank you >> Atom for every thing …

but I Tested this script … it give me these Message :

Python script fail, look console for now …

location :<unknown location>:-1

SyntaxError : invalid syntax

Print “Atom’s After Effects Project converter!”
File “\xxxxx.py”, Line xxxx


Pls Help me