From 5f4aef110890a9c1b56b199ff8cecaf07812ef97 Mon Sep 17 00:00:00 2001 From: "ji.yong.seo" Date: Thu, 21 Jan 2016 13:26:21 +0900 Subject: [PATCH] fix get rotate at time fail. (ffmpeg 2.5 merge) Change-Id: I2484409b69a3398b309d0faecd9f82521af71179 Signed-off-by: ji.yong.seo --- libavformat/mov.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index d2bb6e2..2c6ebb1 100755 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -31,6 +31,7 @@ #include "libavutil/attributes.h" #include "libavutil/channel_layout.h" +#include "libavutil/display.h" #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "libavutil/mathematics.h" @@ -2453,6 +2454,7 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) display_matrix[1][0] || display_matrix[1][2] || display_matrix[2][0] || display_matrix[2][1]) { int i, j; + double rotate; av_freep(&sc->display_matrix); sc->display_matrix = av_malloc(sizeof(int32_t) * 9); @@ -2462,6 +2464,16 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) sc->display_matrix[i * 3 + j] = display_matrix[j][i]; + + rotate = av_display_rotation_get(sc->display_matrix); + if (!isnan(rotate)) { + char rotate_buf[64]; + rotate = -rotate; + if (rotate < 0) // for backward compatibility + rotate += 360; + snprintf(rotate_buf, sizeof(rotate_buf), "%g", rotate); + av_dict_set(&st->metadata, "rotate", rotate_buf, 0); + } } // transform the display width/height according to the matrix -- 2.7.4