Right now ffmpeg doesn't export a mirroring status when checking the
display matrix for rotation.
Here is an example video: https://files.tedm.io/flip.mp4
-Ted
From 7121cecdd54f403cb857dbfd056ca22253d6948a Mon Sep 17 00:00:00 2001
From: Ted Meyer <tmathme...@chromium.org>
Date: Thu, 16 May 2019 14:17:51 -0700
Subject: [PATCH 1/1] Export display matrix mirroring information
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

normally a display matrix will look like:
[ cos(Θ), -sin(Θ), ...]
[ sin(Θ),  cos(Θ), ...]
[ ...,     ...,    ...]
but switching the signs can be used to imply a mirroring effect.
If the cosine values are of a different sign, then there is a
mirroring about the y-axis, and if the sine values are the same
sign, but non-zero, then there is a mirroring about the x-axis.

Signed-off-by: Ted Meyer <tmathme...@chromium.org>
---
 libavformat/mov.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index e40bcf3b86..b8748ee374 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4560,6 +4560,16 @@ static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             snprintf(rotate_buf, sizeof(rotate_buf), "%g", rotate);
             av_dict_set(&st->metadata, "rotate", rotate_buf, 0);
         }
+
+        if (sc->display_matrix[0] != sc->display_matrix[4]) {
+            av_dict_set(&st->metadata, "mirror-y", "yes", 0);
+        }
+
+        // non-mirrored matricies have differing signs - except 0
+        if (sc->display_matrix[1] == sc->display_matrix[3] &&
+            sc->display_matrix[1] != 0) {
+            av_dict_set(&st->metadata, "mirror-x", "yes", 0);
+        }
 #endif
     }
 
-- 
2.21.0.1020.gf2820cf01a-goog

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to