2011-06-07 106 views
1

我正尝试使用QML创建简单的视频播放器。我安装了QtSdk,并从源代码编译安装了QtMobility。然后我把这个简单的视频播放代码,主QML文件:带QML视频的视频在Mac OS X上播放波涛汹涌

import QtQuick 1.0 
import QtMultimediaKit 1.1 

Item{ 
    width: 400; height: 300 
    Video { 
     id: video 
     source: "d:/Projects/Serenity - HD DVD Trailer.mp4" 
     anchors.fill: parent 
     MouseArea { 
      anchors.fill: parent 
      onClicked: { 
       video.play() 
      } 
     } 
    } 
} 

编译和运行应用程序后,视频播放不连贯和退出应用程序它把这个日志:

2011-06-07 11:13:44.055 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x10225ea60 of class NSCFNumber autoreleased with no pool in place - just leaking 
2011-06-07 11:13:45.007 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x10264f030 of class __NSCFDate autoreleased with no pool in place - just leaking 
2011-06-07 11:13:45.007 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x11a409000 of class NSCFTimer autoreleased with no pool in place - just leaking 
2011-06-07 11:13:45.008 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x11a43e550 of class NSCFArray autoreleased with no pool in place - just leaking 
2011-06-07 11:13:45.008 video-player[323:903] *** __NSAutoreleaseNoPool(): Object 0x11a462560 of class __NSFastEnumerationEnumerator autoreleased with no pool in place - just leaking 

如果任何方式使其顺利播放并防止记忆?

+0

您可以通过在应用程序开始时创建新的自动释放池来摆脱autorelease池消息,例如, 'NSAutoreleasePool * pool = [NSAutoreleasePool new];' – 2011-06-07 08:43:08

+0

什么是内容文件的比特率,并且您是否尝试过使用较低的比特率?我注意到Ubuntu上的QML Video项目存在性能问题,这是我在使用QVideoWidget时没有的。如果我没有记错,我得出的结论是,它可能是因为视频在QML情况下呈现给底层的QGraphicsVideoItem,而在小部件的情况下,它利用了GStreamer的xvimagesink - 基本上是渲染到表面的情况,一个窗口。我不知道Mac OS X使用哪个后端,但性能问题可能是跨平台的。 – fejd 2011-06-07 11:49:16

+0

你试过其他文件格式吗?结果是什么? – Abhijith 2011-06-07 14:04:19

回答

1

已解决。我为此使用了OpenGL。比Windows更好 - GL版本。这里代码:

QDeclarativeView mainwindow; 
mainwindow.setSource(QUrl::fromLocalFile("./qml/app.qml")); 
QGLFormat format = QGLFormat(QGL::DirectRendering); // you can play with other rendering formats like DoubleBuffer or SimpleBuffer 
format.setSampleBuffers(false); 
QGLWidget *glWidget = new QGLWidget(format); 
glWidget->setAutoFillBackground(false); 
mainwindow.setViewport(glWidget); 

注:当前版本QtMobility的(1.1)具有不允许播放视频在OpenGL在Windows渲染模式的错误。所以我使用了原生Qt渲染来获胜。

相关问题