On Tue, 3 Dec 2013 14:56:28 +0000, André Cruz <[email protected]>
wrote:
> Some devices include metadata in the video that indicate the orientation
> of the
> video. Apple devices are an example of that.
> 
> This code was lifted from ffmpeg and includes the "rotate" element in
the
> video
> metadata.
> 
> There were several commits that touched the relevant code, but as this
> touched
> other areas as well I could not use those commits as is:
> 
> d3cef0a85
> e6ba3d428
> 62d2a75b0
> 
> ---
>  libavformat/mov.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 9b019e1..6dae12d 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2256,6 +2256,18 @@ static int mov_read_tkhd(MOVContext *c,
AVIOContext
> *pb, MOVAtom atom)
>      sc->width = width >> 16;
>      sc->height = height >> 16;
>  
> +    //  Assign clockwise rotate values based on transform matrix so
that
> +    //  we can compensate for iPhone orientation during capture.
> +
> +    if (display_matrix[1][0] == -65536 && display_matrix[0][1] ==
65536)
> +         av_dict_set(&st->metadata, "rotate", "90", 0);
> +
> +    if (display_matrix[0][0] == -65536 && display_matrix[1][1] ==
-65536)
> +         av_dict_set(&st->metadata, "rotate", "180", 0);
> +
> +    if (display_matrix[1][0] == 65536 && display_matrix[0][1] ==
-65536)
> +         av_dict_set(&st->metadata, "rotate", "270", 0);

Why express the rotation in degrees but then limit the computed value to
rectangular angles?

> +
>      // 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

-- 
Rémi Denis-Courmont
Sent from my collocated server
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to