2

I want to write software which peforms a pan, zoom, rotate, and resample on a 3840x2160 input video, yielding a 960x540 output video. I have an keyframe data file, exported from Adobe After Effects, which specifies the pans, zoom, and rotate actions I want, in terms of key frames. I could let Adobe After Effects render the output video, but instead I want my own software to do this part.

The file looks like this:

Adobe After Effects 8.0 Keyframe Data

    Units Per Second    29.97
    Source Width    3840
    Source Height   2160
    Source Pixel Aspect Ratio   1
    Comp Pixel Aspect Ratio 1

Transform   Scale
    Frame   X percent   Y percent   Z percent   
    0   200 200 0   
    150 300 300 0   
Transform   Anchor Point
    Frame   X pixels    Y pixels    Z pixels    
        1920    1080    0   

Transform   Position
    Frame   X pixels    Y pixels    Z pixels    
    0   480 270 0   
    150 -4800.88    2356.12 0   

Transform   Rotation
    Frame   degrees 
    150 30  

End of Keyframe Data

I don't understand the algebraic relationship between pixel coordinates in the input video frame and pixel coordinates in the output video frame, in terms of the keyframe data in this file. I understand translate, scale, and rotate operations in the abstract, as linear transformations. I don't understand, for example, if the Transform Position values are absolute or relative motions, or how they are affected by the Transform Scale values, or if they are in terms of input frame coordinates or output frame coordinates.

I realise that the actual transformation is based on per-frame values interpolated between these keyframes. I think that's not a problem for me.

What is the algebraic relationship between pixel coordinates relative to the input video frame, and pixel coordinates relative to the output frame, for a frame described by the keyframe, given the width and height of input and output, and the values in the Adobe After Effects Keyframe Data file?

1
  • I never really got that far in my math studies, but I think that whenever you're talking about 3-dimensional transformations (whether xyz, psr, ptz, rgb, or whatever), you're talking about matrices and linear algebra. So maybe take a class on that? May 19, 2018 at 12:03

1 Answer 1

0

Have you tried using after effects? You can get a demo, it will give you an idea of the metaphor behind it.

The position of a layer is the position of its anchor point in the comp space. The anchor point is expressed in terms of the layer space and is the point that the layer rotates around and scales from. By default the anchor point of a layer is its center. In both layer space and comp space the origin [0,0] is the top left, and increasing values move the point to the right and down. E.g. for a 1920x1080 comp / layer the point [1920,1080] is the bottom right.

3
  • Thank you for the suggestion. I have sat down with Adobe After Effects and played with the controls. Your description of the UI metaphor matches what I observed. But an "idea of" the relationship isn't precise enough to write code. May 19, 2018 at 16:11
  • Did the rest of the answer provide enough information? Whatever you're doing sounds interesting.
    – stib
    May 20, 2018 at 0:55
  • This answer isn't enough for my purposes. I sat down with affine transformation matrices and did some simple matrix algebra. I think I have the equations now. I will post them once I have good Internet connectivity. May 20, 2018 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.