[英]Displaying Text over VLC Video Output by Python/PyQt5
I wonder how I can display text over my VLC video output.我想知道如何在我的 VLC 视频 output 上显示文本。 Every widget I put on top of the video surface widget vanishes as soon as video is played.
我放在视频表面小部件顶部的每个小部件都会在播放视频后立即消失。 For example, I use a QFrame as the video surface and put a Qlabel inside that QFrame.
例如,我使用 QFrame 作为视频表面并在该 QFrame 中放置一个 Qlabel。 The text appears over the frame, but come video it's gone.
文字出现在框架上,但视频来了,它消失了。 In the following MRE, as soon as I unremark the
self.Player.play()
the video is played and the text is gone.在下面的 MRE 中,只要我
self.Player.play()
视频就会播放并且文本消失了。
import sys
import vlc
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QWidget,QApplication,QMainWindow,QFrame,QLabel,QVBoxLayout
class Player(QMainWindow):
def __init__(self, parent=None):
super(Player,self).__init__()
self.Init_Gui()
# self.Player.play()
def Init_Gui(self):
centralWidget = QWidget()
mainlayout = QVBoxLayout(centralWidget)
self.resize(640,480)
self.setCentralWidget(centralWidget)
self.VideoSurface = QFrame()
self.VideoSurface.setStyleSheet('background-color: black')
self.OSDLabel = QLabel(self.VideoSurface)
self.OSDLabel.setStyleSheet('color: white')
font = QFont()
font.setPointSize(18)
self.OSDLabel.setFont(font)
self.OSDLabel.setText('Testing ....... Testing..... Testing.....')
mainlayout.addWidget(self.VideoSurface)
self.Instance = vlc.Instance()
self.Player = self.Instance.media_player_new('e:/media/vid1.mp4')
self.Player.set_hwnd(self.VideoSurface.winId())
self.show()
if __name__=='__main__':
MyApp = QApplication(sys.argv)
MyGui = Player()
sys.exit(MyApp.exec_())
libvlc has a function for that, see https://github.com/oaubert/python-vlc/blob/d64c2e84093e1b60b45d8cbb84a53bc5608a1f15/generator/templates/footer.py#L180 libvlc 有一个 function,参见https://github.com/oaubert/python-vlc/blob/d64c2e84093e1b60b45d8cbbpy41#5180/ftemplates/footer。
player.video_set_marquee_string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.