[FFmpeg-devel] [PATCH] Extract rotation in MOV metadata
Dave Badia
dbadia at gmail.com
Sat Mar 26 11:31:22 CET 2011
Interrogate MOV metadata for orientation of video so that software can
determine if the video needs to be rotated for proper display.
---
libavformat/isom.h | 1 +
libavformat/mov.c | 5 +++++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 1df666f..dde1ba1 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -123,6 +123,7 @@ typedef struct MOVStreamContext {
int width; ///< tkhd width
int height; ///< tkhd height
int dts_shift; ///< dts shift when ctts is negative
+ int rotation; ///< rotation 0 if normal, 180 if inverted
} MOVStreamContext;
typedef struct MOVContext {
diff --git a/libavformat/mov.c b/libavformat/mov.c
index e9435a9..7faa225 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1907,6 +1907,11 @@ static int mov_read_tkhd(MOVContext *c,
AVIOContext *pb, MOVAtom atom)
sc->width = width >> 16;
sc->height = height >> 16;
+ if(display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) {
+ sc->rotation = 180;
+ }
+
+
// 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
More information about the ffmpeg-devel
mailing list