4

I'm using LibVLC to display video files. It's working fine so far, despite of the orientation. I'm able to get the orientation out of meta-data but don't really know how to force LibVLC to rotate it from landscape to portrait.

It would be nice to get a hint for a workaround.

Thanks!

Pateta
  • 430
  • 4
  • 15
  • Did you try adding `'--video-filter rotate --rotate-angle '+str(the angle you desire)` to the `vlc.Instance()` ? I've just realised this question is years old, ah well! – Rolf of Saxony Jan 13 '23 at 18:55

1 Answers1

7

I had a similar problem. Unfortunately LibVLC for android does not expose all features, so I had to change code in the jni layer to get it working. Here is how to do it:

Edit libvlcjni.c, and find the function : Java_org_videolan_libvlc_LibVLC_nativeInit. Look for the local varibale argv array and add the following to items to it:

"--video-filter=transform" "--transform-type="

Where transform type is one of the following: 90, 180, 270, hfilp, vfilp.

If you omit --transform-type you'l get a 90 degree rotation by default.

What this modifications does, is it loads the transform filter and then sets the transformation. You can do more fine grained rotation using --rotation-angle, but you'll have to load the appropriate filter first.

Hope this helps.

ne'mi
  • 346
  • 2
  • 4
  • the modification on native method is working, but when using 90 or 180 the player crashes. I think it may be related to androids video surface and not to vlc itself. Any toughts on this? – Pateta May 27 '14 at 11:44
  • I have tried this approach with different rotations without a crash. Could you please post logs so I can better understand what might be going wrong? – ne'mi May 31 '14 at 11:10
  • I don't know were the problem is. Maybe something with my test app. I used your approach and solved it using -video-filter=rotate and --rotate-angle=. So I'll mark your answer as accepted. Thanks! – Pateta Jun 03 '14 at 08:24
  • Im trying to do something similar. may I ask what settings are you using? settings such as HW acceleration enabled or disabled, chroma type, which branch of VLC or commit works for you? thanks! – Simon Aug 21 '14 at 04:20
  • How did you go about editing things on the JNI layer? Did you have to compile libVLC for Android? What git commit hashes did you pull from? – SaundersB Mar 08 '17 at 16:00