QMediaPlayer resource error - c++

I'm using Qt Creator 2.7.2 (Qt 5.1) on Windows 8 Pro x64. I'm having trouble with QMediaPlayer. There are some MP3 files on my PC which run fine on Windows Media Player, but QMediaPlayer can't play them. Following statement:
void MainWindow::onPlayerStateChanged(QMediaPlayer::State state)
{
qDebug() << "onPlayerStateChanged" << state
<< media_player.error() << media_player.errorString();
// ....
}
is the slot connected to media player's stateChanged signal throws following output:
onPlayerStateChanged QMediaPlayer::PlayingState QMediaPlayer::NoError ""
DirectShowPlayerService::doRender: Unresolved error code 80040266
onPlayerStateChanged QMediaPlayer::StoppedState QMediaPlayer::ResourceError ""
DirectShowPlayerService::doRender: Unresolved error code 80040266
Any idea what's wrong?

It might have something to to with the ID3 tags of the file.
I had a similar problem: I was trying to play some MP3 files with QMediaPlayer. One of the files generated that error while the others played fine (on Windows 7). On Linux though, they all played fine.
So I ran the 'file' command on my MP3 files and noticed that the problematic MP3 file had a ID3 version 2.4.0 tag while all the others had ID3 version 2.3.0. I deleted the ID3 tag of that file completely using an ID3 tag editor and after that the file played successfully.
A wild guess here: DirectShow, which is used by QMediaPlayer as backend on Windows, chokes on ID3 version 2.4 and only recognizes older versions. And QMediaPlayer on Linux uses GStreamer as backend, which does not have that problem.

Related

Playing *.avi files with Qt

I am trying to play *.avi file (~900MB) with this code:
QMediaPlayer* player = new QMediaPlayer(this);
player->setMedia(QUrl::fromLocalFile("mes1.avi"));
player->setVideoOutput(ui->videoWidget);
player->play();
where ui->videoWidget is QVideoWidget and every time I play it I am getting this error code (in Application Output console)
Since google doesn't help, this is my only choice...
DirectShowPlayerService::doRender: Unresolved error code 0x80040266 (IDispatch error #102)
EDIT1:
I have installed K-Lite Codec Pack 12.2.6.
EDIT2:
My application is 32bit, but it shouldn't be a problem since K-Lite include 32bit (source).
Use vlc-qt, and you will find it is so easy to play all sorts of video on all platforms, even XP, which has been abandoned by qt long time ago.

Qt deployed (macdeployqt) application does not create a file

I'm facing the following problem:
I wrote a simple application to track working hours. Therefor I create a *.db file programmatically.
Launching the application from Qt Creator (debug or release) works perfectly fine.
I used the macdeployqt tool to get a *.dmg file. When starting the application now the method (see below) cannot open, respectively create the *.db file and I run out of ideas why. In addition to this, the application should output some *.csv files. This also fails.
One more information, running the application as administrator using the sudo command on terminal...well it works and the *.db file and *.csv files get created.
So I am quite sure it must deal with file permissions but I have no idea how to change this except for changing it in the information context menu but this didn't help at all.
Below the method for the *.db file which always returns false when not launching the app from Qt Creator:
QFile file(Globals::Environment::WORKING_DIRECTORY + "/" + "Records.db");
if(file.open(QIODevice::ReadWrite))
return true;
else
{
QMessageBox msg;
msg.setWindowTitle("Error");
msg.setText("Failed to create database file!");
msg.exec();
}
return false;
I am on MacOS 10.11.3.
Qt 5.5.1 (Clang 6.1 (Apple), 64 bit)
If more information is needed, I will provide it of course.
Thanks a lot for every help in advance.

Error on QT5.5 camera preview

I'm trying to use a camera in my QT5.5 application using the QCamera type of QT. A simple example of what I'm doing is
QList<QCameraInfo> cameras = QCameraInfo::avalilableCameras();
qdebug() << cameras.length();
const QCameraInfo &cameraInfo = cameras.first();
QCamera *camera = new QCamera( cameraInfo );
When I run this example, I get "No m_videoSink available!" on the command line. QT is build on Ubuntu 12.04 with libgstreamer0.10-0, libgstreamer0.10-dev and libgstreamer-plugins-base0.10-0 installed. QT is built with -qt-xcb. I have no idea what is wrong here. Does anyone have an idea?
PS: Of course I make sure that line 2 prints >= 1 ;).
Ok, finally I found the basic problem: Unfortunately Qt dropped Ubuntu 12.04 LTS support with version 5.5. With version 5.4 everything works as expected.

How to use LibVLC with Qt 5

