Video doesn't scale until manual resize (macOS)

This forum is about all development around libVLC.
Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Video doesn't scale until manual resize (macOS)

Postby Timothy Grove » 11 Nov 2020 15:10

I'm using the VLC bindings for Python with PyQt5 on macOS, and I'm seeing an issue where a video does not scale up or down to fit the QWidget until it is manually resized; sometimes it does, but mostly it doesn't.
All of the early VLC 3.0 versions work fine until I get to 3.0.7. The changelog suggested that there was a sizing glitch fixed between 3.0.8 and 3.0.9, but that doesn't fix this issue for me. I haven't tested 4.0.

I'm digging around in the VLC source code to see if I can understand the problem, but can anyone point me in the right direction?

I'm using an updated version of the sample player given at: https://raw.githubusercontent.com/oaube ... s/qtvlc.py

Code: Select all

#! /usr/bin/python3 import sys import os.path import vlc from PyQt5 import QtGui, QtCore, QtWidgets unicode = str # Python 3 class Player(QtWidgets.QMainWindow): """A simple Media Player using VLC and Qt """ def __init__(self, master=None): QtWidgets.QMainWindow.__init__(self, master) self.setWindowTitle("Media Player") self.instance = vlc.Instance() self.mediaplayer = self.instance.media_player_new() self.createUI() self.isPaused = False def createUI(self): self.widget = QtWidgets.QWidget(self) self.setCentralWidget(self.widget) self.videoframe = QtWidgets.QFrame() self.palette = self.videoframe.palette() self.palette.setColor (QtGui.QPalette.Window, QtGui.QColor(0,0,0)) self.videoframe.setPalette(self.palette) self.videoframe.setAutoFillBackground(True) self.positionslider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.positionslider.setToolTip("Position") self.positionslider.setMaximum(1000) self.positionslider.sliderMoved.connect(self.setPosition) self.hbuttonbox = QtWidgets.QHBoxLayout() self.playbutton = QtWidgets.QPushButton("Play") self.hbuttonbox.addWidget(self.playbutton) self.playbutton.clicked.connect(self.PlayPause) self.stopbutton = QtWidgets.QPushButton("Stop") self.hbuttonbox.addWidget(self.stopbutton) self.stopbutton.clicked.connect(self.Stop) self.hbuttonbox.addStretch(1) self.volumeslider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.volumeslider.setMaximum(100) self.volumeslider.setValue(self.mediaplayer.audio_get_volume()) self.volumeslider.setToolTip("Volume") self.hbuttonbox.addWidget(self.volumeslider) self.volumeslider.valueChanged.connect(self.setVolume) self.vboxlayout = QtWidgets.QVBoxLayout() self.vboxlayout.addWidget(self.videoframe) self.vboxlayout.addWidget(self.positionslider) self.vboxlayout.addLayout(self.hbuttonbox) self.widget.setLayout(self.vboxlayout) open = QtWidgets.QAction("&Open", self) open.triggered.connect(self.OpenFile) exit = QtWidgets.QAction("&Exit", self) exit.triggered.connect(sys.exit) menubar = self.menuBar() filemenu = menubar.addMenu("&File") filemenu.addAction(open) filemenu.addSeparator() filemenu.addAction(exit) self.timer = QtCore.QTimer(self) self.timer.setInterval(200) self.timer.timeout.connect(self.updateUI) def PlayPause(self): if self.mediaplayer.is_playing(): self.mediaplayer.pause() self.playbutton.setText("Play") self.isPaused = True else: if self.mediaplayer.play() == -1: self.OpenFile() return self.mediaplayer.play() self.playbutton.setText("Pause") self.timer.start() self.isPaused = False def Stop(self): self.mediaplayer.stop() self.playbutton.setText("Play") def OpenFile(self, filename=None): if not filename: filename = QtWidgets.QFileDialog.getOpenFileName(self, "Open File", os.path.expanduser('~'))[0] if not filename: return self.media = self.instance.media_new(filename) self.mediaplayer.set_media(self.media) self.media.parse() self.setWindowTitle(self.media.get_meta(0)) if sys.platform.startswith('linux'): # for Linux using the X Server self.mediaplayer.set_xwindow(self.videoframe.winId()) elif sys.platform == "win32": # for Windows self.mediaplayer.set_hwnd(self.videoframe.winId()) elif sys.platform == "darwin": # for MacOS self.mediaplayer.set_nsobject(int(self.videoframe.winId())) self.PlayPause() def setVolume(self, Volume): self.mediaplayer.audio_set_volume(Volume) def setPosition(self, position): self.mediaplayer.set_position(position / 1000.0) def updateUI(self): self.positionslider.setValue(self.mediaplayer.get_position() * 1000) if not self.mediaplayer.is_playing(): self.timer.stop() if not self.isPaused: self.Stop() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) player = Player() player.show() player.resize(640, 480) if sys.argv[1:]: player.OpenFile(sys.argv[1]) sys.exit(app.exec_())
Any suggestions on a workaround? Thanks.

I'm working with Python3.7.6, PyQt5.13.1, macOS Mojave/Catalina; not seeing this on Windows or Linux.

