Showing a mp4 in my app
-
@J-Hilk
Thank you for pointing me at the official example. I downloaded the files and open the project in QT Creator, hit F5 and wait, the app pops up, I click the Open button, select my mp4 and click the play button and... nothing. I have tried multiple videos and can play those videos with VLC.
-
Are they all mp4 ?
Did you try a different format ?
The fact that they play in VLC is a good sign that they are not corrupted however it does not mean that your system has all the required codecs.
On a side note, you can also make use of VLC in your Qt application if you want.
-
Are they all mp4 ?
Did you try a different format ?
The fact that they play in VLC is a good sign that they are not corrupted however it does not mean that your system has all the required codecs.
On a side note, you can also make use of VLC in your Qt application if you want.
@SGaist said in Showing a mp4 in my app:
On a side note, you can also make use of VLC in your Qt application if you want.
And this is where my non-linux kicks in. I cloned the VLC-QT git directory, but now I don't know what to do from there. I believe I have to build it from within the debian sub-folder inside of the vlc-qt directory, but no idea how.
-
So, following this page for install directions on the vlc-qt: https://github.com/vlc-qt/vlc-qt/blob/master/BUILDING.md
It says for Linux:
Linux
Install requirements from your distribution's repository. Supported generators are make and ninja.Make example:
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
$ make -j8
$ make installSo, I go into the git debian directory because I believe my Rpi4 is running raspbian debian stretch. I then do the mkdir build and cd build so I'm in the build subdirectory of debian. I then use the following cmake command:
cmake -SYSTEM_QML -WITH_X11 -DCMAKE_BUILD_TYPE=DebugAnd I get the following error:
CMake Error: The source directory "/home/pi/vlc-qt/debian/-dcmake_build_type=Debug" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.Was I supposed to put something else where the ".." is in the cmake directions?
-
So, following this page for install directions on the vlc-qt: https://github.com/vlc-qt/vlc-qt/blob/master/BUILDING.md
It says for Linux:
Linux
Install requirements from your distribution's repository. Supported generators are make and ninja.Make example:
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Debug
$ make -j8
$ make installSo, I go into the git debian directory because I believe my Rpi4 is running raspbian debian stretch. I then do the mkdir build and cd build so I'm in the build subdirectory of debian. I then use the following cmake command:
cmake -SYSTEM_QML -WITH_X11 -DCMAKE_BUILD_TYPE=DebugAnd I get the following error:
CMake Error: The source directory "/home/pi/vlc-qt/debian/-dcmake_build_type=Debug" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.Was I supposed to put something else where the ".." is in the cmake directions?
-
@MichRX7 You need to tell cmake where the source code is:
cmake PATH_TO_SRC -SYSTEM_QML -WITH_X11 -DCMAKE_BUILD_TYPE=Debug
@jsulm Thanks for the quick reply.
In the interim I did get a .mov file straight from a new iPhone and moved that over onto my Rpi4, and guess what. It plays, so it must be a codec issue on the mp4 (though it didn't have sound, but maybe the Rpi4 doesn't output sound through hdmi).
Is there a page that tells newbies like me how to install the right codec for my mp4 videos?
-
Hahaha, of course though I take a .mp4 into my video editing software and export it is a .mov and it won't play either. So is there a way to tell what I need to do to a video to get it to play or how I install the codec's I need in QT? I don't want to have to use only non-edited iPhone vids, lol...
(Seriously, so glad to just see a video play... thank you all for the help so far.)
-
Hahaha, of course though I take a .mp4 into my video editing software and export it is a .mov and it won't play either. So is there a way to tell what I need to do to a video to get it to play or how I install the codec's I need in QT? I don't want to have to use only non-edited iPhone vids, lol...
(Seriously, so glad to just see a video play... thank you all for the help so far.)
-
@MichRX7 Most safe method is to install all GStreamer plug-ins your distribution is providing.
@jsulm And I'm stuck again (of course), so I did the following on my Rpi4:
sudo apt-get install gstreamer1.0-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
gstreamer1.0-tools is already the newest version (1.14.4-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.So, I already had the newest version of gstreamer installed. Is there something else I need to do to download specific codec's or all codec's? I tried going to the gstreamer website, but not seeing anything on codecs.
-
The codec are provided in the gstreamer plugins packages. See the
gstreamer1.0-plugins-XXX
packages. -
The codec are provided in the gstreamer plugins packages. See the
gstreamer1.0-plugins-XXX
packages.@SGaist said in Showing a mp4 in my app:
The codec are provided in the gstreamer plugins packages. See the
gstreamer1.0-plugins-XXX
packages.Thanks, will look into that on my lunch break.
Or, if even easier, figure out why a .mov would play when it comes direct from an iPhone, but not if I take a mp4 and convert it into a mov in my video editing software. I mean, if I can convert to .mov and get it to work I'll just do that for now. :)
-
@SGaist said in Showing a mp4 in my app:
gstreamer1.0-plugins
Ok, well tried to install codecs, not sure if I'm doing it right. Did the following three entries, and now going to reboot because my videos didn't play:
apt-get install gstreamer1.0-plugins-*
apt-get install gstreamer1.0-plugins-*
apt-get install libavcodec-extraIf this is not correct, I can't figure out how to get them properly.
-
Can you play your video directly with GStreamer from the command line ?
-
@SGaist said in Showing a mp4 in my app:
Can you play your video directly with GStreamer from the command line ?
Yes, using:
gst-launch-1.0 playbin uri=file:///home/pi/Videos/tomtiph.mp4or
gst-play-1.0 /home/pi/Videos/tomtiph.mp4
both those commands play the video
-
Good.
Then as next step, I would build and run the Media Player Example.
-
Good.
Then as next step, I would build and run the Media Player Example.
@SGaist said in Showing a mp4 in my app:
Good.
Then as next step, I would build and run the Media Player Example.
I have, it won't play the mp4 videos, but it will play the mov video saved direct from an iPhone just like my other videowidget.
-
What are the specifications of that video ?
-
@SGaist said in Showing a mp4 in my app:
Good.
Then as next step, I would build and run the Media Player Example.
I have, it won't play the mp4 videos, but it will play the mov video saved direct from an iPhone just like my other videowidget.
@MichRX7 said in Showing a mp4 in my app:
@SGaist said in Showing a mp4 in my app:
Good.
Then as next step, I would build and run the Media Player Example.
I have, it won't play the mp4 videos, but it will play the mov video saved direct from an iPhone just like my other videowidget.
File Type MPEG-4 Video
Total Size 5.8 MiB -
@SGaist recommended this earlier; it's still worth doing: Check the error signal. It could provide some clues as to why your video isn't playing.
Also, try connecting the status/state change signals and see what you get:
connect(player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), [=](QMediaPlayer::Error error) { qDebug() << "Error:" << error << player->errorString(); }); connect(player, &QMediaPlayer::mediaStatusChanged, [=](QMediaPlayer::MediaStatus status) { qDebug() << "Media Status:" << status; } connect(player,, &QMediaPlayer::stateChanged, [=](QMediaPlayer::State state) { qDebug() << "State:" << state; }
-
@SGaist recommended this earlier; it's still worth doing: Check the error signal. It could provide some clues as to why your video isn't playing.
Also, try connecting the status/state change signals and see what you get:
connect(player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), [=](QMediaPlayer::Error error) { qDebug() << "Error:" << error << player->errorString(); }); connect(player, &QMediaPlayer::mediaStatusChanged, [=](QMediaPlayer::MediaStatus status) { qDebug() << "Media Status:" << status; } connect(player,, &QMediaPlayer::stateChanged, [=](QMediaPlayer::State state) { qDebug() << "State:" << state; }
Thank you for the reply. I placed these in the file. When I do the first connect throws this issue:
/tmp/VisualGDB/c/projects/LinuxProject1/MainWindow.cpp:35: error: reference to non-static member function must be called; did you mean to call it with no arguments?The 2nd and 3rd connect's throw an error unless I put ); after the closing } for each connect.
I can't build the file until I figure out the issue with the first connect is. If I comment it out and place the ); after the 2nd and 3rd connects I can build the file, but I don't see any errors in the debug window in QT Creator if that is where I should be seeing issues.