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?