Wednesday, April 24, 2013

Hardware Accelerated QtMultimedia Backend for Raspberry Pi and OpenGL Shaders on Video

EDIT: This article is completely outdated. Refer to newer posts for properly working builds, instructions on how to build etc... In particular: "Using POT Builds" and "Build Procedure for PiOmxTextures".

In some previous posts I developed a custom QML component to render video in a QML scene using hardware accelerated decoding capabilities and rendering without passing on the ARM side. This resulted in good performance of the Raspberry Pi even with 1080p high profile h264 videos.

Many bugs need to be fixed, code should be refactored a little but still it shows it is possible and that it works good. So I decided to move the following step: modifying Qt to make it possible to use the "standard" QtMultimedia module to access the same decoding/rendering implementation. This would make it possible to better integrate with Qt and allow users to recompile without changing anything on their implementation.

The QtMultimedia module uses gstreamer on Linux to provide multimedia capabilities: gstreamer is unfortunately not hardware accelerated on the Pi unless you use something like gst-omx.

Thus, I started to look at the QtMultimedia module sources in Qt5 and found out (as I was hoping), that the Qt guys have done, as usual, a very good job in designing the concept, providing the classic plugin structure also for multimedia backends. Unfortunately, also as usual, not much documentation is provided on how to implement a new backend, but it is not that difficult anyway by looking at the other implementations.

Design

At the end, I came up with a structure like this: I implemented a new QtMultimedia backend providing the MediaPlayer and VideoOutput minimal functionalities leveraging a "library-version" of the PiOmxTextures sample code which in turn uses a "bundled" version of omxplayer implemented using the OpenMAX texture render component as a sink for the video.

As said, Qt guys have done a good job! I didn't have to change almost nothing of the Qt implementation; all the implementation is inside the plugin (apart from a minimal modification on the texture mapping, for some reason it was upside-down and inverted).

Results

The result is pretty good, I don't see many differences from the previous custom QML component (the decoding and rendering code is the same and the QML component is implemented using the same exact principle, so nothing really changed).
I'm only beginning to play a little bit with this, I just tried a couple of things. In the video you can see the "standard" qmlvideo and qmlvideofx examples provided with the Qt sources.

How to Build

Clone the repo somewhere, then use the prepare_openmaxil_backend.sh script in tools. It will compile PiOmxTextures as a shared lib and will place everything you need in the openmaxil_backend directory. Copy that directory recursively into your Qt source tree in qt_source_tree/qtmultimedia/src/plugins naming it simply openmaxil.

Some changes are needed to the Qt tree to make it compile the new backend automatically instead of the gstreamer backend, for the texture mapping and to make the "standard" qmlvideo and qmlvideofx examples work. No real modification to the code is needed: sufficient to instantiate the QQuickView those examples use with a specific class definition. This is needed. and to provide the plugin the instance of the QQuickWindow containing the media player.
These changes can be applied with a patch to the qtmultimedia tree using the patch in the tools in git. Then build the qtmultimedia module with:

path_to_qmake/qmake "CONFIG+=raspberry"

You'll find all you need here: https://github.com/carlonluca/pi.

How to Use

After you have built the plugin, you can simply use the "standard" Qt API for MediaPlayer and VideoOutput. Only restriction is that the plugin needs to access a QQuickView to access the renderer thread of the Qt Scene Graph. This might be an issue, but I've not found another solution to this yet.

What you have to do is to simply provide your application the QQuickView by using the exact class, which must be included in your application:


class RPiQuickView
{
public:
   static QQuickView* getSingleInstance();
};

Q_DECL_EXPORT QQuickView* RPiQuickView::getSingleInstance() {
   static QQuickView instance;
   return &instance;
}


This is needed because the plugin will look for the RPiQuickView::getSingleInstance() symbol, which should be found after the dynamic linker has linked to plugin the the executable. Also, you'll need to add -rdynamic to the LFLAGS of your application, so we ensure that the linker will add the symbol to the symbol table.

This is what I added to the qmlvideo and qmlvideofx examples to make those work. This is of course not elegant, but still I couldn't find a better way in reasonable time.

Of cuorse, you'll have to copy the Qt libraries that are built to your Pi, together with libPiOmxTextures.so (unless you build it statically) and the ffmpeg libraries (do not use the ffmpeg libs you have in your Pi, it is likely those won't work; use those compiled by the compile_ffmpeg.sh script in tools.

What Remains to Be Done

Most the calls are not implemented, just the minimal to get video on the screen. Also, still the audio implementation is missing (but OMX_MediaProcessor class should be ready to play audio as well) and only the QtQuick side is taken into consideration: I've never had the time to look at the widget implementation.

In case you find bugs, try to report an issue on github. If I'll find the time I'll answer.

Edit 6.25.2013

Instantiation of the QQuickView using the RPiQuickView class is no more needed from 30e24106c5dd7a5998d49d7093baef49f332b1d2. I tested this revision with Qt 5.1.1 and everything seems to keep working correctly.

