Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen displays upside down #972

Closed
aminukano585 opened this issue Dec 1, 2019 · 5 comments
Closed

Screen displays upside down #972

aminukano585 opened this issue Dec 1, 2019 · 5 comments

Comments

@aminukano585
Copy link

Issue

My screen display upside down, I have tried changing device orientation, flipping it upside down and locking up the orientation but the problem persists.

Device Details

Device: TECNO-C7
Android Version: 6.0
HiOS Version: Camon 1.1.0

Screenshot

screen-upsidedown

@rom1v
Copy link
Collaborator

rom1v commented Dec 1, 2019

What if you rotate to landscape? Is it upside down in landscape?

If you record using screenrecord, is the resulting file upside down:

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4

?

@aminukano585
Copy link
Author

Hi, @rom1v the view remains upside down even when rotated to landscape. However, the recorded screen in file.mp4 shows corrected view.

@rom1v
Copy link
Collaborator

rom1v commented Dec 1, 2019

One possible cause could be that the frame are encoded with some rotation metadata (which would surprise me, since it's just raw H.264).

Could you apply this patch, recompile and retry, and tell me what it prints in the console, please?

diff --git a/app/src/decoder.c b/app/src/decoder.c
index cad1991..f718e55 100644
--- a/app/src/decoder.c
+++ b/app/src/decoder.c
@@ -1,6 +1,7 @@
 #include "decoder.h"
 
 #include <libavformat/avformat.h>
+#include <libavutil/display.h>
 #include <libavutil/time.h>
 #include <SDL2/SDL_assert.h>
 #include <SDL2/SDL_events.h>
@@ -75,6 +76,14 @@ decoder_push(struct decoder *decoder, const AVPacket *packet) {
                                 decoder->video_buffer->decoding_frame);
     if (!ret) {
         // a frame was received
+        AVFrame *frame = decoder->video_buffer->decoding_frame;
+        LOGI("new frame");
+        for (int i = 0; i < frame->nb_side_data; ++i) {
+            AVFrameSideData *sd = frame->side_data[i];
+            if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX) {
+                LOGI("rotation: %.2f", av_display_rotation_get((int32_t *) sd->data));
+            }
+        }
         push_frame(decoder);
     } else if (ret != AVERROR(EAGAIN)) {
         LOGE("Could not receive video frame: %d", ret);

@aminukano585
Copy link
Author

Hi @rom1v, I have applied the patch but the problem persists.

This is the console output:

INFO: Initial texture: 720x1280
INFO: new frame
INFO: new frame
INFO: new frame

@rom1v
Copy link
Collaborator

rom1v commented Apr 9, 2020

On dev branch, there are two new solutions:

  • --lock-video-orientation 2 (rotate the video stream)
  • --rotation 2 or Ctrl+/Ctrl+ (rotate the display)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants