Solved No Mp4 Playback on Release Deployment
-
@JKSH Tried removing codecs no luck - went through my code to see if anything was amiss. Looks ok.
Did a build from a completely different PC and the same thing happens - fresh installs of VS 2017 & Q 5.12.2I can run the multimedia player ok - from within QT creator.
Do I need to deploy this example?
The deploy option is greyed out. -
@celica said in No Mp4 Playback on Release Deployment:
Do I need to deploy this example?
The deploy option is greyed out.The idea is to use
windeployqt
to produce a deployment that can play videos.This is to check if the problem is in your code or not.
-
@JKSH Ok thanks
It's gonna be a pain to convert this player example from working in QT Designer to work in Visual Studio -
@celica
Hi
Just as a note.
There is a Qt plugin for Visual Studio that allows the use of UI files
so nothing needs to be converted. -
@mrjj Yes, I have that but I'm getting lots of errors when for nearly all of the header includes
visual studio cannot open source QApplication -
@celica
Ok, it does sound like something in the setup didn't went all well.
Normally it just works and you can right click an UI files and it opens Designer.
So while not as good integration as in Creator it should compile fine. -
@celica said in No Mp4 Playback on Release Deployment:
It's gonna be a pain to convert this player example from working in QT Designer to work in Visual Studio
You don't have to build it in Visual Studio.
- Build the example in Release mode in Qt Creator.
- Check that the example runs correctly in Qt Creator.
- Run
windeployqt
. - Check that the deployed example runs correctly.
-
@JKSH Great, thank you.
So yes I deployed as a release build then used the command
windeployqt.exe C:\Qt\Examples\Qt-5.12.2\multimediawidgets\build-player-Desktop_Qt_5_12_2_MSVC2017_32bit-Release\releaseand it works fine.
https://ibb.co/9rSPFtj
See screenshot, what does this tell us? -
@JKSH Hi Guys
Sorry to bother you again but is there anything else I can try here or am I out of luck? -
@celica said in No Mp4 Playback on Release Deployment:
it works fine.
Hurray! 🎉🎉🎉
what does this tell us?
It tells us that there's nothing wrong with your copy of Qt and nothing wrong with your PC.
So, there might be something wrong with your app. Post your code from
main()
(Please post the code in the forum; no need to use a file upload service) -
@JKSH Here is main:
I have also included the cpp file which does most of the heavy lifting as an uploaded file (this is huge) .
https://easyupload.io/02m7h9#include "incommand.h" #include <QtWidgets/QApplication> #include "ButtonManager.h" #include <QtQuick/QQuickView> #include <QObject> #include <QtGlobal> int main(int argc, char *argv[]) { qputenv("QT_DEBUG_PLUGINS", QByteArray("1")); QCoreApplication::addLibraryPath("."); QApplication application(argc, argv); InCommand mainWindow; QObject::connect(&application, SIGNAL(focusChanged(QWidget*, QWidget*)), &mainWindow, SLOT(focusChanged(QWidget*, QWidget*))); mainWindow.setWindowFlags(Qt::FramelessWindowHint | Qt::Window); //Set borderless window type # QFile styleFile("Resources\\stylesheets\\defaultStyle.css"); QFile stylenightFile("Resources\\stylesheets\\NightStyleSheet.css"); if (stylenightFile.open(QIODevice::ReadOnly | QIODevice::Text)) { application.setStyleSheet(stylenightFile.readAll()); stylenightFile.close(); qDebug() << " -I: Stylesheet loaded OK"; } else { qDebug() << " -E: Can't access default stylesheet!"; } #ifndef TESTING_ON_PC application.setOverrideCursor(QCursor(Qt::BlankCursor)); #endif QObject::connect(&application, SIGNAL(aboutToQuit()), &mainWindow, SLOT(appClosing())); return application.exec(); } class MyApi : public QObject { Q_OBJECT public: Q_INVOKABLE virtual void setValue(int i); };
-
@celica said in No Mp4 Playback on Release Deployment:
QMediaPlayer *player = new QMediaPlayer; QMediaPlayer *playernew = new QMediaPlayer;
Here is your problem.
You must ensure that
QApplication
is the very first QObject that is constructed in your app.However, your
QMediaPlayer
s are initialized statically (in other words, they are initialized outside of a function), which means they can be created beforeQApplication
. When this happens, they look for the mediaservice plugin but they can't find it (becauseQApplication
hasn't loaded it yet), so they give up and they can't play your video.Go through you entire code base and make sure that you don't have any
QObject
s that are initialized statically.QCoreApplication::addLibraryPath(".");
This line is not necessary. Remove it.
(To understand why, read https://doc.qt.io/qt-5/qcoreapplication.html#libraryPaths )
-
@JKSH Thanks so much. This is great.
It is now loading the files previously it was not loading i.e.incommandnew\Win32\Release\mediaservice\dsengine.dll
Plus the codecs it is now loading.
0x000000005d520000 0x8a000 C:\Program Files (x86)\K-Lite Codec Pack\Filters\LAV\LAVSplitter.ax 0x000000005bc00000 0x23c000 C:\Program Files (x86)\K-Lite Codec Pack\Filters\LAV\avutil-lav-56.dll 0x000000005bbb0000 0x49000 C:\Program Files (x86)\K-Lite Codec Pack\Filters\LAV\libbluray.dll 0x000000005be40000 0x389000 C:\Program Files (x86)\K-Lite Codec Pack\Filters\LAV\avformat-lav-58.dll 0x000000005c1d0000 0x1350000 C:\Program Files (x86)\K-Lite Codec Pack\Filters\LAV\avcodec-lav-58.dll 0x000000005bb80000 0x2d000 C:\Program Files (x86)\K-Lite Codec Pack\Filters\LAV\avresample-lav-4.dll
The video is still not playing however when it is deployed.
-
Great progress!
@celica said in No Mp4 Playback on Release Deployment:
The video is still not playing however when it is deployed.
Then it's time to start debugging your app.
Back up your code (using source control, like Git, is best). After that, keep removing large blocks of code from your app and keep retrying the deployment until your problem disappears.
-
@JKSH Just to close this thread
The issue was the videos were not getting deployed.
I need to add these as "Additional Files to Deploy" within the Debugging configuration page of VS
Once these mp4 files were deployed everything worked.
Thanks for all your help -
@celica Awesome. Happy coding!