My display uses:

Intel HD Graphics 4000:
Chipset Model: Intel HD Graphics 4000
Type: GPU
Bus: Built-In
VRAM (Dynamic, Max): 1536 MB
Vendor: Intel
Device ID: 0x0166
Revision ID: 0x0009
Metal: Supported, feature set macOS GPUFamily1 v4

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Video doesn't scale until manual resize (macOS)

Postby mfkl » 12 Nov 2020 06:06

a video does not scale up or down to fit the QWidget until it is manually resized
Could you please share a gif or video of the behavior you observe? I'm not sure that I understand the problem.
https://mfkl.github.io

Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Re: Video doesn't scale until manual resize (macOS)

Postby Timothy Grove » 12 Nov 2020 22:31

Here are a couple of videos to show this behaviour.

https://drive.google.com/file/d/11Lnwhf ... sp=sharing
https://drive.google.com/file/d/1pIZQkL ... sp=sharing

The first is smaller than the video window when loaded and doesn't scale up until the edge of the player is dragged.
The second is larger and doesn't scale down until the edge of the player is dragged.

The behaviour is first seen in VLC 3.0.7.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Video doesn't scale until manual resize (macOS)

Postby mfkl » 16 Nov 2020 04:14

Ok, thanks. Can you repro with the official Qt sample? https://code.videolan.org/videolan/vlc- ... c/QtPlayer

If so, feel free to open a bug report on trac.videolan.org with all your info.
https://mfkl.github.io

Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Re: Video doesn't scale until manual resize (macOS)

Postby Timothy Grove » 17 Nov 2020 19:11

Ok, will do, once I have some success at building this... Which forum best for discussing compilation issues? Any pre-built versions of this around?

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Video doesn't scale until manual resize (macOS)

Postby mfkl » 18 Nov 2020 04:50

here or the libvlc discord https://discord.com/invite/3h3K3JF
https://mfkl.github.io

Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Re: Video doesn't scale until manual resize (macOS)

Postby Timothy Grove » 18 Nov 2020 17:48

Okay, got the code as suggested above and trying to build through QtCreator 4.13.2, with Qt5.13.2, on macOS 10.15.7 (Catalina).

The only thing I altered was QtVLC.pro to indicate paths on my system:

Code: Select all

TEMPLATE = app TARGET = qtvlc DEPENDPATH += . INCLUDEPATH += . \ ../../../include # /Users/timothy/VLCSource/vlc-3.0/include/vlc LIBS += -L/Applications/VLC.app/Contents/MacOS/lib # VLC 3.0.11.1 LIBS += -L/opt/X11/lib # Xquartz.org; X11 no longer included with Mac LIBS += -lvlc -lX11 QT = widgets # Input HEADERS += player.h \ ../../../include/vlc/vlc.h SOURCES += main.cpp player.cpp

Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Re: Video doesn't scale until manual resize (macOS)

Postby Timothy Grove » 18 Nov 2020 17:51

Actually, the compilation steps appear to be okay, but the app start fails:

Code: Select all

15:45:54: Starting /Users/timothy/VLCSource/vlc-3.0/doc/libvlc/build-QtVLC-Desktop_Qt_5_15_0_clang_64bit-Debug/qtvlc.app/Contents/MacOS/qtvlc ... dyld: Symbol not found: _gll_noop Referenced from: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL Expected in: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL 15:45:56: The program has unexpectedly finished. 15:45:56: The process was ended forcefully. 15:45:56: /Users/timothy/VLCSource/vlc-3.0/doc/libvlc/build-QtVLC-Desktop_Qt_5_15_0_clang_64bit-Debug/qtvlc.app/Contents/MacOS/qtvlc crashed.
Seems to be an issue around X11 and OpenGL, but unsure how to correct at the moment...

Timothy Grove
Blank Cone
Blank Cone
Posts: 33
Joined: 07 Sep 2011 13:17

Re: Video doesn't scale until manual resize (macOS)

Postby Timothy Grove » 19 Nov 2020 16:28

Okay, I was able to build the QtVLC player in QtCreator and can reproduce the sizing issue; so off to file the bug report...

This was the QtVLC.pro file I ended up with:

Code: Select all

TEMPLATE = app TARGET = qtvlc DEPENDPATH += . INCLUDEPATH += /Applications/VLC.app/Contents/MacOS/include LIBS += -L/Applications/VLC.app/Contents/MacOS/lib -lvlc # LIBS += -L/opt/X11/lib -lX11 #not required QT += core gui widgets # Input HEADERS += \ player.h SOURCES += \ main.cpp \ player.cpp
And also needed to set the VLC_PLUGIN_PATH in player.cpp"

Code: Select all

Mwindow::Mwindow() { vlcPlayer = NULL; /*need to set VLC_PLUGIN_PATH; both of the following seem to work*/ /*setenv ("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins", 1);*/ QByteArray ba=QString("/Applications/VLC.app/Contents/MacOS/plugins").toUtf8(); qputenv("VLC_PLUGIN_PATH",ba); /* Initialize libVLC */ vlcInstance = libvlc_new(0, NULL);


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 15 guests