Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Mp4 files (and many others) use the <a href="http://en.wikipedia.org/wiki/MPEG-4" rel="noreferrer" title="MPEG-4">MPEG-4</a> standard, which arranges the data inside it in little boxes called atoms. You can find a great description of atoms in this <a href="http://atomicparsley.sourceforge.net/mpeg-4files.html" rel="noreferrer" title="page">Page</a>. In short, atoms are organized in a tree like structure, where an atom can be either the parent of other atoms or a container of data, but not both (although some people break this rule)</p> <p>In particular the atom you are looking for is called "tkhd" (Track Header). You can find a list of atoms <a href="http://www.mp4ra.org/atoms.html" rel="noreferrer">here</a>. </p> <p>Within this atom you will find metadata of the video. The structure of the "tkhd" atom is specified <a href="http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-SW1" rel="noreferrer">here</a></p> <p>Finally the chunk of metadata you need (which is not an atom), is called "Matrix Structure". From <a href="http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737" rel="noreferrer">developer.apple.com</a>: </p> <blockquote> <p>All values in the matrix are 32-bit fixed-point numbers divided as 16.16, except for the {u, v, w} column, which contains 32-bit fixed-point numbers divided as 2.30.</p> </blockquote> <p>This is shown in the following image:</p> <p><img src="https://i.stack.imgur.com/tW0De.gif" alt="&quot;Matrix Structure&quot; a transformation matrix"></p> <p>The 9 byte matrix starts in byte 48 of the "tkhd" atom. An example of a "matrix structure" for an orientation of 0° would be 1 0 0 0 1 0 0 0 1 (the identity matrix)</p> <p>SO!</p> <p>After all that, what you need is to modify this matrix. The next parragraph is taken from <a href="http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737" rel="noreferrer">developer.apple.com</a>: </p> <blockquote> <p>A transformation matrix defines how to map points from one coordinate space into another coordinate space. By modifying the contents of a transformation matrix, you can perform several standard graphics display operations, including translation, rotation, and scaling. The matrix used to accomplish two-dimensional transformations is described mathematically by a 3-by-3 matrix.</p> </blockquote> <p>This means that the transformation matrix defines a function, that maps each coordinate into a new one.</p> <p>Since you only need to rotate the image, simply modify the left most 2 x 3 matrix, which is defined by the bytes 0, 1, 3, 4, 6 and 7.</p> <p>Here are the 2 x 3 matrices I use to represent each orientation (values 0, 1, 3, 4, 6 and 7 of the 3x3 matrix):</p> <p><strong>0°:</strong> (x', y') = (x, y)<br> 1 0<br> 0 1<br> 0 0</p> <p><strong>90°:</strong> (x', y') = (height - y, x)<br> 0 1<br> -1 0<br> height 0</p> <p><strong>180°:</strong> (x', y') = (widht - x, height - y)<br> -1 0<br> 0 -1<br> width height</p> <p><strong>270°:</strong> (x', y') = (y, width - x)<br> 0 -1<br> 1 0<br> 0 width</p> <p>If you don't have them, the width and height can be obtained just after the matrix structure. They are also fixed point numbers of 4 bytes (16.16).</p> <p>It is quite probable your video metadata contains the 90° Matrix </p> <p>(Thanks to Phil Harvey, creator of <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/" rel="noreferrer">Exiftool</a> for his help and a wonderful software)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload