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

Michael Niedermayer michaelni at gmx.at
Thu Apr 7 15:53:27 CEST 2011


On Wed, Apr 06, 2011 at 03:38:57PM -0700, Baptiste Coudurier wrote:
> On 04/06/2011 03:19 AM, Michael Niedermayer wrote:
> > On Wed, Apr 06, 2011 at 09:51:33AM +0200, Jean-Daniel Dupas wrote:
> >>
> >> Le 6 avr. 2011 à 02:50, James Zern a écrit :
> >>
> >>> On Tue, Apr 5, 2011 at 16:53, Baptiste Coudurier
> >>> <baptiste.coudurier at gmail.com> wrote:
> >>>> Hi Dave,
> >>>>
> >>>> On 04/05/2011 04:49 PM, Dave Badia wrote:
> >>>>> On Wed, Mar 30, 2011 at 11:18 AM, Baptiste Coudurier
> >>>>> <baptiste.coudurier at gmail.com> wrote:
> >>>>>> Hi Dave,
> >>>>> <snip>
> >>>>>>
> >>>>>> --
> >>>>>> Baptiste COUDURIER
> >>>>>> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> >>>>>> FFmpeg maintainer                                  http://www.ffmpeg.org
> >>>>>> _______________________________________________
> >>>>>> ffmpeg-devel mailing list
> >>>>>> ffmpeg-devel at ffmpeg.org
> >>>>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>>>>>
> >>>>>
> >>>>> Thanks for the feedback as I am very new to ffmpeg.
> >>>>> I've revised my patch per you suggestions, hope I understood  properly.
> >>>>>
> >>>>>
> >>>>> 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);
> >>>>> +    }
> >>>>
> >>>> Set the metadata on AVStream, not AVFormatContext.
> >>>>
> >>>> Are you sure that the check is 100% correct for the rotation ?
> >>
> >> why not extracting the whole affine transform matrix ?
> > 
> > +1
> > 
> > but that doesnt mean i have any objections to just extract the
> > rotation
> 
> That would be nice, but I would apply Dave patch (plus the AVStream
> metadata change) right now if it is 100% correct and won't cause side
> effects. Is the check correct currently ?

getting this 100% correct is more work than exporting the whole
affine matrix but if you like

the a b
    c d
submatrix of a n*90° rotation / flip / scale
has 2 diagonal entries 0
the absolute values of the other 2 represent x/y scale
the signs and which are 0 represent the rotation and flip


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I hate to see young programmers poisoned by the kind of thinking
Ulrich Drepper puts forward since it is simply too narrow -- Roman Shaposhnik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110407/5ecab310/attachment.asc>


More information about the ffmpeg-devel mailing list