From: André Cruz <andre.c...@co.sapo.pt> This is derived from the Matrix Structure metadata in the tkhd atom.
Based on contributions by Dave Badia <dba...@gmail.com> and Piotr Tomasik <pi...@tomasik.co>. Fixes Bug 595. Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com> --- Cleaned up patch. Vittorio libavformat/mov.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 9b019e1..f468ead 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2256,6 +2256,17 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->width = width >> 16; sc->height = height >> 16; + // Assign clockwise rotation values based on transform matrix so that + // we can compensate for iPhone orientation during capture. + if (display_matrix[1][0] == -65536 && display_matrix[0][1] == 65536) + av_dict_set(&st->metadata, "rotatation", "90", 0); + + if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) + av_dict_set(&st->metadata, "rotatation", "180", 0); + + if (display_matrix[1][0] == 65536 && display_matrix[0][1] == -65536) + av_dict_set(&st->metadata, "rotatation", "270", 0); + // transform the display width/height according to the matrix // skip this if the display matrix is the default identity matrix // or if it is rotating the picture, ex iPhone 3GS -- 1.7.9.5 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel