rotation of video from android_camera

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

rotation of video from android_camera

FFmpeg-users mailing list
I'm using ffmpeg android_camera device as video source in my open source
baresip VoIP app.

If I make a call by holding the device upright (portrait), video from
the front facing camera of the device is sent in landscape orientation
rotated clockwise 90 degrees from portrait orientation.

I added some debug into the app and found that
CameraCharacteristics.SENSOR_ORIENTATION has always value 270.  Android
reference tells this about that characteristics:

  The orientation of the camera image. The value is the angle that the
  camera image needs to be rotated clockwise so it shows correctly on
  the display in its natural orientation. It should be 0, 90, 180, or
  270.

If android_camera device would rotate the video clockwise by that
amount (270), orientation of the video would be correct.  There is this
in android_camera.c:

  av_display_rotation_set(display_matrix, ctx->sensor_orientation);

  if (ctx->lens_facing == ACAMERA_LENS_FACING_FRONT) {
      av_display_matrix_flip(display_matrix, 1, 0);
  }


Any idea why the rotation does not happen?

-- Juha
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

rotation of video from android_camera

FFmpeg-users mailing list
Juha Heinanen via ffmpeg-user writes:

> If android_camera device would rotate the video clockwise by that
> amount (270), orientation of the video would be correct.  There is this
> in android_camera.c:
>
>   av_display_rotation_set(display_matrix, ctx->sensor_orientation);
>
>   if (ctx->lens_facing == ACAMERA_LENS_FACING_FRONT) {
>       av_display_matrix_flip(display_matrix, 1, 0);
>   }

I tried with back camera (where the above flip call is not executed) and
now android_camera sent the video with 270 degree clockwise orientation.

This is with ffmpeg version 4.2.2.

-- Juha
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

rotation of video from android_camera

FFmpeg-users mailing list
I tried by replacing ctx->sensor_orientation with several constants,
e.g., 0.0, 90.0, 180.0:

static int add_display_matrix(AVFormatContext *avctx, AVStream *st)
{
    AndroidCameraCtx *ctx = avctx->priv_data;
    uint8_t *side_data;
    int32_t display_matrix[9];

    av_display_rotation_set(display_matrix, ctx->sensor_orientation);
...

There was no change: video from android_camera was always rotated
clockwise 90 degrees.  Any hints on how to figure out why no rotation
takes place?

-- Juha
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".