RSATom / QmlVlc

[ABANDONED] libvlc wrapper for Qt Quick 2/Qml
Other
139 stars 56 forks source link

Can't play two different videos in a single layout #53

Closed apavlenko closed 8 years ago

apavlenko commented 8 years ago

When trying to play 2 videos one next to the other they are displayed one over the other instead... Is it possible to show them right way?

import QtQuick 2.6
import QtQuick.Controls 1.5
import QtQuick.Layouts 1.1

import QmlVlc 0.1
import QtMultimedia 5.0

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Intel VMF demo player")

    RowLayout {
            id: row
            anchors.fill: parent
            //anchors.centerIn: parent
            spacing: 20

            //1
            Rectangle {
                Layout.fillHeight: true
                Layout.fillWidth: true
                color: 'grey';
                border.color: 'black'
                VlcPlayer {
                    id: vlcPlayer;
                    mrl: "rtsp://192.168.10.163:1234";
                }
                VlcVideoSurface {
                    id: vlcSurface;
                    source: vlcPlayer;
                }
                VideoOutput {
                    id: vlcVideoOut;
                    source: vlcPlayer;
                    //anchors.centerIn: parent;
                    width: parent.width;
                    height: parent.height;
                    //opacity: 0.9;
                }
            }

            //2
            Rectangle {
                Layout.fillHeight: true
                Layout.fillWidth: true
                color: 'yellow';
                border.color: 'black'
                VlcPlayer {
                    id: vlcPlayer2;
                    mrl: "rtsp://192.168.10.75:1234";
                }
                VlcVideoSurface {
                    id: vlcSurface2;
                    source: vlcPlayer2;
                }
                VideoOutput {
                    id: vlcVideoOut2;
                    source: vlcPlayer2;
                    //anchors.centerIn: parent;
                    width: parent.width;
                    height: parent.height;
                    //opacity: 0.9;
                }
            }

            //3
            //...
        }

}
RSATom commented 8 years ago

First of all you don't need VlcVideoSurface and VideoOutput at the same time, so you should remove one of them. Second - you didn't specify width and height for VlcVideoSurface. What about placing it to RowLayout - I'll check it, but I think you just use RowLayout in wrong way.

apavlenko commented 8 years ago

when I comment one of player's mrl - the other one works as expected, but both they try to use the same output element...

RowLayout {
    id: row
    anchors.fill: parent

    //1
    Rectangle {
        Layout.fillWidth: true
        Layout.fillHeight: true
        Layout.minimumWidth: 320
        Layout.minimumHeight: 240
        Layout.preferredWidth: 640
        Text {
            anchors.centerIn: parent
            text: parent.width + 'x' + parent.height
        }
        color: 'grey';
        border.color: 'black'
        VlcPlayer {
            id: vlcPlayer;
            mrl: "rtsp://192.168.10.190:1234";
        }
        VlcVideoSurface {
            id: vlcSurface;
            source: vlcPlayer;
            width: 320;
            height: 240;
        }
        /*VideoOutput {
            id: vlcVideoOutput;
            source: vlcPlayer;
            width: 320;
            height: 240;
        }*/
    }

    //2
    Rectangle {
        Layout.fillWidth: true
        Layout.fillHeight: true
        Layout.minimumWidth: 320
        Layout.minimumHeight: 240
        Layout.preferredWidth: 640
        Text {
            anchors.centerIn: parent
            text: parent.width + 'x' + parent.height
        }
        color: 'yellow';
        border.color: 'black'
        VlcPlayer {
            id: vlcPlayer2;
            mrl: "rtsp://192.168.10.218:1234";
        }
        VideoOutput {
            id: vlcVideoOut2;
            source: vlcPlayer2;
            Layout.fillWidth: true
            Layout.fillHeight: true
            //width: 640;//parent.width;
            //height: 480; //parent.height;
        }
    }
}
apavlenko commented 8 years ago

I really need help showing output of two players in the same app window - could you share any working example?

RSATom commented 8 years ago

your example works for me.

a little bit simplified one, which works fine too:

RowLayout {
    id: row
    anchors.fill: parent

    //1
    Rectangle {
        Layout.fillWidth: true
        Layout.fillHeight: true
        color: 'grey';
        border.color: 'black'
        VlcPlayer {
            id: vlcPlayer;
            mrl: "http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.avi";
        }
        VlcVideoSurface {
            id: vlcSurface;
            source: vlcPlayer;
            anchors.fill: parent;
        }
    }

    //2
    Rectangle {
        Layout.fillWidth: true
        Layout.fillHeight: true
        color: 'yellow';
        border.color: 'black'
        VlcPlayer {
            id: vlcPlayer2;
            mrl: "http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.avi";
        }
        VlcVideoSurface {
            id: vlcVideoOut2;
            source: vlcPlayer2;
            anchors.fill: parent;
        }
    }
}
RSATom commented 8 years ago

Another working sample: https://github.com/RSATom/QmlVlcDemo/blob/master/skin/basic_2.qml

RSATom commented 8 years ago

btw, what Qt version do you use, and what OS?

apavlenko commented 8 years ago

Windows 8.1 Qt 5.5 and 5.6

RSATom commented 8 years ago

I'm on Win 10 with Qt 5.5

RSATom commented 8 years ago

Could you try the same with something other than rtsp source? maybe it's related...

apavlenko commented 8 years ago

it works OK when player1 plays RTSP and player2 plays HTTP, but changing both to use RTSP URLs brings the problem!

RSATom commented 8 years ago

Then it's libvlc level issue. Please enable debug mode and look log with https://technet.microsoft.com/en-us/sysinternals/debugview.aspx

RSATom commented 8 years ago

https://github.com/RSATom/QmlVlcDemo/blob/master/main.cpp#L39 - it's how enable debug mode

apavlenko commented 8 years ago

you are right: I've run two VLC players to show two different RTSP streams - but they display both in the same window leaving the other black! :( thanks a lot for you help, anyway...

RSATom commented 8 years ago

it's possible they just try to use the same port for incoming stream.

RSATom commented 8 years ago

And maybe it could be fixed by some libvlc setting. Look to log, maybe you'll find something there.

apavlenko commented 8 years ago

you're right again: both connections used the same ports! thanks a lot for help - now I know where to go for getting this fixed!

RSATom commented 8 years ago

You are welcome.

I think this issue can be closed.