Can't get QML to playback .mp4 videos



  • Hello - QML newbie here. I am attempting to to create a trivial app for playback of video files. The code I have works fine for .wmv files, but when I try to playback an .mp4 file, nothing plays. Screen stays black.

    I am using Qt 5.2 running on Windows 7. I can playback the .mp4 files with no problem in Windows Media Viewer, so I believe I have the right codecs installed. Qt does not report any errors and the video component reports that it is playing when I query it's status. My code as follows. Any ideas what I need to do?

    @
    import QtQuick 2.2
    import QtMultimedia 5.0
    import QtQuick.Controls 1.1
    import QtQuick.Dialogs 1.1

    Rectangle {
    width: 800
    height: 600
    color: "black"

    FileDialog {
        id:  fbrowser
        title:  "Please select a video file"
    }
    
    Row {
        id:  buttonRow
        
        Button {
            id:  goButton
            text: "Start"
            onClicked:  {
                videoPlayer.source =  videoFileName.text;
                videoPlayer.play();
            }
        }
        
        Button {
            id: stopButton
            text: "Stop"
            onClicked: {videoPlayer.stop(); }
        }
        
        Button {
            id:  chooseFileButton
            text: "Select Video File..."
            onClicked: {fbrowser.open();}
        }
        
        TextField {
            id:  videoFileName
            width: 450
            text:  fbrowser.fileUrl
        }
    }
    
    Rectangle {
        id:  videoRect
        
        anchors {left: parent.left; top: buttonRow.bottom; topMargin: 5; right:  parent.right; bottom:  parent.bottom}
        color:  "transparent"
        
        Video {
            id: videoPlayer
            focus: true
            anchors.fill: parent
        }
    }
    

    }

    @



  • Update*

    I've continued to play around with this today. Oddly, I've found that if I compile my project using MSVS2012 32 bit, it loads and plays the .mp4 files just fine. But if I compile using the mingw 32 bit compiler, I cannot play .mp4 files. Any ideas why that would be true?



  • I'm continuing to learn a little more about this. There seem to be a number of differences in performance and behavior between the mingw and the msvc compiler when it come to the MediaPlayer component in QML. I am attempting to place a string of small videos in a PathView component, and allow the user to scroll to one to play it. Auto repeat of the video via the "loops: Animation.Infinite" property works OK in msvc but appears to have no effect in mingw. The pathView in general behaves much better (scolls faster & more smoothly) in mingw. It also crashes unpredictably in msvc but not in mingw.

    Does anybody really understand the underlying differences in the MediaPlayer implementations with the two compilers?

    Gotta say - I'm a little dissapointed that nobody is responding to these posts - it doesn't seem to bode well for the open source support of Qt as a professional development tool.



  • Hi mclaus,

    I noticed "here":http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL that you can install on windows with either opengl or Angle. The note says that if you want to use QtMultimedia you should use Angle. Maybe that will help?



  • Interestingly, The document states that opengl is required to work with Qt Quick and also that Angle is required to work with QtMutimedia. So, it looks like you may be out of luck for now since you are writing QML with QtMultimedia.



  • on the other hand there is "this":https://blog.qt.digia.com/blog/2012/10/24/graphics-on-windows-from-a-different-angle/ ... It's giving me a headache :-)


  • Moderators

    Hi,

    This page should clarify the situation a bit: http://qt-project.org/wiki/Qt_Multimedia

    Basically, Qt uses the multimedia backend provided by your OS. Microsoft provides 2 backends: DirectShow and Windows Media Foundation. Look in C:<Qt>\plugins\mediaservice\ -- you will find the multimedia plugins there.

    DS is the legacy backend; WMF is the way forward. The WMF backend was the one that allowed you to open your .mp4 file. Unfortunately, WMF...

    • ...doesn't support Windows XP (Microsoft has no plans to do so), and
    • ...isn't properly supported by MinGW yet (it's possible for Qt to hack around this, but it's much better if it's done properly upstream).

    If you want to use MinGW, I believe you can play your .mp4 file if you can find and install a MP4 codec for DirectShow.

    [quote author="Duff" date="1394820770"]I noticed "here":http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL that you can install on windows with either opengl or Angle. The note says that if you want to use QtMultimedia you should use Angle.[/quote]Yes, there's a bug that can cause crashes in Windows when playing video on OpenGL-based builds.

    Note, however, that OpenGL-vs.-ANGLE is completely unrelated to DirectShow-vs.-WMF.

    [quote author="Duff" date="1394821323"]Interestingly, The document states that opengl is required to work with Qt Quick and also that Angle is required to work with QtMutimedia. So, it looks like you may be out of luck for now since you are writing QML with QtMultimedia. [/quote]No, ANGLE simply converts OpenGL instructions into DirectX instructions. In fact, the whole reason for using ANGLE is to support Qt Quick (QML) on systems which don't have OpenGL 2.

    [quote author="Duff" date="1394822052"]on the other hand there is "this":https://blog.qt.digia.com/blog/2012/10/24/graphics-on-windows-from-a-different-angle/ ... It's giving me a headache :-)[/quote]What's wrong?

    [quote author="mclaus" date="1394809630"]I'm a little dissapointed that nobody is responding to these posts - it doesn't seem to bode well for the open source support of Qt as a professional development tool.[/quote]You'll get a reply if someone on these forums is familiar with your issue. I've noticed that there aren't many users here who are experienced in multimedia.

    If you want to talk to Qt's engineers, subscribe and post to the "Interest mailing list":http://lists.qt-project.org/mailman/listinfo/interest



  • Okay, good. I have been hemming and hauling over which version to install on my Windows laptop. I'm hoping I can maintain one repository out on BitBucket and develop with both my Fedora and Windows machines.



  • JKSH & Duff - thanks so much for your thoughtful replies. I'm feeling like I understand it all a little bit better now.



  • How does other file formats work for you ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.