Anyone have experience with VLC-ANDROID-SDK?

  • Replies:4
  • OpenNot stickiedUnanswered
  • Forum posts: 16

Dec 14, 2017, 4:02:55 AM via Website

Hey guys,

I'm using mrmaffen's VLC-ANDROID-SDK to develop an RTSP streaming app.

I've had a lot of success getting it working and running quite well, but the problem I'm having that I can't seem to shake is getting it to display the video feed in fullscreen on the SurfaceView, or even just in the center of the SurfaceView.

This is what I get:

The black window is the total size of the screen, I want that video to fill the screen and hopefully always fill from center, but I can't figure out how to do it.

Anyone have any experience with anything like this and knows how to fix it?

— modified on Dec 18, 2017, 12:07:21 AM


  • Forum posts: 16

Dec 21, 2017, 11:05:11 PM via Website

Okay so I figured out a basic hack to get it filling a larger portion of the screen, works really well if you know the resolution of the stream you are trying to view, if the resolution is unknown then more work needs to be done but this is a baseline.

There are a few steps involved though so bare with me:
1. Find the size of your screen.
2. Set up your final IVLCOut to incorporate the screen size.
3. Adjust scaling factor in mMediaPlayer to increase size of video stream according to the resolution of your target device.

To explain each task:

  1. Setup your globals:

    public class SingleStreamView extends AppCompatActivity implements IVLCVout.Callback {

    public int mHeight;
    public int mWidth;

Secondly, in the onCreate task find your screen sizes of your device:

DisplayMetrics displayMetrics = new DisplayMetrics();
        mHeight = displayMetrics.heightPixels;
        mWidth = displayMetrics.widthPixels;

Then go down to your "CreatePlayer" event and where you set up your video output:

 // Set up video output
            final IVLCVout vout = mMediaPlayer.getVLCVout();

The winning line that made it center in my surface was the "vout.setWindowSize(mWidth,mHeight);"

I hope this helped, it helped me center my video feed in my app.

Then I simply used the setscale option to "fullscreen" the video. That said, it's a bit of a hack, and I would like to try and figure out a way to grab the codec information so to dynamically set the scale of the video.

Either way I found that with a Samsung Galaxy s8, a good scaling factor for a 640x480p RTSP stream was 1.8. Coded like so:

    Media m = new Media(libvlc, Uri.parse(RTSP_ADDRESS));

Where you got "mMediaPlayer.setScale(1.8f);"

Hope this helps you!

— modified on Dec 21, 2017, 11:05:50 PM


  • Forum posts: 1

Dec 26, 2018, 2:32:38 PM via Website

Hi Johan,

I'm trying to develop a similar app, playing an RTSP stream (with authentication) on Android and I feel a bit lost right now. I've looked throught the vlc-android-sdk code but would prefer some form of documentation/tutorial. Can you point me to any tutorial resources for vlc-android-sdk (esp for RTSP streaming)?


Recommended articles