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

查看:22
本文介绍了你如何在 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.

这是我得到的:

http://s1378.photobucket.com/user/Jo_Han_Solo/media/Screenshot_20171214-125504_zps437k1kw2.png.html?filters[user]=146993343&filters=1&o=1

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

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.

无论哪种方式,我发现使用三星 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);"

希望这对某人有所帮助!

Hope this helps someone!

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

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