您如何在Android LibVLC中全屏RTSP流? [英] How do you Fullscreen RTSP Stream in Android LibVLC?

查看:574
本文介绍了您如何在Android LibVLC中全屏RTSP流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mrmaffen的VLC-ANDROID-SDK开发RTSP流应用程序. https://github.com/mrmaffen/vlc-android-sdk

I'm using mrmaffen's VLC-ANDROID-SDK to develop an RTSP streaming app. https://github.com/mrmaffen/vlc-android-sdk

我已经取得了很大的成功,使其运行良好,但我似乎无法动摇的问题是使它在SurfaceView上全屏显示视频源,甚至只是在SurfaceView的中心.

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.

这就是我得到的:

黑色窗口是屏幕的总尺寸,我希望该视频充满整个屏幕,并希望始终从中心开始填充,但是我不知道该怎么做.

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?

推荐答案

我有点解决了问题,但以一种狡猾的方式,它还远未完成,但考虑到缺乏对该主题的知识和信息,我认为这暂时可能会对某人有所帮助.

I kind of solved the problem but in a bit of a dodgy way, it's far from complete but considering the lack of knowledge and information on the topic I thought this might help someone for the time being.

  1. 找到屏幕的大小.
  2. 设置最终的IVLCOut以合并屏幕尺寸.
  3. 将setScale调整为全屏"视频流.

解释每个任务:

  1. 设置您的全局变量:

  1. Setup your globals:

public class SingleStreamView extends AppCompatActivity implements 
IVLCVout.Callback {

public int mHeight;
public int mWidth;

第二,在onCreate任务中找到设备的屏幕尺寸:

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

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

2. 然后转到"CreatePlayer"事件,并在其中设置视频输出:

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

    // Set up video output
        final IVLCVout vout = mMediaPlayer.getVLCVout();
        vout.setVideoView(mSurface);
        vout.setWindowSize(mWidth,mHeight);
        vout.addCallback(this);
        vout.attachViews();

使它居中于我的表面的获胜线是"vout.setWindowSize(mWidth,mHeight);"

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

然后,我仅使用setscale选项将视频全屏"显示.也就是说,这是一种 hack 的方式,我想尝试找出一种方法来获取编解码器信息,以便动态地设置视频的缩放比例并自动将所有尺寸的视频流全屏显示到任何尺寸的屏幕,但目前,此功能适用于已知的视频流分辨率,它将自动调整为手机的屏幕尺寸.

Then I simply used the setscale option to "fullscreen" the video. That said, it's a bit of a hack way of doing it, 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 and that way automatically fullscreen every size video stream to any size screen but for now this will work for known video stream resolutions, it will automatically adjust to the screen size of your phone.

无论哪种方式,我发现使用Samsung Galaxy s8,640x480p RTSP流的良好缩放比例为1.8.编码如下:

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));
        m.setHWDecoderEnabled(true,false);
        m.addOption(":network-caching=100");
        m.addOption(":clock-jitter=0");
        m.addOption(":clock-synchro=0");
        m.addOption(":fullscreen");
        mMediaPlayer.setMedia(m);
        mMediaPlayer.setAspectRatio("16:9");
        mMediaPlayer.setScale(1.8f);
        mMediaPlayer.play();

您在哪里获得了"mMediaPlayer.setScale(1.8f);"

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

希望这对某人有帮助!

这篇关于您如何在Android LibVLC中全屏RTSP流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