109 comments:

  1. Awesome job! Regarding gst-omx on the Pi, in the beginning of the month I was able to build and use GStreamer-1.0 and gst-omx on the Pi, and get accelerated video output.

    I didn't get very far hacking QtMultimedia into using GStreamer-1.0 instead of 0.10 but reading your post now, maybe this could also be achieved? I guess it would be a parallel solution to the one you've been working on.

    Regardless, awesome job, I had your app running before, made a slight change - included the qtquick2applicationviewer.pri file in order to build, deploy and remotely run the project from Qt Creator.

    ReplyDelete
  2. Hello

    Seems nice !

    But i block width

    #sh compile_ffmpeg.sh
    Downloading ffmpeg sources from git...
    Dir structure is not correct! Aborting. Bye bye.

    Yes i don't have a 3rdparty folder ;o how to get it ?

    thx !

    ReplyDelete
    Replies
    1. Create the directory 3rdparty/ffmpeg in the root. My bad, I forgot to commit it maybe.

      Delete
    2. ouch ... i block with

      #sh prepare_openmaxil_backend.sh 2
      .......
      ../../../omx_camerasurfaceelement.cpp:44:21: fatal error: libv4l2.h: No such file or directory
      compilation terminated.

      ffmpeg seems to be compiled fine but ... :(

      i will try again from 0 ..

      Delete
    3. Why restarting again? That only means you're not providing libv4l2. In PiOmxTextures there is some experimental code to acquire from camera (never completed because Pi seemed to have bad issues with USB drivers). Either remove that class that needs libv4l2 or provide headers and libs.

      Delete
  3. Hello.
    I decided that I should start with a script - ffmpeg.
    I'm trying to run a script compile_ffmpeg.sh - "Dir structure is not correct! Aborting. Bye bye."
    Trying for another.Created these directories -PiOmxTextures/openmaxil_backend/3rdparty/ffmpeg.
    Copied the script to a folder "ffmpeg" - run - "Dir structure is not correct! Aborting. Bye bye."
    How do I start compiling PiOmxTextures?

    ReplyDelete
    Replies
    1. Create the dir 3rdparty/ffmpeg in the root and do not move the script.

      Delete
  4. hi guys, I'm testing with "XmlListModel" using "PiOmxTextures" but have not had good results. I tried "XmlListModel" on a separate example using only this module and it works perfect but when I use it in conjunction with "PiOmxTextures" always gives me the same error and is as follows:

    Error opening :/ playlist.xml: Unknown Error

    The path to the file "playlist.xml" is correct in the program, including an address I gave you absolute that would something like "/ home / pi / playlist.xml" but still giving the same error.

    What I try to do is a video player listed in a XML.

    Someone could help me??

    Thank you.

    PS: The file "main.qml" would be as follows:

    import QtQuick 2.0
    import QtQuick.XmlListModel 2.0
    import com.luke.qml 1.0

    Rectangle {
    id: mainRectangle
    //property int indexFlippable: 0
    property int indexVideo: 0
    property int durationVideo: 0
    property int elapasedTime: 0
    width: 1280
    height: 720
    color: "grey"
    focus: true

    XmlListModel {
    id: xmlModel
    source: "playlist.xml" // <- THIS FAILS
    query: "/contenidos/contenido"

    XmlRole { name: "url"; query: "url/string()" }
    XmlRole { name: "tipo"; query: "tipo/string()" }
    XmlRole { name: "duracion"; query: "duracion/string()" }
    XmlRole { name: "orden"; query: "orden/string()" }

    onStatusChanged: {
    console.log(errorString());
    }
    }

    Timer {
    interval: 1000; running: true; repeat: true
    onTriggered: {
    if (durationVideo < elapasedTime) {
    if (indexVideo < xmlModel.count ) {
    var url = xmlModel.get(indexVideo).url;
    var tipo = xmlModel.get(indexVideo).tipo;
    var duracion = xmlModel.get(indexVideo).duracion;
    var orden = xmlModel.get(indexVideo).orden;

    durationVideo = duracion;

    mediaProcessor.source = url;
    mediaProcessor.play();

    //showXmlData.text = "url: " + url + "\n" +
    // "tipo: " + tipo + "\n" +
    // "duracion: " + duracion + "\n" +
    // "orden: " + orden + "\n";
    indexVideo++;

    if (indexVideo == xmlModel.count) {
    indexVideo=0;
    }

    showXmlData.text = url;

    }
    elapasedTime=0;
    durationVideo=10;
    } else {
    elapasedTime++;
    }
    console.log("Position: " + mediaProcessor.streamPosition + ".");
    showXmlData.text = "Position: " + mediaProcessor.streamPosition + ".";
    }
    }

    OMXMediaProcessor {
    id: mediaProcessor
    source: "updating.mp4"
    }

    OMXVideoSurface {
    id: omxVideoSurface
    width: 1370 //1280
    height: 770 //720
    x: 0
    y: 0
    source: mediaProcessor

    SequentialAnimation {
    id: theAnimation
    PropertyAnimation {
    target: omxVideoSurface
    property: "opacity"
    to: 0.0
    duration: 1000
    }
    PropertyAnimation {
    target: omxVideoSurface
    property: "opacity"
    to: 1.0
    duration: 1000
    }
    }
    }

    Text {
    id: showXmlData
    anchors.centerIn: parent
    text: "show xml"
    }

    }

    ReplyDelete
    Replies
    1. Have you tried to specify a URL instead of a relative or absolute path? So if the abs path to the file is:

      /home/pi/file.xml

      have you tried with:

      file:///home/pi/file.xml?

      Delete
    2. Certainly I have not tried to point to the file that way. The strange thing is that in the example that works using the module "XmlListModel", I use the relative path of the form "playlist.xml" and absolute "/home/pi/playlist.xml" and it works both ways. In the project you created beam (PiOmxTextures) did not recognize such path's.

      I hope your solution works.

      Thanks Guru.

      Delete
    3. Hello Again, I have previous solution worked perfectly but now I have a problem that occurs when I want to load a new video to "video object (mediaProcessor)". I created a timer that runs an object XmlListModel, and in X seconds I reload a new video on the subject mediaProcessor.

      When I use "mediaProcessor.source" to upload a new video, my application crashes. I tried to use it the following way:

      mediaProcessor.source = "newvideo.mp4";
      mediaProcessor.play ();

      but still not working.

      I do not know which way to load a new video and I've tried several ways.

      I thought about creating an object "OMXMediaProcessor" for each file I want to load but do not know which way I can delete the previous object and create a new runtime.

      I hope I can help.

      Thank you.

      PS: I tried to compile ffmpeg for use qtmultimedia but it does not work, perhaps qtmultimedia I work much easier but still can not work. I followed the guide and although it looks very easy, I can not compile ffmpeg.

      Delete
    4. If resetting the source is not working then something is wrong in the implementation: you'll need to have a look and see what is wrong. The qmlvideo applications where loading and unloading the object; I never looked deeply into that documentation, but those seemed to use a Loader. Try to debug a little and see what is crashing.
      I noticed that some deinit of the hardware libs was making it segfault: I didn't have time to analyze so I simply omitted that. Still it might be the case to have a look if you need this.

      Delete
    5. Well, the truth is that I need to get the application as it is something very important for the final development. No I have great knowledge in debug these applications but clearly I'm giving everything I know to get it.

      The final development is that the application has the ability to read an XML file where is the list of content to be reproduced, so that all contents are displayed one after the other without interruption.

      I'm putting in another separate example, the same application but you can read to display web addresses and these addresses can be web pages, videos, widgets, etc..

      Ultimately I want to create a very complete media player for raspberry and remain as open-source project for the use of all.

      I hope I will continue investigating accomplish what I need.

      Perhaps the easiest way is to use QTMultimedia but still can not compile ffmpeg. I hope to have good results in the next test.

      Thank you.

      Delete
    6. What is the error when compiling ffmpeg? Maybe it is the case to open issues on github. If I find the time, I can have a look at those, but my time is limited and I have other projects.

      Delete
    7. Hi again, when I compile ffmpeg I recive the following warning/error:

      WARNING: arm-linux-gnueabihf-pkg-config not found, library detection may fail.

      /bin/sh: 1: arm-linux-gnueabihf-ar: not found
      make: *** [libavdevice/libavdevice.a] Error 127
      Cleaning up...
      mv: cannot `stat' over «ffmpeg_compiled/include»: no such file or directory
      mv: cannot `stat' over «ffmpeg_compiled/lib»: no such file or directory
      Done! Bye bye! ;-)

      Thanks

      Delete
    8. It seems like your toolchain binaries are not in the path.

      Delete
    9. Hi guys, well, I have been looking for ways to create objects dynamically and for this I can use the method "createQmlObject". My intention is to create and destroy the object of video "OMXMediaProcessor" and "OMXVideoSurface" for each video that has to display. I have seen many examples but I always get the error "Qt.createQmlObject (): failed to create object '. I've checked the syntax and I can not find the problem.

      My code to create objects is as follows:

      var objStr = "import QtQuick 2.0;import com.luke.qml
      OMXMediaProcessor {id:mediaProcessor}
      OMXVideoSurface {id:omxVideoSurface;width:1370;height:770;x:0;y:0;source:mediaProcessor}";
      var dynamicObject = Qt.createQmlObject(objStr,mainRectangle,"firstObject");

      I hope someone can help with this.

      Thank you very much.

      Delete
    10. Never used createQmlObject(), but maybe a missing semicolon after import com.luke.qml?

      Delete
    11. I tested with a semicolon and two points but it does not work. I realized that what does not work is when I add "OMXMediaProcessor {id: mediaProcessor};". Will not recognized as QML native object??? I do not know, well, if I keep looking and I'll leave the solution here for everyone.

      Thanks Guru.

      PS: You could send me your email?

      Delete
    12. Did you try using the QtScript object to check what error exactly is thrown? http://qt-project.org/doc/qt-4.8/qml-qt.html#createQmlObject-method

      Delete
    13. So Luca, I'm using the same method (createQmlObject) but found the error checking examples. The problem is that inside the method "createQmlObject" I can not create multiple individual items so that the right way was:

      == Start ==
      objStr var = 'import QtQuick 2.0; import com.luke.qml 1.0;
      Rectangle {
      id: box, color: "red", width: 20, height: 20;

      OMXMediaProcessor {
      id: mediaProcessor '+ indexVideo +';
      source: "'+ url +'"
      }

      OMXVideoSurface {
      id: omxVideoSurface;
      width: 1370;
      height: 770;
      x: 0;
      y: 0;
      source: mediaProcessor '+ indexVideo +'
      }
      } ';
      var dynamicObj1 = Qt.createQmlObject (objStr, mainRectangle "dynamicObject");
      // dynamicObj1.destroy ((duration-1) * 1000); <- if I enable this, the application does not work

      == End ==

      The application now works for me but there are times that when you upload a video, the application freezes. This does not happen often but still happens.

      The other thing that I can not get is to destroy the object created dynamically but I monitored for a time and system resources do not fall.

      I will continue to debug the code and trying other things to let it run best. Perhaps you could try to compile the module QtMultimedia for other tests with this backend.

      Do I have the image that you had uploaded and the links do not work for me but I will try to compile all qt in the system and start over from scratch.

      I hope to have better results.

      Thank you.

      Delete
    14. "Perhaps you could try to compile the module QtMultimedia for other tests with this backend."

      What do you mean?

      "Do I have the image that you had uploaded and the links do not work for me but I will try to compile all qt in the system and start over from scratch."

      Not understanding this either... Are you talking about the image with Qt and whatever inside from the other post? If yes, I said I'll not provide the FTP anymore. Use the edonkey network.

      Delete
    15. yes, I was referring to the image that was on the other post and I've already gotten so I'll try a few things with this.

      Thank you very much.

      Delete
  5. Hello.
    Can not build.
    I did as you said - created a directory 3rdparty/ffmpeg in .../pi.
    I start script compile_ffmpeg.sh .
    Ok.
    I start script prepare_openmaxil_backend.sh . Does not start.
    I created a directory 3rdparty in ..pi/openmaxil_backend .
    I start script prepare_openmaxil_backend.sh .
    Error:not found freetype2.
    export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH.
    I again start script.Error:
    ../../../openmaxiltextureloader.cpp: In member function ‘bool OpenMAXILTextureLoader::loadTextureFromImage(QString, EGLDisplay, EGLContext, GLuint&)’:
    ../../../openmaxiltextureloader.cpp:107:28: error: exception handling disabled, use -fexceptions to enable
    make: *** [.obj/release-shared/openmaxiltextureloader.o] Error 1
    PiOmxTextures built. Copying libs and headers...
    cp: failed stat for «build-PiOmxTextures/piomxtextures/*»: no such file or directory
    Cleaning up...

    ReplyDelete
    Replies
    1. omxplayer requires freetype. It seems it is not found in your sysroot.

      Delete
  6. "freetype" is found(export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH).
    Following error:
    ../../../openmaxiltextureloader.cpp: In member function ‘bool OpenMAXILTextureLoader::loadTextureFromImage(QString, EGLDisplay, EGLContext, GLuint&)’:
    ../../../openmaxiltextureloader.cpp:107:28: error: exception handling disabled, use -fexceptions to enable
    make: *** [.obj/release-shared/openmaxiltextureloader.o] Error 1
    PiOmxTextures built. Copying libs and headers...
    cp: failed stat for «build-PiOmxTextures/piomxtextures/*»: no such file or directory
    Cleaning up...

    Thanks.

    ReplyDelete
    Replies
    1. That pkg config path seems to be the one from your host... anyway, file the issue on github and if I'll have the time I'll have a look. You might try to simply enable the exceptions.

      Delete
    2. ... and report the entire command line that resulted in that error.

      Delete
  7. Hello,

    So damn, i dream to make it work, but i always have error :(

    1/ Install a ubuntu 13.04 on computer ( fresh install )
    2/ Install a raspbian on raspberry ( install package mentioned )
    3/ Install crosscompile tools ( + fix symlink )
    4/ SCP specified folder from raspberry
    5/ Clone qt5 raspberry
    6/ Go to qt5/qtbase for ./configure ..., configure is fine, but it say "XCB = system", i think i need XCB = NO ... but note sure
    6.A/ First configure had error about that it want -qt-xcb or something like that ... i did a ln -s libXext.so.6.4.0 libXext.so in rpi sysroot, and configure is now "okay"
    7/ make => compile for 1 hour and then a error about XCB platform.

    Following error :

    root/opt/vc/include -I/opt/rpi/sysroot/opt/vc/include/interface/vcos/pthreads -I/opt/rpi/sysroot/opt/vc/include/interface/vmcs_host/linux -o .obj/release-shared/qxcbnativeinterface.o qxcbnativeinterface.cpp
    qxcbnativeinterface.cpp: In member function âvoid QXcbNativeInterface::beep()â:
    qxcbnativeinterface.cpp:97:5: error: â::Displayâ has not been declared
    qxcbnativeinterface.cpp:97:16: error: âdisplayâ was not declared in this scope
    qxcbnativeinterface.cpp:97:27: error: â::Displayâ has not been declared
    qxcbnativeinterface.cpp:97:38: error: expected primary-expression before â)â token
    qxcbnativeinterface.cpp:97:39: error: expected â;â before ânativeResourceForScreenâ
    qxcbnativeinterface.cpp:316:1: error: expected â}â at end of input
    qxcbnativeinterface.cpp: At global scope:
    qxcbnativeinterface.cpp:86:1: warning: âqXcbResourceMapâ defined but not used [-Wunused-variable]
    make[5]: *** [.obj/release-shared/qxcbnativeinterface.o] Error 1
    make[5]: Leaving directory `/root/qt5/qtbase/src/plugins/platforms/xcb'
    make[4]: *** [sub-xcb-plugin-pro-make_first-ordered] Error 2
    make[4]: Leaving directory `/root/qt5/qtbase/src/plugins/platforms/xcb'
    make[3]: *** [sub-xcb-make_first] Error 2
    make[3]: Leaving directory `/root/qt5/qtbase/src/plugins/platforms'
    make[2]: *** [sub-platforms-make_first] Error 2
    make[2]: Leaving directory `/root/qt5/qtbase/src/plugins'
    make[1]: *** [sub-plugins-make_first] Error 2
    make[1]: Leaving directory `/root/qt5/qtbase/src'
    make: *** [sub-src-make_first] Error 2


    ReplyDelete
    Replies
    1. okay .. i downloaded the QT 5.0.0 RC2, it seems to success to make qtbase ...

      i guess that the git qt5 give me 5.1 version, and something is wrong with it ....

      I am going to do the next, thx a lot for your blog !

      Delete
    2. I don't see how this is related to the post... Anyway I don't think you want to use the xcb plugin and run the applications on X11. If you do, you'll have to install all the libxcb* packages.

      Delete
    3. Yes sorry ..., but now i have qt5.0.0rc2 working !

      And about this post ... when i test the example qmlvideo .. the video don't play and i have some error about gstreamer*** ( because the error is about gstreamer, i guess that it's not using your openmaxil plugin :(. )

      I have in qt tree /qtmultimedia/plugins/mediaservice/
      - libopenmaxilmediaplayer.so

      and nothing about gstreamer, ( i copy 3rdparty/PiOmxTextures and ffmpeg in /usr in my pi

      Delete
    4. If you get that it probably means you still have the gstreamer plugin in your Pi. Remove that and add the openmax based plugin. Also you'll need to have the correct version of ffmpeg and libPiOmxTextures.so in the linker path.

      Delete
    5. Yes, i checked in the mediaservice on the pi, and deleted all .so related to gstreamer ( only keep libopenmaxilmediaplayer.so )

      and now !

      Module 'QtMultimedia' does not contain a module identifier directive - it cannot be protected from external registrations.
      defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

      When you say 'ffmpeg and libPiOmxTextures.so in the linker path', i just copy ffmpeg lib libPiOmxTextures from 3rdparty in /usr ... i am new to cpp :/

      thx

      Delete
    6. That probably means Qt was unable to load the plugin because the dyn linker returned an error. If you're new to C++ then you should learn it before doing this.

      Delete
  8. Hello.
    After the upgrade I've lost my directory -vchi_local/vchost_config.h in /mnt/rasp-pi-rootfs/opt/vc/include/interface/vmcs_host/ .
    I see this error:"make: *** No rule to make target `/mnt/rasp-pi-rootfs/opt/vc/include/interface/vmcs_host/vchi_local/vchost_config.h', needed by `.obj/release-shared/openmaxiltextureloader.o'. Stop."
    Tell me please what to do?Can copy a lost directory from the old version(copy before upgrade)?
    Thanks.

    ReplyDelete
    Replies
    1. I found it:Need to add -I/opt/vc/include/interface/vmcs_host/linux to CFLAGS.

      Delete
  9. Has anyone tried the QT5 sources for raspberry from "http://twolife.be/raspbian/"??? I've done it and I've managed to create some things smoothly. I tried even the samples Luca and I work (of course I had to install additional libraries but everything goes on errors) and are already pulling the 5.0.2 version but still a qtbase package to install / upgrade files new version. Maybe they could try this repo.

    Luca I ask a question??, You have tested this repo?? We will have to make many changes in the script to install the new backend for qtmultimedia??

    Greetings and thanks.

    ReplyDelete
    Replies
    1. Hi. Sorry never tried, I build my own Qt. The plugin should be compatible with any Qt 5.0 build I suppose, but there is a modification in QtMultimedia.

      Delete
  10. Hello,

    great functionnality !

    I success compiled and play video with PiOmxTexture ( APP )

    But with the basic qmlvideo example, i get

    ---------------------------------------------------------------
    Module 'QtMultimedia' does not contain a module identifier directive - it cannot be protected from external registrations.
    Creating player service...
    Instantiating QMediaService...
    OpenMAXILPlayerControl::OpenMAXILPlayerControl(QObject*)
    Requesting control for org.qt-project.qt.metadatareadercontrol/5.0...
    Requesting control for org.qt-project.qt.mediaavailabilitycontrol/5.0...
    Requesting control for org.qt-project.qt.mediaplayercontrol/5.0...
    Requesting control for org.qt-project.qt.medianetworkaccesscontrol/5.0...
    virtual QMediaPlayer::State OpenMAXILPlayerControl::state() const
    virtual QMediaPlayer::MediaStatus OpenMAXILPlayerControl::mediaStatus() const
    virtual QMediaPlayer::MediaStatus OpenMAXILPlayerControl::mediaStatus() const
    Requesting control for org.qt-project.qt.videorenderercontrol/5.0...
    virtual void OpenMAXILVideoRendererControl::setSurface(QAbstractVideoSurface*)
    virtual int OpenMAXILPlayerControl::volume() const
    virtual void OpenMAXILPlayerControl::setVolume(int)
    [qmlvideo] Content.initialize: complete
    [qmlvideo] SceneBasic.onClicked, started = false
    [qmlvideo] Content.start
    virtual void OpenMAXILPlayerControl::stop()
    Stop
    virtual void OpenMAXILPlayerControl::setMedia(const QMediaContent&, QIODevice*)
    /root/piomxtextures/vans.avi
    setMedia thread is: 0x88b6f8.
    Deferring setMedia()...
    virtual void OpenMAXILPlayerControl::setPosition(qint64)
    virtual void OpenMAXILPlayerControl::play()
    Deferring play() command...
    --------------------------------------------------------------------

    and nothing on the display :s

    ReplyDelete
    Replies
    1. Hi,

      I make it work with a simple multimedia test, it work, bug it seems that change the source of the player make it crash ( and i guess this is why the qt multimedia example crash too )

      import QtQuick 2.0
      import QtMultimedia 5.0

      Rectangle {

      MouseArea {
      anchors.fill: parent
      onClicked: {
      player.source = "/test1.avi";
      }
      }


      width: 1920
      height: 1080

      color: "black"

      MediaPlayer {
      id: player
      source: "/video.avi"
      autoPlay: true
      }

      VideoOutput {
      id: videoOutput
      source: player
      anchors.fill: parent
      }
      }

      Delete
    2. I just tried and qmlvideo seems to work for me at the moment, although I have to say I might be using a slightly different version at the moment, which makes my test a little useless. Did you apply the changes to qmlvideo to export the sysmbol?

      Delete
    3. Hello,

      I apply the patch that add -rdynamic and add your class in the qmlvideo example.

      After test, the change of source completely fail, the pause / stop also, i can get the position / duration data without problem.

      Some output of the source change ( video.avi to test1.avi ):


      root@raspberrypi:~/qt5_video# ./video
      Module 'QtMultimedia' does not contain a module identifier directive - it cannot be protected from external registrations.
      Creating player service...
      Instantiating QMediaService...
      OpenMAXILPlayerControl::OpenMAXILPlayerControl(QObject*)
      Requesting control for org.qt-project.qt.metadatareadercontrol/5.0...
      Requesting control for org.qt-project.qt.mediaavailabilitycontrol/5.0...
      Requesting control for org.qt-project.qt.mediaplayercontrol/5.0...
      Requesting control for org.qt-project.qt.medianetworkaccesscontrol/5.0...
      virtual QMediaPlayer::State OpenMAXILPlayerControl::state() const
      virtual QMediaPlayer::MediaStatus OpenMAXILPlayerControl::mediaStatus() const
      virtual QMediaPlayer::MediaStatus OpenMAXILPlayerControl::mediaStatus() const
      virtual void OpenMAXILPlayerControl::play()
      Deferring play() command...
      Requesting control for org.qt-project.qt.videorenderercontrol/5.0...
      virtual void OpenMAXILVideoRendererControl::setSurface(QAbstractVideoSurface*)
      virtual void OpenMAXILPlayerControl::stop()
      Stop
      virtual void OpenMAXILPlayerControl::setMedia(const QMediaContent&, QIODevice*)
      /video.avi
      setMedia thread is: 0x1e207b8.
      Deferring setMedia()...
      virtual void OpenMAXILPlayerControl::play()
      Deferring play() command...
      Renderer thread is: 0x1e4e3d8.
      Processing post play()...
      void OpenMAXILPlayerControl::playInt()
      Play
      Processing post setMedia()...
      void OpenMAXILPlayerControl::setMediaInt(const QMediaContent&)
      Opening...
      Input #0, avi, from '/video.avi':
      Metadata:
      encoder : Lavf54.25.100
      Duration: 00:01:49.37, start: 0.000000, bitrate: 1263 kb/s
      Stream #0:0: Video: h264 (Constrained Baseline) (H264 / 0x34363248), yuv420p , 720x406, 25 fps, 25 tbr, 25 tbn, 50 tbc
      Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 1 51 kb/s
      Initializing OMX clock...
      Opening video using OMX...
      virtual OMX_TextureData* OpenMAXILPlayerControl::instantiateTexture(QSize)
      Video codec omx-h264 width 720 height 406 profile 578 fps 25.000000
      Opening audio using OMX...
      Audio codec aac channels 2 samplerate 44100 bitspersample 16
      Executing clock...
      Processing post play()...
      void OpenMAXILPlayerControl::playInt()
      Play
      Starting thread.
      Decoding thread started.
      Buffering timed out.
      void OpenMAXILVideoRendererControl::onTextureReady(const OMX_TextureData*)
      Status: 1
      States: undefined
      virtual qint64 OpenMAXILPlayerControl::duration() const
      Duration: 109365
      virtual qint64 OpenMAXILPlayerControl::position() const
      Position: 5921088
      virtual void OpenMAXILPlayerControl::stop()
      Stop
      Waiting for the stop command to finish.
      Cleaning up...
      Stopping OMX clock...
      Closing players...
      Closing players...
      Freeing texture...
      virtual void OpenMAXILPlayerControl::freeTexture(OMX_TextureData*)
      Stop command issued.
      virtual void OpenMAXILPlayerControl::setMedia(const QMediaContent&, QIODevice*)
      /test1.avi
      setMedia thread is: 0x1e207b8.
      Deferring setMedia()...
      virtual void OpenMAXILPlayerControl::play()
      Deferring play() command...
      virtual void OpenMAXILPlayerControl::play()
      Cleanup done.
      Deferring play() command...
      void OpenMAXILVideoRendererControl::onTextureInvalidated()


      Don't understand why "deffering .. " :(

      Delete
    4. I need to defer because the set of a new media must be done in the rendering thread where the OpenGL and the EGL contexts are available. Those calls arrive from Qt in a different thread.

      Anyway, I don't think I ever tried to change the media resetting the source, I think qmlvideo and qmlvideofx free the media object entirely. It must be fixed, file the issue on github and I may have a look later.

      Delete
    5. A other test, show that when using the qtmultimedia, video need to be play at the start, if i dynamicaly create qml video after start, i get deffering ;o ( like in the example bellow )

      But with the piomxtextures project, this work ( but i have some "glitch" on the video ) :

      Next step is to read your cpp code ;)

      Item{
      id: containerVideo
      width: 1920; height: 1080
      property int elapsedTimeVideo: 0
      property variant videoQml: 0
      Timer {
      interval: 1000; running: true; repeat: true
      onTriggered: {
      containerVideo.elapsedTimeVideo += 1;

      console.log('time elapsed =>'+containerVideo.elapsedTimeVideo);

      function player_video(url_video){

      containerVideo.videoQml = Qt.createQmlObject('import QtQuick 2.0;import com.luke.qml 1.0; Item{ OMXMediaProcessor { id: mediaProcessor; source: "'+url_video+'" } OMXVideoSurface {id: omxVideoSurface; width: 1920; height: 1080; x: 0; y: 0; source: mediaProcessor } } ', containerVideo, "dynamicSnippet1");

      }

      if(containerVideo.elapsedTimeVideo == 1){

      player_video('/video/video1.avi');


      }else if(containerVideo.elapsedTimeVideo == 109){

      player_video('/video/video2.avi');

      }else if(containerVideo.elapsedTimeVideo == 226){

      player_video('/video/video3.avi');

      }else if(containerVideo.elapsedTimeVideo == 370){

      player_video('/video/video4.avi');

      }

      }
      }

      }

      Delete
    6. I committed a quick fix to allow reset of the source. Very simple, just a missing implementation. Anyway, still there are cases where omxlpayer code asserts, mostly when rapidly restting, so I closer look is needed. Bye.

      Delete
    7. Hello, thx for fix

      I started again with qt 5.01, now the qmlvideo example "work" !

      I still cannot change source :(, it block in "deferring...."

      -----------------------------------------------
      time elapsed =>58
      time elapsed =>59
      time elapsed =>60
      virtual void OpenMAXILPlayerControl::stop()
      Stop
      Waiting for the stop command to finish.Cleaning up...
      Stopping OMX clock...

      Closing players...
      Closing players...
      Stop command issued.
      virtual void OpenMAXILPlayerControl::setMedia(const QMediaContent&, QIODevice*)
      /video.avi
      setMedia thread is: 0x4d87b8.
      Deferring setMedia()...
      virtual void OpenMAXILPlayerControl::play()
      Deferring play() command...
      Cleanup done.
      Freeing texture...
      virtual void OpenMAXILPlayerControl::freeTexture(OMX_TextureData*)
      void OpenMAXILVideoRendererControl::onTextureInvalidated()
      time elapsed =>61
      time elapsed =>62
      -----------------------------------------------

      i am not sure what onTextureInvalidated means :/

      Delete
  11. in tests I did and everything worked fine, I did keep track of time (about 6 hours) and finally the app froze. The last info was that I used a lot of memory (about 800MB) and reached 60% CPU usage.

    I realize that I can not release the entire video object and is the reason why the app fails.

    I will continue testing.

    Greetings.

    ReplyDelete
    Replies
    1. I never test for more than a couple of minutes so it is likely to fail a long play. As said in the other article, this is just a proof of concept.

      Anyway, your test is interesting: 6 hours of continuous play? Or you mean 6 hours changing the video source? Or only play after the video is finished?

      Delete
  12. Well, now I'm doing more tests but the only problem presented to me is that resource consumption rises too much and ends up freezing the application. Now I'm looking for some kind of event that can be assigned to the object "OMXMediaProcessor" or "OMXVideoSurface". Here is a example:

    Rectangle {
         id: rect
         width: 80, height: 80
         color: "red"

         NumberAnimation on opacity {
             to: 0
             duration: 1000

             onRunningChanged {
                 if (! running) {
                     console.log ("Destroying ...")
                     rect.destroy ();
                 }
             }
         }
    }

    This is the event I'd like to use but in "OMXMediaProcessor" and "OMXVideoSurface" can not be used.

    It may do something similar???

    Thank you.

    ReplyDelete
    Replies
    1. If by event you mean animation then I suppose alpha may not work. You can do other animations anyway as shown in the videos.

      If you want something more you might want to have a look at the QtMultimedia backend instead of the custom components. That might support something more through shaders.

      Delete
    2. Sorry, I think I did not explain enough. What I do is use an event let me know when the video has reached its end and then perform the action of destroying the video object. As an example I set the code above, where used alpha effect but in my case would be to detect the end of the video playback.

      In short, what are the events supported by "OMXMediaProcessor" and "OMXVideoSurface"???

      Thank you very much.

      Delete
    3. Those objects were only used to present the concept, I won't update those anymore. Now you should use the QtMultimedia backend. The events provided anyway should be those exposed in the header: https://github.com/carlonluca/pi/blob/master/omx_mediaprocessorelement.h. Never tested anyway.

      Delete
    4. I understand the situation.

      Thank you very much for the great contribution.

      Delete
  13. Hi Guys, Today I tried to compile the project PIOmxTexture but I had problems with the following error:

    omxplayer_lib/utils/traits.hpp:141:5: error: expected unqualified-id before ‘using’

    Someone can give me a hand ??

    Thanks.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Hello! Thanks for some really nice guides on how to compile QT for the RPI. As a comment, I tried compiling the latest version (after the 25.6 edit) but it resulted in compilation errors. They were solved by installing libv4l2-dev (libv4l2.h missing in omx_camerasurfaceelement.cpp) and libboost1.5-dev (boost missing in omxplayersubtitles.h). Once those were installed everything compiled as it should.

    However, I still have some problems getting the examples to run. I've run all the tools succesfully and copied the resulting folder to the qtmultimedia plugin-folder as instructed, then I patched and re-installed the qtmultimedia-module with the instructed config. However, I still get "Warning: "No decoder available for type 'video/x-h264.." when I try to run the qmlvideo-example. I'm not sure if ffmpeg didn't install correctly or if I'm missing something else. I'm not sure what the last part means "Of cuorse, you'll have to copy the Qt libraries that are built to your Pi, together with libPiOmxTextures.so.." does this mean anything else than having to re-flash the SD-card with the new installs? I'm not very familiar in this environment.

    Thank you.

    ReplyDelete
    Replies
    1. You have to provide the system all that is needed to load the Qt Multimedia implementation, which means: the Qt beckend goes into the proper directory for Qt to find (plugins/mediaservice), the modified version of the Qt module after the patch was applied, the correct version of ffmpeg according to the scripts provided on github and the libPiOmxTextures library, which is currently shared lib (I plan to switch to a static version, makes more sense). Put all this into your Pi and ensure the dynamic linker links to those libs. No re-flash.

      The error you report suggests more something related to encoding, like Qt is trying to decode using the gstreamer plugin... Is this possible?

      Delete
    2. I interpreted the problem like you said, that Qt is trying to use gstreamer instead of openmaxil, but attributed the problem to probably not having the correct libraries in the correct places (I'm quite new to both linux and Qt). Surprised that there was no warning about the libraries not being found though. But I understood it as when all files are in place, the qmlvideo-example should use the openmaxil-backend without needing to adjust the code in the example? Still a bit unsure of specifically which of the folders should go where, like I said I haven't had any warnings of missing files. I interpret it as the contents of the created openmaxil_backend-folder should be directly copied to /usr/local/qt5pi/plugins on the pi and the libPiOmxTextures.so file goes into ../qt5pi/plugins/mediaservice? Should the ffmpeg-folder created be copied to /usr/lib? Sorry if these questions are very elementary.

      I've been given the task to try and create a lightweight browser for the RPi that can play a 720p-video stream at a certain location in the window, figured I could try building a Qt-webkit-browser with your openmaxil-plugin.

      Delete
    3. Yes, if you recently cloned the repo, no modification is needed to the application.
      For specific information about plugins location, refer to the Qt documentation. Anyway, I suggest you remove the old gstreamer plugin, so that there is no ambiguity. Only keep the OpenMAXIL plugin and place it in the correct location.

      As for the rest, I suggest you have a look at some manuals. You need some understanding of Linux. However, libs needed by the linker must be placed in the default locations or otherwise specified with LD_LIBRARY_PATH.

      Delete
    4. Thank you for the replies. I think I figured out how to link the libraries and while I've stopped getting the "no decoder available"-error, now when I try to start a video in the application(same in qmlvideo and qmlvideofx) the application crashes with:

      bash: line 1: 2167 Illegal instruction DISPLAY=:0.0 /home/pi/multimedia/video/qmlvideofx/qmlvideofx
      Remote application finished with exit code 132.

      Any suggestions what might cause it?

      Delete
    5. I'm sorry, I don't exactly know. Are you able to run any Qt/QML application at all? Seems like it is trying to use X11... Are you using the xcb platform plugin by any chance?

      Delete
    6. Yes, I can run the qmlvideo-example up until the point that I have to "tap" to display the video. Same thing in qmlvideofx, as soon as the program tries to start displaying a video the app crashes. Does the openmaxil-backend require wayland to run? It's not really mentioned in the post/documentation or then I might have just missed it. I've only compiled QT and applied the instructions in this post, I haven't touched either Wayland or xcb, so I assume that it uses the default plugins and X11.

      Delete
    7. X11 is rarely used when it comes to embedded hardware. Performance is bad and rarely hw acceleration is supported in there. I'm not sure for Raspberry. Anyway I've never tested the plugin on X11 nor I've tested on Wayland. I've always used eglfs. I might have omit that information.

      Delete
    8. Got the plugin to work after your commit that improved the rotations. I misunderstood the system earlier and it did use EGLFS all along but for some reason just didn't work. Now that I've got it to work though it sometimes produces this error:

      Requesting control for org.qt-project.qt.videowindowcontrol/5.0...
      Requesting control for org.qt-project.qt.videorenderercontrol/5.0...
      [0;34mvirtual void OpenMAXILVideoRendererControl::setSurface(QAbstractVideoSurface*)
      [0;37m
      This plugin does not support propagateSizeHints()

      When I for example try to use it in a videowidget. Any Ideas as to what might be causing it? Awesome work overall by the way!

      Delete
    9. What do you mean by "videowidget"? Anyway, that message should not be related to PiOmxTextures or the openmaxil plugin. I suppose that is related to the eglfs plugin.

      Delete
    10. Well I was trying to see if the plugin would work in this example:

      http://qt-project.org/doc/qt-5.0/qtmultimedia/multimediawidgets-videowidget.html

      The console suggest the openmaxil-plugin is activating but no output is displayed. Though if the problem mentioned above might have something to do with it, but you're probably right that it's related to eglfs.

      Delete
    11. Not sure whether that will work. That example is QWidget based. I only tested QML-based applications. If you want to test a standard Qt example I suggest the qml examples.

      Delete
  16. Hey, good work!

    However I can't make it work. It finally compiled successfully and it produced the libraries here:

    ls /usr/local/qt5pi/plugins/mediaservice/
    libopenmaxilmediaplayer.so libqtmedia_audioengine.so

    Also i copied all 3rdparty libraries to /usr/local/:

    ls /usr/local/3rdparty/
    PiOmxTextures ffmpeg

    I set up ldconfig with this file:
    cat /etc/ld.so.conf.d/omx.conf
    /usr/local/3rdparty/PiOmxTextures/lib
    /usr/local/3rdparty/ffmpeg/lib

    ldconfig -v shows how he properly finds all libraries form these new directories.

    Also I checked with ldd, and all libs seems present in the system...

    Also the test project was cleaned and recompiled, but i still get this error:

    Module 'QtMultimedia' does not contain a module identifier directive - it cannot be protected from external registrations.
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

    Any idea what I'm doing wrong?

    ReplyDelete
  17. Hey, good work!

    However I can't make it work. It finally compiled successfully and it produced the libraries here:

    ls /usr/local/qt5pi/plugins/mediaservice/
    libopenmaxilmediaplayer.so libqtmedia_audioengine.so

    Also i copied all 3rdparty libraries to /usr/local/:

    ls /usr/local/3rdparty/
    PiOmxTextures ffmpeg

    I set up ldconfig with this file:
    cat /etc/ld.so.conf.d/omx.conf
    /usr/local/3rdparty/PiOmxTextures/lib
    /usr/local/3rdparty/ffmpeg/lib

    ldconfig -v shows how he properly finds all libraries form these new directories.

    Also I checked with ldd, and all libs seems present in the system...

    Also the test project was cleaned and recompiled, but i still get this error:

    Module 'QtMultimedia' does not contain a module identifier directive - it cannot be protected from external registrations.
    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

    Any idea what I'm doing wrong?

    ReplyDelete
    Replies
    1. If the plugin can find its libs it should load fine. Some more debugging information is needed, maybe try with QT_DEBUG_PLUGINS=1.

      Delete
  18. Hello everyone.

    I use QT 5.1.1 from git, and i encounter the following problems:
    1. The stop method doesnt work. there is no way to stop a video (however pause and play after pause do work)
    2. After the video finished playing, there is no way to play it again.

    From those of you who managed to make this work, do you encounter the same problems?
    Thanks in advance.

    ReplyDelete
  19. Quick question, the compile_ffmpeg-tools seems to assume that I have a raspbian cross-compilation toolchain ready to use, which I do not. Which are the necessary steps I need to take before I can fully build this? I'm on a pretty much clean install of a Xubuntu host machine.

    I managed to get my hands on a pre-built package of yours, which worked very well I might add, with the exception of looping video, which I saw that you have fixed in your latest changes, why I need to patch the image.

    ReplyDelete
    Replies
    1. You'll need the Linaro toolchain for Raspberry (you can find it online) and a sysroot that you can create from the image you say you have. The older posts about building Qt may help you (although you don't have to actually rebuild Qt, that is already available in the image). That patch should only be applied to PiOmxTextures if I remember correctly.

      Delete
    2. This comment has been removed by the author.

      Delete
  20. Hello,
    Great job!
    I have begun testing on 5.2 and have a problem.
    You have plans to continue the code?
    Tomorrow I try to send some pull request if I can fix the problem.
    thanks

    ReplyDelete
    Replies
    1. Hello. I have already tested on 5.2 months ago and I had no problems. What are you experiencing?
      I stopped to work on this many months ago as it seems the challenging part is completed, so not much is needed at the moment.

      Delete
    2. I tested again with Qt tag v5.2.0 and the latest Raspbian image (2013.12.20). I had no issues.

      Delete
  21. Hello, were right!.
    Works perfectly was a problem with my cross-compile
    Sorry for the inconvenience, Thanks

    ReplyDelete
  22. Hello ,soryy about my english first.I'm newby to on everything.
    I try to compile pi-master on ubuntu 13. with raspberry toolchain.
    ./compile_ffmpeg.sh 1 .. done ok.
    ./prepare_openmaxil_backend.sh 1 ..error on make
    .
    cc1plus: error: unrecognized command line option '-std=c++11'
    .
    "-std=c++11" i not know from where the option come from ,may everyone can resolve this
    thak's

    ReplyDelete
    Replies
    1. It seems like you're using a wrong toolchain as c++11 should be supported with linaro.

      Delete
  23. Hello, I am trying to find a method to play video in my QML application using Qtcreator 4.7. I am designing a UI for a Kiosk and i need the video to play in a never ending loop when the project is run. Cn youhelp me with an example of how the coding should be for this?

    ReplyDelete
    Replies
    1. Sources are available already on guthub.

      Delete
  24. This comment has been removed by the author.

    ReplyDelete
  25. Hi,
    First, thanks for your job with qt and omx!
    After cross compiling your scripts, when I tryed to run the example on the tools folder, it showed my the following error:

    qrc:///qml/main.qml:80:5: Type POC_MetaData unavailable
    qrc:///qml/POC_MetaData.qml:29:1: Type POC_AnimatedOverlay unavailable
    qrc:///qml/POC_AnimatedOverlay.qml:25:1: module "QtQuick.Layouts" is not installed

    The QtQuick issue should be my fault. I'll check if I missed some cross compiling, but what about the MetaData? Did happen before to you?

    Thanks!

    ReplyDelete
    Replies
    1. You're missing a Qt module. I don't know for the other part, sorry. Maybe it is caused by the missing module, I don't know.

      Delete
    2. This comment has been removed by the author.

      Delete
  26. hello again.
    libopenmaxilmediaplayer ..running good on eglfs ,
    but if i update rpi firmware ,video canvas become mirroring upside down.
    thank's for your sharing ....
    soory with my english

    ReplyDelete
    Replies
    1. Hello! Thanks for sharing.
      Yes, as I pointed out in a recent post on the blog (http://thebugfreeblog.blogspot.it/2014/04/updates-on-hardware-accelerated-qt.html), I uploaded a new patch to Qt Multimedia. Maybe Broadcom fixed something in the omx component and now the patch I had to add is no more needed.
      Bye!

      Delete
  27. Hello. Thanks for your job.
    Can you help me with video on my Raspberry pi.
    I installed QT5 using this article http://qt-project.org/wiki/Native_Build_of_Qt5_on_a_Raspberry_Pi .I can native build sample.
    Now i want to install hardware acselerating for playing video.I clone your git. I ran pi/tools/compile_ffmpeg.sh and got "Please, set the path to your sysroot in RPI_SYSROOT first." what RPI_SYSROOT it?
    From your article http://thebugfreeblog.blogspot.it/2013/03/bring-up-qt-501-on-raspberry-pi-with.html i read that "Instead of the loopback mount of the image on your system to get a correct sysroot, I quickly scp'ed the needed binaries from my board to a newly created sysroot. In particular I copied:
    /lib
    /usr/lib
    /usr/include
    /opt
    I'll refer to the directory containing all of this as rasp_sysroot. Quick and dirty. You might also consider using rsync though.
    As a final note on this I have to say that scp has the somehow pleasant collateral effect of following the symlinks in libs."

    Why is it? Should I create rasp_sysroot on my home folder? Should I copy /lib,/usr/lib,/usr/include,/opt to rasp_sysroot?

    ReplyDelete
    Replies
    1. > Why is it?

      Why what? Why you need to scp?

      > Should I create rasp_sysroot on my home folder?

      If that is a good location for you yes.

      > Should I copy /lib,/usr/lib,/usr/include,/opt to rasp_sysroot?

      Yes.

      Delete
    2. Hello Luca. Sorry with my english. I dont use cross compiling. I will create i small project (it will loop playing 720p h.264 video on Pi). I bilt qt5 on Pi for native using (using this http://qt-project.org/wiki/Native_Build_of_Qt5_on_a_Raspberry_Pi). Now i can qmake and make project on Pi. I ran examles sach as analogclock, cube it are work. But then i start /home/pi/opt/qt5/qtmultimedia/examples/multimediawidgets/player i have got the error "The QMediaPlayer object does not have a valid service. Please check the media service plugins are installed"
      In your article i see that you able to play video from qt5 on Pi. I don't understand how i can install your lib to my envoirment for playng video. Can you help me, i need step by step guide.
      Now i downloaded POCPlayer into my Pi, run qmake and make. I ran POCPlayer and have got :

      Delete
    3. pi@raspberrypi ~/opt/qt5/qtmultimedia/examples/multimedia/POCPlayer $ ./POCPlayer
      defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/SourceProxy.qml:84: TypeError: Type error
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/SourceProxy.qml:84: TypeError: Type error
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/SourceProxy.qml:84: TypeError: Type error
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/SourceProxy.qml:84: TypeError: Type error
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/FastGlow.qml:132:25: Unable to assign [undefined] to QByteArray
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/FastGlow.qml:131:23: Unable to assign [undefined] to QByteArray
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/BasicButton.qml:146:29: Unable to assign [undefined] to QString
      file:///usr/local/qt5/qml/QtQuick/Controls/Button.qml:85:22: Unable to assign [undefined] to QString
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/BasicButton.qml:146:29: Unable to assign [undefined] to QString
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/BasicButton.qml:146:29: Unable to assign [undefined] to QString
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/BasicButton.qml:146:29: Unable to assign [undefined] to QString
      file:///usr/local/qt5/qml/QtQuick/Controls/Private/BasicButton.qml:146:29: Unable to assign [undefined] to QString
      Can't find extension for .
      Can't find extension for image/jp2.
      Can't find extension for image/vnd.microsoft.icon.
      Can't find extension for image/x-dds.
      Can't find extension for image/x-icns.
      Can't find extension for image/x-mng.

      Delete
    4. For a step by step guide read the article. There is a paragraph titled "How to Build".

      Delete
    5. I installed libqt5multimedia5-plugins, after this i can play video from omxplayer. Before this installation i did not play video from omxplayer. After instalation libqt5multimedia5-plugins i can not make any examples, o got error: /usr/bin/ld: warning: libGLESv2.so.2, needed by /usr/lib/arm-linux-gnueabihf/libQt5OpenGL.so.5, not found (try using -rpath or -rpath-link)
      /usr/lib/arm-linux-gnueabihf/libQt5OpenGL.so.5: undefined reference to `QFontEngine::glyphCache(void const*, QFontEngineGlyphCache::Type, QTransform const&) const'
      collect2: ld returned 1 exit status
      make: *** [player] Error 1


      Delete
    6. As far as I know there is no relation whatsoever between omxplayer and Qt. PiOmxTextures does not interfere in any way with libQt5OpenGL. It only modifies libQt5Multimedia.

      Delete
  28. >For a step by step guide read the article. There is a paragraph titled "How to Build".
    I cloned your git to home. I ran pi-master/tools $ sudo ./compile_ffmpeg.sh 2 and got error "
    ./compile_ffmpeg.sh: 20: ./compile_ffmpeg.sh: RPI_SYSROOT: Please, set the path to your sysroot in RPI_SYSROOT first."

    ReplyDelete
    Replies
    1. Correct, you have to specify the location of your sysroot.

      Delete
  29. sorry for noob's questions. what location must i specify. I dont use rpi_sys_root folder for cross compile, becouse i use native bild qt5 on pi. My QT5 installed into /usr/local/qt5
    And where can i specify this location.

    ReplyDelete
    Replies
    1. Those script are for crossbuilding, sorry. I never built directly on the Pi, it is too slow. If you need to do that you'll have to read the scripts and do the same on the Pi.

      Delete
    2. yes first bilding was very slowly. it was for 2 days)).

      Delete
  30. i read the script. I dont understand what path i must use instread RPI_SYS_ROOT

    ReplyDelete
    Replies
    1. You're probably better off reading a crossbuilding guide for that.

      Delete
  31. Hi guys, today I probe to compile qt5.3 but this dont work. Always I get this next message:

    qlibrary_unix.cpp:(.text+0x111c): aviso: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): En la funci?n `dlopen':
    (.text+0xc): referencia a `__dlopen' sin definir
    /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlclose.o): En la funci?n `dlclose':
    (.text+0x0): referencia a `__dlclose' sin definir
    /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlsym.o): En la funci?n `dlsym':
    (.text+0xc): referencia a `__dlsym' sin definir
    /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlerror.o): En la funci?n `dlerror':
    (.text+0x0): referencia a `__dlerror' sin definir
    /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libm.a(feholdexcpt.o): En la funci?n `feholdexcept':
    (.text+0x48): referencia a `_dl_hwcap' sin definir
    /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libm.a(fesetenv.o): En la funci?n `fesetenv':
    (.text+0x64): referencia a `_dl_hwcap' sin definir
    collect2: error: ld returned 1 exit status
    make[2]: *** [../../lib/libQt5Core.so.5.3.0] Error 1
    make[2]: Leaving directory `/home/andres/opt/qt5/qtbase/src/corelib'
    make[1]: *** [sub-corelib-make_first] Error 2
    make[1]: Leaving directory `/home/andres/opt/qt5/qtbase/src'
    make: *** [sub-src-make_first] Error 2

    I have Ubuntu 14.04 x64.

    Someone know soution to this problem ??

    Thanks.

    ReplyDelete
    Replies
    1. Problem solved. Only I need run "fixQualifiedLibraryPaths" script.

      Delete
  32. Hey Luca,

    Now that qt 5.4RC is out i tried to build you work against it, but with no luck.

    Any plans to update your instructions for qt 5.4 ? thanks.

    ReplyDelete
    Replies
    1. I'm sorry. I'm working on many projects at the moment so I don't know whether I'll be interested in trying new Qt versions or firmwares.

      Delete
  33. to be a bit more precise here is the issue i'm facing :

    i can get ffmpeg to build, although i needed to add -b to the git checkout n.2.2 line in compile_ffmpeg.sh script
    then when i use the prepare script i get a warning (not sure this is normal)

    Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version.
    Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point.
    Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned!

    it seems tocontinue though, but then when it starts building i'm getting :

    omx_mediaprocessor.cpp
    In file included from ../../../omxplayer_lib/OMXPlayerAudio.h:27:0,
    from ../../../omx_playeraudio.h:30,
    from ../../../omx_mediaprocessor.cpp:37:
    ../../../omxplayer_lib/DllAvFilter.h: In member function ‘virtual int DllAvFilter::avfilter_graph_parse(AVFilterGraph*, const char*, AVFilterInOut**, AVFilterInOut**, void*)’:
    ../../../omxplayer_lib/DllAvFilter.h:127:75: error: cannot convert ‘AVFilterInOut**’ to ‘AVFilterInOut*’ for argument ‘3’ to ‘int avfilter_graph_parse(AVFilterGraph*, const char*, AVFilterInOut*, AVFilterInOut*, void*)’
    ../../../omx_mediaprocessor.cpp: In member function ‘void OMX_MediaProcessor::mediaDecoding()’:
    ../../../omx_mediaprocessor.cpp:731:13: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
    In file included from ../../../omxplayer_lib/OMXPlayerAudio.h:27:0,
    from ../../../omx_playeraudio.h:30,
    from ../../../omx_mediaprocessor.cpp:37:
    ../../../omxplayer_lib/DllAvFilter.h: In member function ‘virtual int DllAvFilter::avfilter_graph_parse(AVFilterGraph*, const char*, AVFilterInOut**, AVFilterInOut**, void*)’:
    ../../../omxplayer_lib/DllAvFilter.h:128:3: warning: control reaches end of non-void function [-Wreturn-type]
    make: *** [omx_mediaprocessor.o] Error 1

    Any thoughts about where this could come from ?

    ReplyDelete
    Replies
    1. Ok i think i found the issue, was coming from obviously using the wrong ffmpeg branch, which means that piOmxTexture doesnt seem to build on ffmpeg 2.4 ..

      Delete