I'm trying to use LibVLC in a Qt 5 program to open a VLC instance and play a video.
The following code comes from https://wiki.videolan.org/LibVLC_Tutorial/
I'm using Linux.
.pro :
TEMPLATE = app
TARGET = projectLoic
INCLUDEPATH += . vlc
QT += widgets
# Input
HEADERS +=
SOURCES += main.cpp
LIBS +=-lvlc
main :
#include <vlc/vlc.h>
#include <QApplication>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
// Load the VLC engine
inst = libvlc_new(0, NULL);
// Create a new item
m = libvlc_media_new_path (inst, "/home/........mp3");
// Create a media player playing environement
mp = libvlc_media_player_new_from_media (m);
// play the media_player
libvlc_media_player_play (mp);
return app.exec();
}
The compilation is fine. But the program immediatly crashes when I build it (with Qt Creator). Any idea?
Many thanks
Many things could cause this crash. The best is to get VLC source code to trace back the issue. Passing the option '--verbose=2' when initializing libVLC can help as well.
In my case the cause of the crash was due to this bug in the ubuntu package of vlc:
https://bugs.launchpad.net/ubuntu/+source/vlc/+bug/1328466
When calling libvlc_new() vlc modules and their dependent libraries are loaded into memory. The qt module of LibVLC was searching for Qt4 shared objects instead of Qt5 (manually installed).
The solution was to rebuild the module cache which was outdated an pointing to Qt4 binaries. You can reset it on the command line:
sudo /usr/lib/vlc/vlc-cache-gen -f /usr/lib/vlc/plugins/
Or pass to vlc the option:
--reset-plugins-cache
I have never used this library, but Are you using exactly this code?
m = libvlc_media_new_path (inst, "/home/........mp3");
This path may be the problem.
What distribution of Linux are you using?
I ran into this same problem with Qt5 and LibVLC, and the primary cause (Ubuntu 12.04 LTS and 14.04 LTS), was that LibVLC was loading the qt4 interface plugin, which conflicted with Qt5. If you check your call stack, you'll most likely see that at a Qt4 library was being loaded, causing the crash.
If this is the problem, there are only 3 options (tested with LibVLC 2.2 and Qt5 on Ubuntu 12.04 and 14.04 LTS 64 bit).
The first (worst) is to delete the qt4 user interface plugin. You can test this is the problem by moving and running and then setting it back. Deleting will break your regular VLC player most likely.
Second option is to create a copy of the plugins directory and set that in your runtime path using VLC_PLUGIN_PATH, environment variable. but I've had trouble getting that to work without changing the original plugin path folder also (which will break your VLC player unless you modify your shortcuts, etc. to also set VLC_PLUGIN_PATH.
The third option, and what I ended up doing, was to custom build my own static LibVLC binary with a few edits to the source code so that it will not load the qt4 interface plugin installed with VLC. You can follow these steps to do this.
1) Download VLC Source Code for your platforms distribution.
http://download.videolan.org/pub/videolan/vlc/
Make sure you download the version matching your distribution. For
example, match the VLC version to what is installed with Ubuntu.
2) Extract source code to folder
3) Install dependencies for the OS distribution
sudo apt-get build-dep vlc
4) Modify src/modules/bank.c
Edit the module_InitDynamic function
Add the following code at the top of the function:
// HACK TO DISABLE QT4 PLUGIN
if(strstr(path, "qt4") != NULL)
return NULL;
// END HACK
3) From terminal
./bootstrap
./configure --disable-qt --disable-skins2 --enable-xcb --prefix=/home/$USER/vlc-custom_build_output_folder_name
./make
./make install
4) Copy/Save the resulting files in the install folder.
Then just link against this library instead.

Error: Qt5 Video render error code 80040218

When running an application in Qt5 made ​​using the QWebView, I accessed a page with a video player in HTML5, but the video does not play and qt/directshow shows the following error:
DirectShowPlayerService::doRender: Unresolved error code 80040218
DirectShowPlayerService::doRender: Unresolved error code 80040218
Details:
Qt5.1.1 MingW4.8 32bit
Windows 7 64bit
I suspect that is why my Windows is 64bit, but the *QT/MingW** runs on 32bit and maybe miss some DLL/LIB.
How can I resolve this?
Thanks.
The error code is rather generic: 0x80040218 VFW_E_CANNOT_RENDER "No combination of filters could be found to render the stream." and the typical cause is that the application cannot decode media feed because it lacks decoding components, such as codec for this video feed is not installed/available.
install K-Lite_Codec_Pack_1540_Basic in your machine, this error not related to pyqt5 and any other
You may check out 'LAV Filters'. It solved my rendering problem: 'DirectShowPlayerService::doRender: Unresolved error code 80040266'.
Download installer: http://forum.doom9.org/showthread.php?t=156191 And the source code: https://github.com/Nevcairiel/LAVFilters
If you are a developer, you can download and use ffmpeg to decode and encode your file to avi(windows) or mov(mac).