I have this application where I display content together with a video file. The video files are either in image/jpeg (MJPG format according to vlc) or video/x-h264 format.
To do this, I use a mediasource combined with a video output element to display the video. This is working perfectly when using h264. However, this is not working at all with the mjpg video files.
But I have no idea how to do this. I have read up on libraries using either ffmpeg or vlc, but I can't seem to find libraries to use in combination with QML elements, only with regular QWidgets.
Here is some (stripped down) relevant code, it is really simple and I would prefer to keep it simple. So ideally I am just looking for a way to get a codec into the project or something like that.
property string videoLocation
FileDialog {
id: videoFileDialog
onAccepted: {
videoLocation = fileUrl
}
}
MediaPlayer {
id: mediaplayer
source: videoLocation
autoPlay: false
}
VideoOutput {
id: videoOutput
source: mediaplayer
}
Maybe relevant:
my system is ubuntu 13.04 and I use qt 5.3.
Thx in advance
EDIT: I have figured out the problem I think: The stream is recorded using gstreamer > 1.0. For some reason it won't play back in 0.10. If I record using the same settings, but with gstreamer 0.10, everything is fine and my application works (though this option is not feasible, I really need to capture using > 1)
Here is the code I am using to capture the stream to a file:
gst-launch-0.10 v4l2src device=/dev/cam1 ! image/jpeg,width=320,height=240,framerate=30/1 ! matroskamux ! filesink location=videotest.mkv
Any suggestions for a setting that is compatible between new and old gstreamer?
On *nix platforms, QtMultimedia uses GStreamer as its backend. On GStreamer's website it appears that JPEG is a supported format (and one would assume that includes motion jpeg.)
Check your package manager to make sure you have all of GStreamer's plugins installed. There's at least three different packages of GStreamer plugins on Ubuntu.
So I fixed it by using an avi container instead of a matroska container. No idea why it works now and not with matroska. I can honestly only think this has to be a bug somewhere.
Related
I just started using JavaFX 11, and SwingFXUtils seems to be gone (or renamed?)
I tried to download it manually, but the module-system complained about import sun.awt.image.IntegerComponentRaster;, and I couldn't get it to work.
I need to convert Swing Icon to JavaFX image.
Since Java 9, SwingFXUtils has been moved to the javafx.swing module, under the package javafx.embed.swing.
See JavaFX 9 Javadoc and the new JavaFX 11 Javadoc, hosted at https://openjfx.io.
If you have any issue with your sample, make sure you are adding the proper VM options. See the samples from the getting started guide.
Probably you will need to add something like:
--module-path <path-to>/javafx-sdk-11/lib --add-modules=javafx.controls,javafx.swing
SwingFXUtils is still there if you have correctly added the javafx.swing module to your build path (see answer from José) but importing an internal class like sun.awt.image.IntegerComponentRaster is not allowed anymore.
To convert your icon you can try this:
Icon icon; // Your icon
BufferedImage image = (BufferedImage)((ImageIcon)icon).getImage();
WritableImage writable = SwingFXUtils.toFXImage(image, null);
Whether this works or not depends on how your icon was created but it is worth a try.
Using Qt Version 5.4.2
Error code returned : DirectShowPlayerService::doSetUrlSource: Unresolved error code 800c000d
A QML file has been written with the Video QML type as below. I have added the below in the project file (.pro)
Qt+= multimedia
Snippet of code as below in the QML file.
Video {
id: video
width : 800
height : 600
source : "Video.mp4"
MouseArea {
anchors.fill: parent
onClicked: {
video.play();
}
}
focus: true
Keys.onSpacePressed: video.playbackState == MediaPlayer.PlayingState ? video.pause() : video.play()
Keys.onLeftPressed: video.seek(video.position - 5000)
Keys.onRightPressed: video.seek(video.position + 5000)
}
Any pointers regarding this error would be helpful.
I faced the same issue, fixed it by:
changing
source: "file://D:/Temp/video/ccc.wmv"
to
source: "file:///D:/Temp/video/ccc.wmv"
as the message mentioned doSetUrlSource indicates may using the wrong URL.
Have you searched through the bug tracker? I found QTMOBILITY-1461, for example:
The default directshow filters on Windows7 are not enough for playback of the m4a file. It is not the AAC codec problem, but no filter to identify the m4a container.
The "K-Lite Codec Pack" provides "MPC - MP4 Splitter" filter which could be used to connect the m4a source to the Microsfot codec filter "Microsoft DTV-DVD Audio Decoder" to be able to play the file.
Windows Media Player 12 on Windows7 uses Media Foundation instead of DirectShow to play .m4a .m2ts, .mp4, and .mov formats (for other formats it uses DirectShow filters). This explains why we could not do it with the current directshow backend implementation for QMediaPlayer without a third-party filters.
We might consider adding Media Foundation support in the futrure, but for now you have to install third-party filter to have it work on Windows7.
So, installing the K-Lite Codec Pack might help.
You could also try the suggestions in this mailing list thread.
I think the problem is qml cannot play .mp4 file.
After I try .wmv file it is working fine.
I am looking for a best way to implement a video player application in QML. Almost all QML examples are reading files from filesystem or web:
MediaPlayer {
id: mediaplayer
source: "groovy_video.mp4"
}
VideoOutput {
anchors: parent.fill
source: mediaplayer
}
I want to specify my own source for MediaPlayer - a C++ QObject derived class, that has an interface similar to QIODevice. That would be perfect for my needs. I need to preload video in parts and also to cache it for later use.
Is there an easy solution for my needs?
(I am using Qt 5.2)
Generally speaking you should be able to override any URL that is loaded by QML. The Qt 4 docs are a bit more explicit about this than Qt 5:
https://doc.qt.io/qt-4.8/qdeclarativenetwork.html
But the same should be similar for Qt 5:
http://doc.qt.io/qt-5/qqmlnetworkaccessmanagerfactory.html
e.g. you should be able to use a specific url schema for a custom source magic+videos://.... for your custom source.
Worst case scenario you have to inherit (and override some methods) from QNetworkAccessManager and QNetworkReply (which inherits from QIODevice).
I have not played with this since qt4 but I assume a good starting point would be this:
http://doc.qt.io/qt-5/qtqml-networkaccessmanagerfactory-example.html
I'm a bit outdated on this kind of stuff, but hopefully this helps.
I'm having an issue where certain controls are flipped, depending on the machine that I'm building my project on. On my development machine, when I build it, everything is okay. However, when I build it on our build server, some things are flipped. It seems to be things that are on a higher layer - for instance, options in the select control (see first image below), alerts/overlays (see second image below), etc. It's not just the text, either - the entire content is flipped, images and all.
I have verified that the code is exactly the same in both instances, so it must have something to do with settings or the flex SDK version. On my development machine, the Flex SDK version is 4.0.0.14159, and on the build server, the Flex SDK version is 4.1.0.16076. I can downgrade the SDK on the build server if needed - but could it really be an issue with the SDK? Any ideas?
Thanks!
It looks like this will be fixed in the 4.5 SDK--see SDK-26473 for workarounds.
I was able to fix the mirroring by turning off Flex 3 Compatibility Mode in the Flex compiler settings (if using mxmlc, -compatibility-version=4.0).
Your build machine must be set to a locale which uses right-to-left text, such as Hebrew or Arabic keyboard setting.
Oops - hadn't read all of dpstone's answer before I posted my comment to the question.
The answer to this problem is in the bug he linked to. You need to explicitly set the layout direction. You can do this in one of two ways.
1) in a .css file that you import into your main application file:
global
{
layoutDirection: "ltr";
}
OR
2) you can set it in a <style> tag in your main application file.
<mx:Style>
global
{
layoutDirection: "ltr";
}
</mx:Style>
In qt-designer I loaded bitmap images and in preview I am able to view the images. But after compiling in qdevelop IDE, I could not see the images at all.
Is there any procedure to load the bitmaps in to qdevelop.
Thanks in advance
I think you'll be wanting to add the bitmaps to a resource file, using Qt's resource system, if you want to be able to use them in Designer and also have them work in your compiled application correctly. I've not used it, but the examples look fairly straightforward, and it appears QDevelop supports the resource system to some extent.
Have you configured Qt to use required images plugins?
[-no-gif] [-qt-gif] [-no-libtiff] [-system-libtiff] [-no-libpng] [-qt-libpng] [-system-libpng] [-no-libmng] [-qt-libmng] [-system-libmng] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]