androidvideovlclibvlc

Video rotation on android using LibVLC


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!


Solution

  • 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.