Important: Please read the Qt Code of Conduct -

Size constraints for video for QML

  • Has anyone else had any problems embedding video in QML code? I'm trying to use a file that's 133 mb (without anything else in the app or the code) and it's taking forever to run. Does anyone have work arounds for this or advice?

    Thank you!

  • Lifetime Qt Champion


    What do you mean by embed ? Use Qt's resource system ?

  • Yes, essentially this:

        Video {
            id: video
            width : parent.width
            height : parent.height
            source: "qrc:/video/"
            MouseArea {
                anchors.fill: parent
                onClicked: {
            focus: true
            Keys.onSpacePressed: video.playbackState == MediaPlayer.PlayingState ? video.pause() :
            Keys.onLeftPressed: - 5000)
            Keys.onRightPressed: + 5000)

  • Are there known size limitations for how large the video file that you use can be?

  • @abanksdev hi, while running video code are you facing memory problem because of 133mb? if it's like that then i can help you, i have come across this situation.

  • Moderators

    @abanksdev from my experience, It takes about 5 minutes to compile and link around 20 mb of ressource files. 133 mb will take a lot longer, if it works at all.

    Why don't you ship the Moviefile seperaterly and load it from the system HD ? Do you really need a 133 mb movie in your binary file!?

  • Lifetime Qt Champion


    You should rather use a external binary resouce.

  • @SGaist I'm a little unclear as to what they're instructing me to do in the link you sent me. Do i have to create a resource file with the videos in it first and then register it in the cmd line?

  • Lifetime Qt Champion

    1. You create a .qrc file
    2. You use rcc to generate an external file
    3. You add a call to registerResource in your sources to be able to access your data as if they were on different connections.

  • @SGaist said in Size constraints for video for QML:

    You create a .qrc file
    You use rcc to generate an external file
    You add a call to registerResource in your sources to be able to access your data as if they were on different connections.

    My apologies, I had to move onto other tasks at work.

    I'm still unclear as to the ordering of things

    1.) I create a qrc file with nothing in it
    2.) Where do I call the command

    rcc -binary myresource.qrc -o myresource.rcc

    I tried to call it in the cmd line from the project directory to no avail
    Moreover, is myresource.rcc just the file name or the actual file itself?
    3.) Where do I point to the path of the file I want to create as a binary external resource? With


    Should it go in the .pro file?

    I really need someone to just spell it out for me, I'm new to this. An example would help me a whole lot.

    Thank you!

  • Lifetime Qt Champion

    1. Why empty ? Its content should be the same as if you would build the resource within your application.
    2. Likely because you were calling it on an empty file.
    3. No, it should go in your application.

  • @SGaist @abanksdev said in Size constraints for video for QML:

    rcc -binary myresource.qrc -o myresource.rcc

    running it in my project dir results in the following:

    -bash: rcc: command not found

    I must be missing something totally obvious

  • Lifetime Qt Champion

    How did you install Qt ?

  • Nevermind I got that working.
    Once I have the rcc file should I delete the qrc file that I built it from?
    Moreover how do I set the source of a qml object to a rcc file?

    I assumed I should use the same path that i registered in QResource::registerResource("/path/to/myresource.rcc"); but when i do that, i don't get any errors, but yet the video im trying to display doesn't show up

  • Lifetime Qt Champion

    No you don't, the .qrc file is a part of your sources the same as the rest of your code.

    Again, no, use the same path as you would if it was embedded in your application.

  • So you mean I would use the qrc path 'qrc:/vidoes/filename' ?
    Can you give me an example. I'm extremely new to this, I'm not sure what you mean by 'as if it was embedded in your application'

  • Okay, for clarity's sake, here's how I'm implementing this. Let me know if anything is completely off base.

    The file I am trying to embed in my application:

    1.) I add a new resource file called 'videos.qrc' and add file to it
    2.) In the project's directory I register rcc -binary videos.qrc -o videos.rcc
    3.) In main.cpp in main() I use QResource::registerResource("C:/Users...qtProject/videos.rcc")
    4.) In video.qml:

    MediaPlayer {
              id: video
              source: "qrc:/videos/"
              autoPlay: true
              source: video

  • Lifetime Qt Champion

    Might be a silly question but does that video work correctly if you give the full path to it ?

  • Wow, good catch. It doesn't. Errrr
    I tried giving it the qrc url and the local path. Unless it's just taking a long time to load, but I doubt that

  • Lifetime Qt Champion

    Rather the QuickTime format is not supported by the backend.

Log in to reply