Friday, December 26, 2014

Binaries for Hardware Accelerated Qt Multimedia Backend on Raspberry Pi

As someone still have troubles building PiOmxTextures, I prepared a little package that contains the binaries needed to make it run and have a look. In the past I tried to provide an entire firmware, but it was large to upload and not very comfortable to update. This package only contains:

  • PiOmxTextures.tar: library to provide the playback capabilities, including ffmpeg 2.5.
  • Qt-rasp-5.4.0.tar: the entire tree of Qt 5.4.0 binaries built for Raspberry Pi (firmware ba43047, rpath is set to /usr/local/Qt-rasp-5.4.0).
  • Qt-rasp-5.4.0_host.tar: the utility to be used on the host when cross-building (built for x86 Kubuntu 13.10).
Current version of the package is 4.3.0: download.

To have a quick look, just place Qt-rasp-5.4.0 in /usr/local into your Pi, then place PiOmxTextures somewhere and add it to the runtime library path. Now you can test running qmlvideo or qmlvideofx from the Qt Multimedia examples. Something similar to this should come up: 
Bye! ;-)

42 comments:

  1. This is great thank you very much for your efforts, sorry for the dumb question but could you elaborate on how I "add it to the runtime library path"??

    ReplyDelete
    Replies
    1. http://www.eyrie.org/~eagle/notes/rpath.html

      Delete
    2. Thanks for this, works perfectly for me now.

      Delete
  2. Thanks man! Thats a nice Xmas gift

    ReplyDelete
  3. Should I use these steps ("http://thebugfreeblog.blogspot.com.br/2013/03/raspberry-pi-wheezy-image-with-qt-and.html) to setup QT properly?

    ReplyDelete
    Replies
    1. I don't know what you mean by setup. Do you want to run something on the Pi or to build something else with Qt?

      Delete
    2. I want to setup QT in my Ubuntu/x86 to cross compile with the provided tools (Qt-rasp-5.4.0_host.tar)

      QT is refusing the provided qmake when I add it on "Options > Build & Run > Qt Versions".

      Qmake not executable: "The qmake executable /usr/local/Qt5.4.0/bin/qmake could not be added. Cannot start /usr/local/Qt5.4.0/bin/qmake: No such file or directory"

      I own the file and it has the execute flag set...

      Thanks, Luca.

      Delete
    3. Can you run it from the command line? It is built for x86 on Kubuntu 13.10. Maybe your system is not compatible.

      Delete
    4. Can't run on command line as well: "No such file or drectory".

      I'm on Lubuntu x86_64... nothing too fancy.

      Delete
    5. http://askubuntu.com/questions/133389/no-such-file-or-directory-but-the-file-exists

      Delete
    6. Nailed it! Thanks, Luca!!!

      Delete
  4. hello dear luca ...i am working on my raspberry pi b+ and i need play mp3 music with qtmultimedia (i have my aplication on ubuntu 14.04 64bits and Qt 5.3.2 but i need its on my raspberry ) i tried with some tutorials but i can complilate qt on my rapberry , i dont know for where start .. can you help me how i can compilated qt with qtmultimedia ??? i am a begginer

    ReplyDelete
    Replies
    1. Playing music on Pi should be very simple. Just build with gstreamer support and you should be done.

      Delete
  5. i can do that http://thebugfreeblog.blogspot.it/2012/11/bring-up-qt-50-on-raspberry-pi.html ?????

    ReplyDelete
    Replies
    1. Yes, same way. But as you can see that build was not supporting gstreamer. You need to also add gstreamer libs and headers to the sysroot and then check Qt configure to ensure the build will include gstreamer support. Last time I did that was several months ago, but may still work.

      Delete
  6. Hello! I was able to take your PiOMXTextures library, compile it myself from GitHub, and run it on my Pi. It worked very nicely. However when I tried to dynamically link against the library generated by setting CONFIG_LIB, I get a segfault.

    Here's the output near the segfault:
    14:17:50.457 VERBOSE: [0;37mInitializing OMX clock... [0m
    512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf54.29.104
    Duration: 00:00:12.08, start: 0.000000, bitrate: 2632 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1150x864, 2630 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
    handler_name : VideoHandler
    14:17:50.471 VERBOSE: [0;37mOpening video using OMX... [0m
    14:17:50.473 VERBOSE: [0;37mGenerating texture of size (1150, 864). [0m
    bash: line 1: 5549 Segmentation fault

    When I debugged with gdb I saw that the segfault was happening within the call to nativeInterface->nativeResourceForIntegration("egldisplay") in get_egl_display() in omx_globals.h.

    Do you have any ideas why this might be happening, or what I can do? Thanks!

    ReplyDelete
    Replies
    1. So you're using the lib by itself? Without the Qt plugin?

      Delete
    2. No, with Qt5.4. I cross compile the lib and my app with the same toolchain in Qt and ran on the same Pi with the same libs installed.

      Delete
    3. Ok, Qt 5.4, but are you using the Qt backend plugin or libPiOmxTextures directly? What code do you use to play the video?

      Delete
    4. I used libPiOmxTextures directly (qml below). I had briefly tried using the plugin but I believe I had an issue with it not having a decoder. I would have to revisit what was done.

      import QtQuick 2.0
      import com.luke.qml 1.0

      Rectangle {

      OMXMediaProcessor {
      id: mediaProcessor
      source: "/home/pi/190_100652043.mp4"
      //source: "/home/pi/big_buck_bunny_1080p_h264.mov"
      }

      OMXVideoSurface {
      id: omxVideoSurface
      width: 1920
      height: 1280
      source: mediaProcessor
      }
      }

      (Apologies for the other post, I replied to the article, not this thread)

      Delete
    5. I misspoke. The error using a VideoOutput object in QML was no service found.

      defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

      Are you saying that the VideoOutput method is the proper way? Or should it matter?

      Delete
    6. I suggest you use the Qt backend provided according to the articles on the blog instead. Using the library directly is pretty outdated.

      Delete
    7. Okay thanks, I will give it another try.

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

    ReplyDelete
  8. I would like to use this without qtquick, but that is currently not possible.
    Could this be changed somehow?

    ReplyDelete
    Replies
    1. It depends on where you want to use it.

      Delete
    2. I created an app that has a QGraphicsView with in it a QVideoItem to play the video. That did not work.

      Currently I'm rewriting that app to use QML, which goes better than expected (I had no experience with QML yet) so maybe its not a problem after all.

      Delete
  9. Hi Luca

    I had been trying to use these binaries. I cross-compile succesfully with Qt Creator the qmlvideo example, and it executes but after I select the file and click a Video mode I got the following error:

    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
    qml: [qmlvideo] VideoItem.onError error 5 errorString The QMediaPlayer object does not have a valid service
    qml: [qmlvideo] Content.onFatalError

    And the video doesn't reproduce.

    I have followed the instructions and started in the clean distro of raspbian after installing all the libraries you mention in the older posts.

    Can you help me figuring out what the problem is?
    Thanks in advance.

    ReplyDelete
    Replies
    1. Use the env variable QT_DEBUG_PLUGINS.

      Delete
  10. Hi again Luca

    Yesterday I continued the cross-compiling of Qt5.3.2, following your instructions to get the openmaxil backend and add it to qtmultimedia, which I compiled and installed again.

    Now when I execute the example qmlvideo i don't get the error mentioned in the last post, but the video is played at a very low framerate, as if it where not hardware accelerated.

    Any ideas about this?

    ReplyDelete
    Replies
    1. Probably not using the correct plugin.

      Delete
    2. I forgot to mention that Qt Creator displays the following messages as Application output...

      Cannot connect to server socket err = No such file or directory
      Cannot connect to server request channel
      jack server is not running or cannot be started
      Warning: "A lot of buffers are being dropped."

      Delete
    3. That confirms you're not using this plugin. You're probably using the gstreamer plugin.

      Delete
    4. Thanks for your reply Luca... I'm newbie at all this...

      Where or How do I select the Plugin that uses qtmultimedia?

      When I compiled Qtmultimedia (after applying the patch) it found and compiled the Openmaxil Plugin, so I assumed it would use it from now on.
      Do I have to make some changes in qmlvideo? Same thing happens if I try to execute POCPlayer

      Delete
    5. Remove any media plugin but PiOmxTextures.

      Delete
    6. IIRC, I removed the libgstmediaplayer.so from the qt/plugins/mediaservice but now I have the same error than before

      defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
      qml: [qmlvideo] VideoItem.onError error 5 errorString The QMediaPlayer object does not have a valid service
      qml: [qmlvideo] Content.onFatalError

      I guess this is because the application is still looking for the gstreamer plugin...
      When you say "Remove any media player but PiOmxTextures" do you mean before compiling qtmultimedia (after the patch)?

      I'm really sorry if I'm asking nonsense for you, but I'm lost right now... Is there any other way to chat with you?

      Delete
    7. Got It!!!! I had the library path wrong....

      Thanks a Lot Luca!

      Delete
  11. Hi, All!!!
    Please help me! I try full week for create app with QT\QML with video output on Pi and no luck. :((((
    I can compile the QML without video plugin (using cross-compile as describe this http://qt-project.org/wiki/RaspberryPi_Beginners_guide) and all done, but if I it try using QTMultimeda I get error: "defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer".

    By reason of I try build piOmxTexture. But I can't this. (((
    Could you explain step-by-step how can I do it?

    ReplyDelete
    Replies
    1. Hi Yuriy

      First than all: Did you compile all Qt or just qtbase? The guide you mention tell you to compile qtbase first and then the other modules. Among the other modules you MUST compile qtmultimedia. Or just take the easy way and compile all qt (just do the configure, make and makeinstall steps on the qt folder)

      In the other hand: If you use correctly the binaries of this post you don't have to compile Qt and it will already have PiOmxTextures
      - Get sure of adding the library paths ( Explained here) for the folders you get from Qt-rasp-5.4.0.tar and PiOmxTextures.tar
      - The folder compressed in Qt-rasp-5.4.0_host.tar must be placed at /usr/local/ in your host machine
      - Get sure of having the necessary libraries.

      Delete
  12. Hi Luca,just wondering, what is the downside of directly compiling on the raspberry ? (if there is any), or is it just more convenient to code from a distant platform and cross compile the application.

    ReplyDelete