Audio with QML - Unable to play a wav file - c++

3 days I'm stuck with a tricky issue!
I've built an image for my embedded device based on a Colibri T20 board, using Yocto.
I"ve added Qt5, using X11 (because Tegra20 drivers from nvidia support hw accel only with X11...).
At this point, everything works fine.
I've also generated the respective SDK to build application for the respective platform..
Works fine.
I wrote a simple application to play audio file, very basic...just to play wav files...
It does not work. No sound output.
import QtMultimedia 5.5
Item {
...
Audio {
id: audioPlayer
source: "file:///opt/track.wav"
}
..
onClick() {
idPlayer.play()
}
}
This code works fine on my host linux.
But not on my Colibri.
Qt 5.5.1 was firstly built with ALSA, pulseaudio (gstreamer plugins...).
No outpût.
But in the linux, I can play the wav file using:
aplay /opt/track.wav
So I assume that my alsa driver are up-to-date.
Then, I 've recompiled Qt 5.5.1 without pulseaudio....
It does not work better :(
To be honnest, I'm not very experienced with alsa and pulseaudio matter. I'm very fustrated bzecause I don't understand what's happening under the abstracted layer of QtMultuimedia.
Any suggestion is welcome...This issue is simply driving me mad ;)

Related

Qt: no playback on linux

I have tried (I think) every possible way of playing audio in a Qt project, none of which have worked:
QSound::play(...)
QMediaPlayer
QAudioOutput, from http://doc.qt.io/qt-4.8/qaudiooutput.html
None of these solutions play WAV or MP3, and I have tried loading the files from a resource (qrc:media/file.wav) or simply from disk (/full/path/to/file.wav).
I think the problem is with codecs. QAudioDevice::supportedCodecs() returns an empty list. I'm on a linux system that has no problems playing audio/video (Ubuntu 14.04, usually playing in VLC... that uses its own codecs?).
Playing with QSound (WAV & MP3):
QSoundEffect(pulseaudio): Error decoding source
QMediaplayer (WAV): nothing happens
QMediaplayer (MP3):
GStreamer; Unable to play - "qrc:media/lowtone.mp3"
Qt uses specific media backends for each platform(link is qt5, but it was the same in Qt4). From the error it looks like your version is using GStreamer.
Check if the gstreamer dev packages on your distribution are well installed, because QAudioDevice::supportedCodecs must return at least audio/pcm. Work on the package setup until your test program show pcm. See https://wiki.qt.io/Building_Qt_for_Linux
You may also need to install plugins (also dev packages) before being able to play wav or mp3 using phonon.

GStreamer encountered a general stream error in Qt5 raspberry pi

I'm trying to play a video using QtMediaPlayer in Raspberry pi 2 B. The source code is as follows:
QMediaPlayer *media;
QVideoWidget *video;
...
...
media = new QMediaPlayer(parent);
video = new QVideoWidget(parent);
media->setVideoOutput(video);
media->setMedia(QUrl::fromLocalFile("/home/pi/Desktop/test3.mp4"));
media->play();
But the result is a blank video screen and the following error:
** (Bus:2148): WARNING **: ffmpegcolorspace-vo: size 1105920 is not a
multiple of unit size 829440
Error: "GStreamer encountered a general stream error."
System Information
Running latest raspbian Jessie OS,
Installed Qt5.3,
Installed gstreamer0.10-plugins-good/bad/ugly/ffmpeg and
Installed Mpeg-2 License
Here is the video test3.mp4
I ran this code in Windows with Qt5 installed; it is working there. But it's not working in the Raspberry pi. Please tell me what I'm missing here.
Trying Pipe from Shell
Video playback on the Raspberry Pi is actually a bit of a tricky thing. The most common solution is to use OMXPlayer to play videos. It's a command line program, but there are lots of flags and repeated calls can control playback. All in all, it works pretty dang well for most smallish projects.
As far as actually using Qt, QMediaPlayer, and etc. I don't think you'll be able to make it work right out of the box. However, I found a blog that discusses this issue and has some Raspberry Pi firmware that fixes QtMultimedia support on the Raspberry Pi.

Qt camera example does not find the laptop's webcam

