2011-06-07 104 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渲染來獲勝。

相關問題