Coding Chase - Projects

My 3D Hub

Thank You For Donating:

Ikeeki (linux-sunxi@irc.freenode.net)
Computer Troubleshooters Brasil

Wednesday 3 September 2014

Cubieboard: GStreamer 0.10 + libvdpau-sunxi

It's been a while since I've posted in the blog, but while I'm still to release any new versions of Qt5Box, there's still some exploring to be done with hardware accelerated video on Cubieboard.

Using X11 and libvdpau-sunxi, it's possible to have hardware accelerated video on Cubieboard, and confirm it with mplayer - just check the sunxi wiki steps for that.

But what about GStreamer? Read on...

Step 1: libvdpau-sunxi and mplayer

- based on Cubian images for Cubieboard
- add sunxi_cedar_mod to /etc/modules

sudo apt-get install libvdpau-dev vdpauinfo libvdpau-sunxi

http://linux-sunxi.org/Cedrus

- set permissions in udev rules
- reserve memory for the VPU
- add VDPAU_DRIVER=sunxi to /etc/environment

sudo apt-get install mplayer2

wget sintel mp4 trailers

DISPLAY=:0 mplayer -ao alsa:device=hw=1.0 -vo vdpau -vc ffmpeg12vdpau,ffh264vdpau, sintel_trailer-480p.mp4


(at this point, 480p, 720p, 1080p should work properly with mplayer)

Step 2: libvdpau-sunxi and GStreamer


sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgstreamer-plugins-bad0.10* gstreamer0.10-plugins-ugly gstreamer0.10-alsa gstreamer0.10-plugins-good gstreamer0.10-tools gtk-doc-tools

DISPLAY=:0 gst-launch-0.10 playbin2 uri=file:///home/cubie/sintel_trailer-480p.mp4 video-sink="autovideosink" audio-sink="faad ! audioconvert ! alsasink device=hw:1,0"

(no vdpau yet - video is distorted, audio is working over HDMI)

sudo apt-get autoremove
sudo apt-get install faad libfaad-dev libfaad2
sudo apt-get clean

wget http://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-0.10.23.tar.xz

./autogen.sh && make -j 3 && sudo make install

sudo ln -s /usr/local/lib/gstreamer-0.10/libgstvdpau.so /usr/lib/arm-linux-gnueabihf/gstreamer-0.10/
sudo ln -s /usr/local/lib/libgstvdp-0.10.so.23 /usr/lib/libgstvdp-0.10.so.23
sudo ln -s /usr/local/lib/libgstvdp-0.10.so.23.0.0 /usr/lib/libgstvdp-0.10.so.23.0.0

rm -rf ~/.gstreamer-0.10/ && gst-inspect-0.10 | grep vdpau

vdpau:  vdpausink: VDPAU Sink
vdpau:  vdpauvideopostprocess: VdpauVideoPostProcess
vdpau:  vdpaumpeg4dec: VDPAU Mpeg4 Decoder
vdpau:  vdpauh264dec: VDPAU H264 Decoder
vdpau:  vdpaumpegdec: VDPAU Mpeg Decoder

DISPLAY=:0 gst-launch-0.10 playbin2 uri=file:///home/cubie/sintel_trailer-480p.mp4 video-sink="vdpauh264dec ! vdpauvideopostprocess ! vdpausink" audio-sink="faad ! audioconvert ! alsasink device=hw:1,0"

Failed to open VDPAU backend libvdpau_sunxi.so: cannot open shared object file: No such file or directory

sudo ln -s /usr/lib/arm-linux-gnueabihf/vdpau/libvdpau_sunxi.so.1 /usr/lib/libvdpau_sunxi.so

Failed to open VDPAU backend /usr/lib/libvdpau_sunxi.so: undefined symbol: XTranslateCoordinates

(the mplayer line works OK with vdpau video support and alsa audio through HDMI)

sudo apt-get purge libvdpau-sunxi

(leave libvdpau-dev installed)

git clone https://github.com/linux-sunxi/libvdpau-sunxi.git

cd libvdpau-sunxi
make
sudo make install

(mplayer and GStreamer working now)

reboot

- mplayer cmdline working
- gstreamer cmdline working

3 comments :

  1. Hi Wick Wire,
    I have found your solution to play hardware accelerated video on A20+mali400. Have you found a solution to set the default videosink?
    I looked for a long time and found the file qgstreamerplayersession.cpp in /qt-everywhere-opensource-src-5.3.2/qtmultimedia/src/plugins/gstreamer/mediaplayer/. I think the GStreamer connection is created here. But my GStreamer-knowledge isn’t enough and actually I do not have much time alongside my studies. Do you find an approach to solving the problem?
    Kind regrads from Germany.
    Stefan

    ReplyDelete
  2. Hi, yes I tried hacking qgstreamerplayersession myself, but to no avail: I did get to invoke vdpausink as m_videoSink at one point, but black screen only on the app.

    I'm also not that versed on GStreamer, but down the road through research and debate with fellow coders, I got the impression that maybe we are meant to leave that part untouched, in the sense that at that level, Qt is already handling the previously decoded frames over to eglsink for graphics manipulation (hopefully I'm not writing too much rubbish here) and so I thought I'd to it the other way around: checking for what Qt actually does when requesting video from GStreamer.

    Qt is using playbin2 to do this, and playbin2 on its own, over on GStreamer, is using ffdec_h264 and a bunch of other ffmpeg components for its pipeline.

    The vdpau elements that were built following this guide have a low Gstreamer RANK, so what if - we were to set the GST_RANK of these vdpau plugins to higher than the current default...?

    Meaning, by changing the GST_RANK_NONE to PRIMARY + 1 on vdpau.c inside that tar.xz plugins bad, recompiling and reinstalling, afterwards by running gst-inspect vdpausink you can check the new Rank: 257 (higher than ffmpeg's 256)

    When running the gst-launch command line, you shouldn't be able to specify to playbin2 the video-sink="" element anymore, as by then, vdpau elements are default. And by consequence, QtMultimedia would ask Gstreamer to hand over decoded frames as before, but this time around, Gstreamer would do it in with hardware acceleration...

    Anyways, tried it recently and one thing is for sure: changing the RANK affects GStreamer and consequently QtMultimedia which already claims to have accessed VDPAU on the Qt5 app output, but still not working, so I'm still at it.

    If you decide to go this way also, let me know how it goes for you!

    ReplyDelete
  3. I tried the first step with mplayer, and work fine thanks!!

    I tried vlc but not work, it says:

    [VDPAU SUNXI] VE version 0x1623 opened.
    [b00576f0] vdpau_display vout display debug: using back-end sunxi VDPAU Driver
    [b00576f0] vdpau_display vout display error: source video YCbCr format not supported

    Can you help me?

    ReplyDelete