I'm using Debian Jessie and dmesg | grep video returns:
[ 22.280407] Linux video capture interface: v2.00
[ 22.790704] uvcvideo: Found UVC 1.00 device Lenovo EasyCamera (13d3:5170)
[ 22.796546] usbcore: registered new interface driver uvcvideo
The example compiles fine but upon launch i get a dialog telling me that the camera service is missing. I'm using Qt 5.5.0. This question points to a similar issue but it's for windows. Also I've installed Qt using the installer provided at it's web site. I've tested my webcam with Cheese application and it works but QCameraInfo::availableCameras() returns nothing.
I don't know if this is a definitive answer, but in my experience the dreaded "camera service is missing" comes down to exactly what the message says; for some reason the media back-end that Qt uses to get video input from a camera is broken or miss-configured in some way. In my case I had this problem in the following situations:
1. Building Qt from source
Qt build system SILENTLY DISABLES FEATURES if you don't have all the dependencies that it requires to include them in the build. Make sure to read this official article very carefully for your platform. I lost count of the times this has ruined my <insert favourite period of time such as day/week/year here >, and not only for the multimedia module...
2. Missing some gstreamer packages on my Ubuntu
I develop for Linux & Debian mostly, and on those platforms Qt depends on gstreamer backend. gstreamer is basically a plugin architecture in the core with every single feature added as plugins, and with endless possibilities of manual intervention through configuration files. See where is this is going? Clue: make sure you have all the plugins you want installed and configured properly. Here is a link to some gstreamer tools you can use. Same probably goes for other back-ends on other platforms.
And a pro tip in the end: Since both Qt5.5 gstreamer0.1 (old) and gstreamer1.0 (new) are supported as back-ends, and since Qt5.6 the new one is default. This will give you some room for experimenting, for example if the old does not work, you can try the new etc.
Hope this was useful!

Using Qt Media Player on Raspberry Pi 1

I have a project built using Qt5 which has to play a video. Just like in the videowidget sample code.
I've followed these instructions to build qt5 on my Pi. And it went just fine. But when I try to run any qt program that uses QMediaPlayer, I get the error message:
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
Which means I don't have a backend to play the video, right? Is there any one that I can use which will with Qt, like ffmpeg? And how can I get it to work? Specially for h264 videos.
I've tried to install gstreamer as is told on this link, but it's not working. Will I have to rebuild the entire qt5 again?
P.S.: I have the raspberry pi 1 model B with raspbian installed.
Edit: As mentioned by Greenflow, I checked the ./configure log and saw that the GStreamer was compiled in, but the video apps are still not working...
The message on the log was like this:
GStreamer .............. yes (0.10)
And the message on Greenflow's log was like this:
GStreamer .............. yes (1.0)
Clearly it's another version of GStreamer, but is it the problem?
I've also found this post which says QtMultimedia on the Pi is rather useless, but the post is from 2013, so I'm not sure if it's really relevant. I'd like to have this app playing hardware accelerated videos on my Raspberry Pi, but I'm almost dropping the idea.
Anyways, thanks Greenflow for the head start.
Edit 2: Found this thread on the Qtcentre. Damn, this thing is not going to be easy to solve, I guess...
sudo apt-get install libqt5multimedia-plugins solved this for me.

How to play video with qt5

I'm trying to make a simple videoplayer using qt. However, I can't get the videowidget example that comes with qt to work, instead I get an error: "The QMediaPlayer object does not have a valid service". I'm using windows vista. Can I get the videos to play normally, even if that example isn't working? Is there any other simple way to test playing videos? Or is this a problem with qt?
Check this VideoWidget I created: https://github.com/MaximAlien/VideoWidget. The main thing here is that the video should be in web and QMediaPlayer handles everything for you. Example works with Qt 5 and higher.
This is expected on your Vista, unfortunately. See the relevant post from the maintainer:
On Windows XP, Qt Multimedia uses DirectShow (and WMF for Windows Vista and later). The DirectShow plugin binary is not included in the Qt 5.0 package (only the WMF plugin is). You need to compile QtMultimedia yourself, or just the DirectShow plugin in qtmultimedia/src/plugins/directshow
... in the following report on the Qt issue tracker:
Qt 5.0 and QMediaPlayer failure on Windows XP
The steps to build it on your would be:
grab the tarball
unpack it
move into the qtmultimedia folder
run qmake -r
(n)make
(n)make install
Please make sure qmake is properly in your PATH before doing this.