I've got a quite persistent problem regarding the d3dvideosink.
My GStreamer pipeline is written by using the GStreamer SDK 1.14.2 in Qt/C++ and looks like this:
videotestsrc -> d3dvideosink
I use gst_video_overlay_set_window_handle to place the sinks output over the corresponding QWidget (using WId QWidget::winId() const).
The stream works as expected, but will produce flicker whenever the widget (or any parent widget) is repainting (e.g. while resizing).
How can I configure the widget / pipeline / d3dvideosink / ... to eliminate flickers ?
P.S. Using glimagesink instead of d3dvideosink works, but will be less performant.
Disable Qt repaints over the Window. To do this:
setAttribute(Qt::WA_PaintOnScreen);
Overload paintEngine() to return nullptr.
Related
I'm developing a video stream software, I'm using libvlc and qt-vlc for playing videos from network stream. Everything is good just one problem. When VlcMediaPlayer starts to playing, the mouse pointer hide over VlcWidgetVideo widget.
If mouse move around application it will be shown but only on the VlcWidgetVideo there are no mouse
My simple code is like that:
auto _instance = new VlcInstance(VlcCommon::args(), this);
auto _player = new VlcMediaPlayer(_instance);
auto playerWidget = new VlcWidgetVideo(_player, this);
auto _media = new VlcMedia(mediaUrl.toString(), _instance);
_player->setVideoWidget(playerWidget);
_player->play();
// mediaUrl is type of QUrl
_player->open(_media);
Now, my question is that: How can I force qt-vlc to don't hide pointer? I want to mouse pointer be visible always. My development environment is:
CentOS 7.2 on VirtualBox
Qt 5.5
Excuse for my bad English
Note 1:
Two points:
Playing same stream video with vlc media player on same computer doesn't hide the cursor!
When I try to simulate the mouse pointer with a shape in QLabel the player widget flush by repeat
Note 2:
I dropped using of qt-vlc and used libvlc directly, But no changes! Mouse hide and some times it appear as a single black pixel
Note 3:
Running same code on debian 9 works fine
Use --mouse-hide-timeout=<integer> from https://wiki.videolan.org/VLC_command-line_help/
If that doesn't work, consider opening an issue as I'm not sure vlc-qt offers a way to configure that option.
I created simple project for displaying local .html page.
I used Qt5.4 with QWebView there. But after switching to Qt5.6 I noticed
that Qt WebKit is deprecated and not supported any more.
Thus I decided to replace Qt WebKit functionality with one from the
Qt WebEngine.
After replacing QWebView with QWebEngineView
I investigated that setZoomFactor method has no effect.
Is it known issue? How can I handle with this?
EDIT:
An interesting thing have been investigated recently. I use setHtml method for setting content of local .html files to my QWebEngineView. These files also contain references to images. So I set baseUrl parameter as a relative path to required images. In that case using of setZoomFactor method has no effect.
But when I don't set relative path to images as parameter, images are absent on QWebEngineView but zoom functionality works. Any ideas what is wrong here?
Setting zoomFactor for QML WebEngineView in Qt 5.11 using QML zoomFactor property or C++ setZoomFactor (private-API) did not work as expected. I discovered from comments in QT Bug 51992 that it works when set after a page load.
QML solution:
WebEngineView {
// ...
onLoadingChanged: {
zoomFactor = 0.75
}
}
QWebEngineView solution: connect to the loadFinished signal, and set zoomFactor after each page load:
main.cpp (after engine.load call):
QWebEngineView *webView; // = ...
QObject::connect(webView, &QWebEngineView::loadFinished,
[=](bool arg) {
webView->setZoomFactor(zoomFactor);
});
It seems to be a known bug in this version of Qt. You can check by yourself here : Qt Bug 51992.
Basically, it is said that :
This looks like a known glitch that is currently happening because of
the Chromium API that we use for setting the zoom factor.
And also :
Chromium limits the zoom factor to a maximum of 5.0 - any calls with a
number higher than that will have no effect.
Hope that will help you.
The setZoomFactor does not function properly in the QT 5.15 release.
Call setZoomFactor multiple times to resolve the problem.
WebEngineView {
function setZoomFactor(real) {
zoomFactor = real
zoomFactor = real
zoomFactor = real
}
}
I'm working on a QML application for an embedded platform which includes a GridView widget containing images. It's important for me that scrolling through the GridView will be smooth and will not put load on the CPU. Can I expect Qt to use OpenGL to render the GridView?
I faced with the same problem.
QApplication::setGraphicsSystem(QLatin1String("opengl"));
haven`t work for me. So i set the OGWidget as a viewport:
QDeclarativeView mainwindow;
mainwindow.setSource(QUrl::fromLocalFile("./qml/app.qml"));
QGLFormat format = QGLFormat(QGL::DirectRendering); // you can play with other rendering formats like DoubleBuffer or SimpleBuffer
format.setSampleBuffers(false);
QGLWidget *glWidget = new QGLWidget(format);
glWidget->setAutoFillBackground(false);
mainwindow.setViewport(glWidget);
and do not forget to add opengl in *.pro file.
Depending on your platform use
QApplication::setGraphicsSystem(QLatin1String("opengl"));
or (Symbian)
QApplication::setGraphicsSystem(QLatin1String("openvg"));
before you instantiate the QApplication object.
By default Qt does not use the OpenGL render backend. You can enforce it by using a QGlWidget. In your case, as you want to use a stock widget, you can set the render backend as a command line option:
<binary name> -graphicssystem opengl
I am currently developing a video player.
The GUI as the topmost layer is written in QML. It should be transparent to lower layers. It contains control elements, some Lists etc., It's displayed using a QDeclarativeView.
Description
QDeclarativeView *upperLayer = new QDeclarativeView(this);
upperLayer->setSource(QUrl("/home/projects/QtVideo/qml/videoControl.qml"));
upperLayer->setStyleSheet(QString("background: transparent");
upperLayer->setResizeMode(QDeclarativeView::SizeRootObjectToView);
uperLayer->showFullScreen();
The layer underneath is a QWidget: I use the libvlc to display the video content
in this widget.
Reason: I am receiving MPEG-TS, which can not be decoded by phonon, afaik. Therefore I need the libvlc to decode the incoming *.ts stream and put the output onto the display.
QWidget *lowerLayer = new QWidget(this);
lowerLayer.setGeometry(QString("background: red"));
QUrl* url = new QUrl("file:///home/projects/QtVideo/video.ts");
libvlc_instance_t*vlcObject;
libvlc_media_t*vlcMedia;
libvlc_media_player_t*vlcPlayer;
vlcPlayer = NULL;
if(vlcObject = libvlc_new(argc, argv)) == NULL)
{
printf("Not able to initialize";
exit(1);
}
if(vlcPlayer && libvlc_media_player_is_playing(vlcPlayer))
{
libvlc_media_player_stop(vlcPlayer);
}
vlcPlayer = libvlc_media_player_new(vlcObject);
vlcMedia = libvlc_media_new_location(vlcObject, url.toString().toUtf8().constData());
libvlc_media_player_set_media(vlcPlayer, vlcMedia);
#if defined(Q_OS_MAC)
libvlc_media_player_set_nsobject(vlcPlayer, lowerLayer->winId());
#elif defined(Q_OS_UNIX)
libvlc_media_player_set_x_window(vlcPlayer, lowerLayer->winId());
#elif defined(Q_OS_WIN)
libvlc_media_player_set_hwnd(vlcPlayer, lowerLayer->winId());
#endif
libvlc_media_player_play(vlc_player);
Both Elements, the QDeclarativeView and the QWidget
are embedded in a QMainWindow, lowerLayer created before the upperLayer,
upperLayer Transparent to the lowerLayer.
The Problem:
As long as the lowerLayer is displaying static elements such as a picture, or some colored shapes, everything works fine, full transparency and functionality.
As soon as I start displaying a video, such as the described *.ts using the libvlc OR some random video using the Phonon::VideoPlayer, the parts of the upperLayer which are above the video parts of the lowerLayer are displayed in the color of the lowerLayer(default: gray), the parts of the upperLayer which are positioned above parts of the lowerLayer or others which do not contain video elements are displayed in correct behaviour.
Question:
Is there any posibility and if, how, to get the upperLayer transparent, even if there is a video playing?
Are you still fighting with this issue? I, sadly, do not have a satisfying answer for you. The best I can do is point you to reasons why it doesn't work:
http://lists.trolltech.com/qt-interest/2007-02/thread01061-0.html
See Message #4 in the link above.
I have tried many different methods to get transparent painting over a video (specifically Phonon::VideoPlayer) using Qt. The only method I've found so far, is to set the overlaying QWidget as a toolTip doing something like
pWidget->setWindowFlags(Qt::ToolTip)
Depending on what exactly you're wanting to do this may be sufficient, but (in my opinion) it's a hack at best. I'm actively struggling with this issue and if I can find some sort of solution, I'll be sure to post it here.
Best of luck.
you're using direct rendering (by passing the wid of the widget) which draws the video overtop at that geometry:
libvlc_media_player_set_x_window
you need to use offscreen rendering and draw that to your qwidget. this can be done with an opengl context (complicated) or using the callback methods available in libvlc.
if you use the display callback (libvlc_video_display_cb) libvlc will also generate lock/unlock methods also, if you need. in this method libvlc will expect some parameters to be set such as canvas geometry and pixel format.
that said, phonon has a libvlc backend which might help, but may still use direct rendering depending on some factors..
I have a Carbon LSUIElement application, which runs in the background (possibly with an icon in the menubar, depending on a pref) and occasionally needs to show a dialog to the user - sometimes in response to a user event, but sometimes in response to a background task failing or similar.
(I'm using Qt 4.5, so the application is Carbon based; With Qt 4.6 things will be Cocoa based, but it sounds as if the problem may exist there too).
The problem is that when I open a window, and show it, it doesn't get brought to the front. I assume this is an artefect of being an LSUIElement app. Qt uses SelectWindow in Carbon, and [makeKeyAndOrderFront] in Cocoa, to bring a window (and the app) to the front.
To work around the problem, I tried going direct to the window server: (the first few steps are to get the WindowID, this will be simpler with Qt-Cocoa, since I can use NSWindow:nativeWindow)
WindowRef ref = HIViewGetWindow((HIViewRef) aWidget->winId());
CGSWindow wid = GetNativeWindowFromWindowRef(ref);
CGSConnection cid =_CGSDefaultConnection();
CGSOrderWindow(cid, wid, 1 /* above everything */, 0 /* NULL */);
This works, sort of - the window comes to the front, but it's not highlighted or keyboard focused. Are there additional steps to fix those issues, or is there a simpler solution to the whole problem?
Use SetFrontProcessWithOptions to bring your window in front of other apps.
Try:
[NSApp activateIgnoringOtherApps: YES]