0

I am making a media player app for a TVBox running Android 7.1.2. I want to rotate the HDMI output but the box's rotation is locked to landscape so I cannot rotate the app using setRequestedOrientation. The library I use is VLC Android with SurfaceView. I cannot use TextureView because it is so lag and drop FPS.

To rotate the HDMI output, I have tried the following:

  • Modify the build.prop file but no luck.
  • Install a bunch of screen rotating app but it didnt work either.
  • I have tried this and some relate tutorial but it didnt work :

https://android.stackexchange.com/questions/117003/allow-rotate-into-portrait-mode-but-do-not-rotate-external-display

  • I try to used MediaRouter but the box recognized the HDMI as main screen and not external.
  • I tried using VLC filter :video-filter=rotate, :video-filter=transform but it will only be available in 4.0.
  • I also modified VLC source code but saddly it only rotate picture, not video.

So is there any other way I can try to rotate screen orientation of HDMI output? Is there any chance that we can rotate screen by OpenGl ES or native code?

Thank you.

BDL
  • 21,052
  • 22
  • 49
  • 55
ngoson
  • 583
  • 5
  • 14
  • I have no clue if it helps, but if it's like a regular app, can you load the output to a view and then just rotate the view? (Using android:rotation)? – Dan Baruch Mar 01 '21 at 13:19
  • @DanBaruch Yeah I have tried this but the SurfaceView cannot be transformed. It's View part and Surface part are seperated :(. – ngoson Mar 01 '21 at 13:21
  • Oh, sorry then, nothing more I can think of :( – Dan Baruch Mar 01 '21 at 13:35

1 Answers1

1

so you are saying that you can't use video-filter=rotate, what about video-filter=transform?

final ArrayList<String> args = new ArrayList<>();
args.add("--video-filter=transform");
args.add("--transform-type=270");

mLibVLC = new LibVLC(context, args);
mMediaPlayer = new MediaPlayer(mLibVLC);
final IVLCVout vlcVout = mMediaPlayer.getVLCVout();
vlcVout.setVideoView(mSurfaceView);
vlcVout.setWindowSize(mSurfaceView.getWidth(), mSurfaceView.getHeight());
snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • I have tried this filter too but it won't work either. I asked this on VLC git and they said that video filters will be available in 4.0. – ngoson Mar 01 '21 at 13:57
  • well, if you are using [THIS](https://github.com/videolan/vlc-android) lib I can ensure you that code posted in my question was working well and pretty efficient with `implementation group: 'org.videolan.libvlc', name: 'libvlc', version: '2.5.5'` (just digged this snippet from some repo, currently not maintained) – snachmsm Mar 01 '21 at 14:04
  • I will try this way. Thank you :)) – ngoson Mar 01 '21 at 14:11
  • I tried like the above but it only output the first frame of the video and then black screen, audio is still playing. I also saw that libvlc cannot load filter or rotate module: `core video output: Failed to create video filter 'transform'` `core video output: Failed to add filter 'transform'`. Guess that i have to rotate video on web server. – ngoson Mar 01 '21 at 17:42
  • Well if anyone is working with image then this way or newest version of VLCLib with transform or rotate is worked, but NOT for video. – ngoson Mar 11 '21 at 13:34
  • I've just noticed that `video-filter` isn't working with [official lib build](https://mvnrepository.com/artifact/org.videolan.android/libvlc-all?repo=jcenter), but can confirm is working with this [unofficial fork/release](https://mvnrepository.com/artifact/org.videolan.libvlc/libvlc), which is probably modified as [this answer](https://stackoverflow.com/a/23848108/4217682) suggests (and sadly not maintained). Have you found a way to rotate device using official release and/or on device only? – snachmsm Mar 17 '21 at 07:26
  • Yeah I have found a way to rotate all the app for the box, but all videos are still rendered in landscape mode: https://stackoverflow.com/questions/66666245/video-didnt-follow-app-orientation-android . Seems like this is a device specific problem. When I tried VLC version 2.5.5 you mentioned, the video get scaled down and display only in the screen corner and it still can't be transform. – ngoson Mar 17 '21 at 14:39
  • @ngoson - can you post your rotating code? now I need to rotate video with some more current libVLC than modded one in one of my comments... 3.x.x or one of 4 eap. tried `--vout=android-display`, which is just stretching video to fit whole space (still rotated) on 3.4.9 and will give black screen on 4 eap5 (default `gles2` gives proper ratio). posted in my answer args are no-op, if I understood correctly it is still in development with chance for release when 4 comes final. can we rotate with stable 3.x.x? – snachmsm Jan 08 '23 at 21:17