[FFmpeg-devel] [PATCH] Extract rotation in MOV metadata

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Apr 30 01:22:32 CEST 2011


On date Saturday 2011-04-30 01:09:15 +0200, Jean-Daniel Dupas encoded:
> 
> Le 30 avr. 2011 à 00:55, Stefano Sabatini a écrit :
> 
> > On date Tuesday 2011-04-05 16:53:32 -0700, Baptiste Coudurier encoded:
> >> Hi Dave,
> >> 
> >> On 04/05/2011 04:49 PM, Dave Badia wrote:
> > [...]
> >>> Interrogate MOV metadata for orientation of video so that software can
> >>> determine if the video needs to be rotated.
> >>> ---
> >>> libavformat/mov.c |    4 ++++
> >>> 1 files changed, 4 insertions(+), 0 deletions(-)
> >>> 
> >>> diff --git a/libavformat/mov.c b/libavformat/mov.c
> >>> index 23ba1d4..b12890f 100644
> >>> --- a/libavformat/mov.c
> >>> +++ b/libavformat/mov.c
> >>> @@ -1907,6 +1907,10 @@ 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) {
> >>> +         av_metadata_set2(&c->fc->metadata, "rotate", "180", 0);
> >>> +    }
> > 
> > It was already said, but why such a specific check? IMO it would much
> > more useful to export the rotation information (e.g. 90, 180,
> > etc.). Which are the acceptable rotation values?
> > 
> > Also, how should we export this information to the application level
> > (e.g. for auto-inserting a corresponding rotation filter at the begin
> > of the filterchain)?
> 
> If your goal is to apply a filter based on the track matrix, I don't
> understand what the point of extracting the rotation only.
> It would be easier to extract the whole matrix, and write an 'affine
> transform' filter to apply the matrix instead of bothering with
> rotation, which is just a special case of affine transform.

> If the track matrix specifies a rotation, a translation, and a scaling, applying only one transform will be wrong anyway.

Yes, now the point is how to expose this MOV specific affine transform
matrix to AVStream/to the application level.
-- 
FFmpeg = Fundamental & Fabulous Magical Prodigious Erroneous Gnome


More information about the ffmpeg-devel mailing list