Answers.Body: <p>Have you tried using after effects? You can get a demo, it will give you an idea of the metaphor behind it.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-19T16:11:36.093Z
Answers.Text: 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.
Answers.UserDisplayName: Jim DeLaHunt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-20T00:55:18.653Z
Answers.Text: Did the rest of the answer provide enough information? Whatever you're doing sounds interesting.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-20T22:56:18.933Z
Answers.Text: 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.
Answers.UserDisplayName: Jim DeLaHunt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-19T12:05:43.763Z
Answers.LastActivityDate: 2018-05-19T12:05:43.763Z
Answers.UserDisplayName: stib
Body: <p>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.</p>
  
  <p>The file looks like this:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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 <code>Transform Position</code> values are absolute or relative motions, or how they are affected by the <code>Transform Scale</code> values, or if they are in terms of input frame coordinates or output frame coordinates.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-19T12:03:49.960Z
Comments.Text: 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?
Comments.UserDisplayName: Jason Conrad
Tags: <after-effects><animation-rendering><keyframes>
Title: What is algebraic effect of transforms in Adobe After Effects Keyframe Data file?
UserDisplayName: Jim DeLaHunt
ThreadText: # What is algebraic effect of transforms in Adobe After Effects Keyframe Data file?
  
  (Asked by: username_0 on 2018-05-18)
  
  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?
  
  **Tags:** after-effects, animation-rendering, keyframes
  
  > **Comments:**
  > **username_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?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-05-19. Score: 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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_2**: Did the rest of the answer provide enough information? Whatever you're doing sounds interesting.  
  > **username_0**: 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.  
  
  ---
  
  