我有一个宠物项目,其中包含一个具有显示字幕功能的视频播放器。 到目前为止,我一直在处理项目的其他部分,但现在我必须以最好的方式实现字幕渲染部分。
我没有找到任何有用的东西,除了 this .
但是当我使用此代码时,我得到了错误的视频图片。
颜色修改:红→蓝、蓝→红等
有人可以帮我处理这段代码,或者告诉我另一种在视频顶部呈现字幕的解决方案吗?
PS:我在 PySide 1.0.0、1.0.6 以及 Arch 和 Ubuntu linux 上对其进行了测试。
感谢 alexisdm 提供了一个丑陋的 hack .它改变了 paint() 方法来反转颜色。
import sys
from PySide.QtGui import QApplication, QMessageBox
# overlay
from PySide.QtGui import QGraphicsScene, QGraphicsView, QGraphicsProxyWidget, QPainter, QImage
from PySide.QtOpenGL import QGLWidget
from PySide.phonon import Phonon
try:
from OpenGL import GL
except ImportError:
app = QApplication(sys.argv)
QMessageBox.critical(None, "OpenGL 2dpainting",
"PyOpenGL must be installed to run this example.",
QMessageBox.Ok | QMessageBox.Default,
QMessageBox.NoButton)
sys.exit(1)
#class CustomProxy(QGraphicsProxyWidget):
# def __init__(self, parent=None):
# QGraphicsProxyWidget.__init__(self, parent)
#
#
# def boundingRect(self):
# return QGraphicsProxyWidget.boundingRect(self).adjusted(0, 0, 0, 0);
class CustomProxy(QGraphicsProxyWidget):
def __init__(self, parent=None):
QGraphicsProxyWidget.__init__(self, parent)
def boundingRect(self):
return QGraphicsProxyWidget.boundingRect(self).adjusted(0, 0, 0, 0);
# This is the magic:
def paint(self, painter, option, widget=None):
painter_inverted = QPainter()
brect= QGraphicsProxyWidget.boundingRect(self)
invertedColor = QImage(brect.width(),brect.height(),QImage.Format_RGB32)
painter_inverted.begin(invertedColor)
QGraphicsProxyWidget.paint(self,painter_inverted, option, widget)
painter_inverted.end()
painter.drawImage(0,0,invertedColor.rgbSwapped())
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setApplicationName("tete")
scene = QGraphicsScene()
media = Phonon.MediaObject()
video = Phonon.VideoWidget()
Phonon.createPath(media, video)
proxy = CustomProxy()
proxy.setWidget(video)
rect = proxy.boundingRect()
#proxy.setPos(0, 0)
#proxy.show()
scene.addItem(proxy)
media.setCurrentSource("/home/boo/Development/mindmap/test/resources/glvideo.avi")
media.play()
titem = scene.addText("Bla-bla-bla")
titem.setPos(130, 130)
#titem.setPos(rect.width()/2, rect.height()/2)
view = QGraphicsView(scene)
vp = QGLWidget()
view.setViewport(vp)
#view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
view.setWindowTitle("Eternal fire")
view.show()
sys.exit(app.exec_())
最佳答案
正如 alexisdm 所指出的那样在评论中这是 Qt 的一个已知错误。
可以找到#GTBUG-8738有人甚至添加了解决方法。
关于python - Phonon 的 VideoWidget 在 QGLWidget(Qt,Python)上显示错误的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7687864/
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file